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
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
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

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
fi
# if virtualhost mount in fstab exists remove it
if grep -q "/usr/jails/$username/srv/www/$virtualhost" /etc/fstab; then
sed -i "\|/usr/jails/$username/srv/www/$virtualhost|d" /etc/fstab
# if virtualhost mount in fstab.jails exists remove it
if grep -q "/usr/jails/$username/srv/www/$virtualhost" /etc/fstab.jails; then
sed -i "\|/usr/jails/$username/srv/www/$virtualhost|d" /etc/fstab.jails
fi
# 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
fi
# check for virtualhost jail mount(s) in fstab
if /bin/grep -q " /usr/jails/$username/srv/www/" /etc/fstab; then
# check for virtualhost jail mount(s) in fstab.jails
if /bin/grep -q " /usr/jails/$username/srv/www/" /etc/fstab.jails; then
echo user \"$username\" has one or more jailed vhost mounts
exit 1
fi
@ -62,9 +62,9 @@ if grep -q "^/dev/sda /usr/jails/$username/home/$username " /etc/mtab; then
umount /usr/jails/$username/home/$username
fi
# if user home dir mount in fstab exists remove it
if grep -q "^/home/$username /usr/jails/$username/home/$username " /etc/fstab; then
sed -i "\|/home/$username /usr/jails/$username/home/$username|d" /etc/fstab
# if user home dir mount in fstab.jails exists remove it
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.jails
fi
# 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
install -d -o $username -g $username -m 755 /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
jk_socketd
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
chmod 755 /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
apt -y install varnish