Skip to content

Instantly share code, notes, and snippets.

@pleasemarkdarkly
Created September 15, 2020 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pleasemarkdarkly/05cee51f8ce05a823e1f9caf7066e7cf to your computer and use it in GitHub Desktop.
Save pleasemarkdarkly/05cee51f8ce05a823e1f9caf7066e7cf to your computer and use it in GitHub Desktop.
#!/bin/bash
# Put this in /usr/local/etc/rc.d/
# chown this to root
# chmod this to 755
# Must be run as root!
SESSION=$(date +"%Y%m%d-%H%M")
SYSTEM_LOG="/root/synology-extra-config.${SESSION}.log"
VOLUME_MOUNTS="/volume1/systems/synology_918+/mounts"
CHROOT_INSTALL="/volume1/@appstore/debian-chroot/var/chroottarget"
[ ! -f "${SYSTEM_LOG}" ] && touch "${SYSTEM_LOG}"
do_start() {
echo "Starting $0…"
echo "Synology root"
mount -vo bind "${VOLUME_MOUNTS}/root" "/root"
echo "Synology homes is simlinked"
echo "Chroot root/home folders mount"
mount -vo bind "${VOLUME_MOUNTS}/debian-chroot.root" "${CHROOT_INSTALL}/root"
mount -vo bind "${VOLUME_MOUNTS}/homes" "${CHROOT_INSTALL}/home"
echo "Started $0."
}
do_stop() {
echo "Stopping $0…"
umount /root
umount "${CHROOT_INSTALL}/root"
umount "${CHROOT_INSTALL}/home"
echo "Stopped $0."
}
do_status() {
echo "Status $0_"
echo "/root mount status: " && (grep "/root " /proc/mounts && echo "mounted" || echo "not mounted")
echo "${CHROOT_INSTALL}/root mount status: " && (grep "${CHROOT_INSTALL}/root " /proc/mounts && echo "mounted" || echo "not mounted")
echo "${CHROOT_INSTALL}/home mount status: " && (grep "${CHROOT_INSTALL}/home " /proc/mounts && echo "mounted" || echo "not mounted")
echo "Status $0_"
}
case "$1" in
start)
do_start | tee -a "${SYSTEM_LOG}"
;;
stop)
do_stop | tee -a "${SYSTEM_LOG}"
;;
status)
do_status | tee -a "${SYSTEM_LOG}"
;;
*) echo "Usage: $0 [start|stop|status]"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment