2021-04-04 13:28:22 -07:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# vhost-stack
|
|
|
|
# https://git.stack-source.com/msb/vhost-stack
|
|
|
|
# MIT License Copyright (c) 2021 Matthew Saunders Brown
|
|
|
|
|
2021-04-04 14:15:16 -07:00
|
|
|
# load include file
|
|
|
|
source $(dirname $0)/vhost.sh
|
2021-04-04 13:28:22 -07:00
|
|
|
|
2021-09-16 16:21:35 -07:00
|
|
|
help()
|
|
|
|
{
|
|
|
|
thisfilename=$(basename -- "$0")
|
|
|
|
echo "Make sure all home (/home/...) and virtualhost (/srv/www/...) files are owned by correct users."
|
|
|
|
echo ""
|
2021-10-05 11:33:24 -07:00
|
|
|
echo "usage: $thisfilename [-n|-v] [-h]"
|
2021-09-16 16:21:35 -07:00
|
|
|
echo ""
|
|
|
|
echo " -h Print this help."
|
|
|
|
echo " -n dry-run - List all files that need modification, but don't actually do anything."
|
|
|
|
echo " -v verbose - List all files that are being modified."
|
|
|
|
}
|
|
|
|
|
2021-10-05 11:33:24 -07:00
|
|
|
vhost:getoptions "$@"
|
2021-04-04 13:28:22 -07:00
|
|
|
|
|
|
|
for VHOST in /srv/www/*/; {
|
|
|
|
|
|
|
|
# get username
|
|
|
|
USER=$(stat -c '%U' $VHOST)
|
|
|
|
# make sure all files & dirs are owned by user
|
2021-10-05 11:33:24 -07:00
|
|
|
if [[ -n $verbose ]] || [[ -n $dryrun ]]; then
|
2021-04-04 13:28:22 -07:00
|
|
|
/usr/bin/find $VHOST ! -user $USER
|
|
|
|
fi
|
2021-10-05 11:33:24 -07:00
|
|
|
if [[ -n $dryrun ]]; then
|
2021-04-04 13:28:22 -07:00
|
|
|
/usr/bin/find $VHOST ! -user $USER -exec chown $USER {} +
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for HOME in /home/*/; {
|
|
|
|
|
|
|
|
# get username
|
|
|
|
USER=$(stat -c '%U' $HOME)
|
|
|
|
# make sure all files & dirs are owned by user
|
2021-10-05 11:33:24 -07:00
|
|
|
if [[ -n $verbose ]] || [[ -n $dryrun ]]; then
|
2021-04-04 13:28:22 -07:00
|
|
|
/usr/bin/find $HOME ! -user $USER
|
|
|
|
fi
|
2021-10-05 11:33:24 -07:00
|
|
|
if [[ -n $dryrun ]]; then
|
2021-04-04 13:28:22 -07:00
|
|
|
/usr/bin/find $HOME ! -user $USER -exec chown $USER {} +
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|