When a user has the same name as his primary group, userdel(1) tries
to remove it as well, but stops and prints an error message if that
group is being used by any other users as their primary group. By
deleting the www user first, the group is properly deleted. This
means we can get rid of the subsequent call to groupdel(1).
Tested by adding / removing a vhost on my testing vm.
Shellcheck pass and code cleanup.
Set stricter error handling with sh options.
Removes the for loop and cat(1) in favor of directly calling the
file with cut(1) and piping the output to a while read loop. Read
https://github.com/koalaman/shellcheck/wiki/SC2002 for more info.
Adds proper variable globbing.
Removes the large block of commented code, if this turns out to be
necessary, we can add a condition check to the script instead of
uncommenting on a per case basis.
Some people forget to use the --follow-symlinks flag with sed(1),
thus not carrying changes over to /etc/apache2/sites-available.
This new command makes sure all vhosts in /etc/apache2/sites-enabled
are symlinks. It assumes that we always want to overwrite the file in
/etc/apache2/sites-available with the file in /etc/apache2/sites-enabled.
All uses of the VHOST_PATH variable in the code append a slash to
it, so it is easier to remove the trailing slash in it's instantiation.
Also simplifies the sed(1) invocation.
Adds more portable bash invocation.
Adds more severe bash evaluation.
Added h flag and made improper use print the usage function.
Added checks that make sure the parameters are okay.
Proper variable quoting, tests and $() use.
Setting / unsetting IFS variables can be removed by setting it only
in the loop context.
The for cat can be replaced by a simpler while read loop.
Proper variable quoting was added.
Changed the way modif was optionally passed, this removes the
extraneous ':' at the end.
echo(1) the lines as we go instead of building an array, this removes
the possibility of sub-shell screwups.