jails use fstab.jails

This commit is contained in:
Matthew Saunders Brown 2021-08-18 16:13:02 -07:00
parent de4e34d6ba
commit 721b43541a
5 changed files with 15 additions and 10 deletions

View File

@ -56,7 +56,7 @@ if [ -d /usr/jails/$username ]; then
if [ ! -d /usr/jails/$username/srv/www/$virtualhost ]; then if [ ! -d /usr/jails/$username/srv/www/$virtualhost ]; then
install -d -o $username -g $username -m 755 /usr/jails/$username/srv/www/$virtualhost install -d -o $username -g $username -m 755 /usr/jails/$username/srv/www/$virtualhost
mount --bind /srv/www/$virtualhost /usr/jails/$username/srv/www/$virtualhost mount --bind /srv/www/$virtualhost /usr/jails/$username/srv/www/$virtualhost
echo "/srv/www/$virtualhost /usr/jails/$username/srv/www/$virtualhost none bind 0 0" >> /etc/fstab echo "/srv/www/$virtualhost /usr/jails/$username/srv/www/$virtualhost none bind 0 0" >> /etc/fstab.jails
fi fi
fi fi

View File

@ -46,9 +46,9 @@ if grep -q "^/dev/sda /usr/jails/$username/srv/www/$virtualhost " /etc/mtab; the
umount /usr/jails/$username/srv/www/$virtualhost umount /usr/jails/$username/srv/www/$virtualhost
fi fi
# if virtualhost mount in fstab exists remove it # if virtualhost mount in fstab.jails exists remove it
if grep -q "/usr/jails/$username/srv/www/$virtualhost" /etc/fstab; then if grep -q "/usr/jails/$username/srv/www/$virtualhost" /etc/fstab.jails; then
sed -i "\|/usr/jails/$username/srv/www/$virtualhost|d" /etc/fstab sed -i "\|/usr/jails/$username/srv/www/$virtualhost|d" /etc/fstab.jails
fi fi
# if virtualhost symlink exists in jail remove it # if virtualhost symlink exists in jail remove it

View File

@ -35,8 +35,8 @@ if /bin/grep -q "^/dev/sda /usr/jails/$username/srv/www/" /etc/mtab; then
exit 1 exit 1
fi fi
# check for virtualhost jail mount(s) in fstab # check for virtualhost jail mount(s) in fstab.jails
if /bin/grep -q " /usr/jails/$username/srv/www/" /etc/fstab; then if /bin/grep -q " /usr/jails/$username/srv/www/" /etc/fstab.jails; then
echo user \"$username\" has one or more jailed vhost mounts echo user \"$username\" has one or more jailed vhost mounts
exit 1 exit 1
fi fi
@ -62,9 +62,9 @@ if grep -q "^/dev/sda /usr/jails/$username/home/$username " /etc/mtab; then
umount /usr/jails/$username/home/$username umount /usr/jails/$username/home/$username
fi fi
# if user home dir mount in fstab exists remove it # if user home dir mount in fstab.jails exists remove it
if grep -q "^/home/$username /usr/jails/$username/home/$username " /etc/fstab; then if grep -q "^/home/$username /usr/jails/$username/home/$username " /etc/fstab.jails; then
sed -i "\|/home/$username /usr/jails/$username/home/$username|d" /etc/fstab sed -i "\|/home/$username /usr/jails/$username/home/$username|d" /etc/fstab.jails
fi fi
# delete user # delete user

View File

@ -41,7 +41,7 @@ ln -s /usr/local/sbin/mini_sendmail /usr/jails/$username/usr/sbin/sendmail
chmod a+rwx /usr/jails/$username/tmp chmod a+rwx /usr/jails/$username/tmp
install -d -o $username -g $username -m 755 /usr/jails/$username/home/$username install -d -o $username -g $username -m 755 /usr/jails/$username/home/$username
mount --bind /home/$username /usr/jails/$username/home/$username mount --bind /home/$username /usr/jails/$username/home/$username
echo "/home/$username /usr/jails/$username/home/$username none bind 0 0" >> /etc/fstab echo "/home/$username /usr/jails/$username/home/$username none bind 0 0" >> /etc/fstab.jails
killall jk_socketd killall jk_socketd
jk_socketd jk_socketd
jk_jailuser -n -j /usr/jails/$username -s /bin/bash $username jk_jailuser -n -j /usr/jails/$username -s /bin/bash $username

View File

@ -145,6 +145,11 @@ fi
cp libexec/command-not-found-handle /usr/local/libexec/command-not-found-handle cp libexec/command-not-found-handle /usr/local/libexec/command-not-found-handle
chmod 755 /usr/local/libexec/command-not-found-handle chmod 755 /usr/local/libexec/command-not-found-handle
chown root:root /usr/local/libexec/command-not-found-handle chown root:root /usr/local/libexec/command-not-found-handle
if ! [ -f "/etc/fstab.jails" ]; then
touch /etc/fstab.jails
chmod 644 /etc/fstab.jails
echo "# /etc/fstab.jails: jail bind mounts information." > /etc/fstab.jails
fi
# varnish # varnish
apt -y install varnish apt -y install varnish