archbox/archboxinit.bash

53 lines
1.4 KiB
Bash
Raw Normal View History

2020-12-28 05:22:53 +00:00
#!/usr/bin/env bash
2020-10-27 06:12:14 +00:00
source /etc/archbox.conf
2021-01-04 04:38:20 +00:00
msg(){
echo "$(tput bold)$(tput setaf 2)==> $@ $(tput sgr0)"
}
rbind() {
[[ $(mount | grep $CHROOT$1) ]] && msg "$CHROOT$1 already mounted." \
|| (mount -R $1 $CHROOT$1 && msg "$CHROOT$1 mounted!")
[[ $2 = "make-rslave" ]] && mount --make-rslave $CHROOT$1
}
bindproc() {
[[ $(mount | grep $CHROOT/proc) ]] && msg "$CHROOT already mounted." \
|| (mount -t proc /proc $CHROOT/proc && msg "$CHROOT/proc mounted!")
}
rmbind() {
umount_args=-R
[[ $LAZY_UMOUNT = "yes" ]] && umount_args=-Rl
[[ $(mount | grep $CHROOT$1) ]] && umount $umount_args $CHROOT$1 \
&& msg "$CHROOT$1 unmounted!"
}
2020-11-11 13:02:05 +00:00
case $1 in
2020-12-31 16:16:31 +00:00
start)
2021-01-04 04:38:20 +00:00
rbind /home
bindproc
rbind /tmp
rbind /sys make-rslave
rbind /dev make-rslave
[[ $MOUNT_RUN = "yes" ]] && rbind /run
[[ $MOUNT_MOD = "yes" ]] && rbind /lib/modules && rbind /boot
[[ -d /var/lib/dbus ]] && rbind /var/lib/dbus
2020-12-31 16:16:31 +00:00
chroot $CHROOT /usr/local/bin/serviced >/dev/null 2>&1
exit 0
;;
stop)
2021-01-04 04:38:20 +00:00
rmbind /home
rmbind /proc
rmbind /tmp
rmbind /sys
rmbind /dev
[[ $MOUNT_RUN = "yes" ]] && rmbind /run
[[ $MOUNT_MOD = "yes" ]] && rmbind /lib/modules && rmbind /boot
rmbind /var/lib/dbus
kill $(pidof serviced) 2>/dev/null
2020-12-31 16:16:31 +00:00
exit 0
;;
2020-11-11 13:02:05 +00:00
esac