Skip to content

Instantly share code, notes, and snippets.

@jorgicio
Created November 18, 2019 01: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 jorgicio/6c7ffa07477a3a69e61779db615afc5a to your computer and use it in GitHub Desktop.
Save jorgicio/6c7ffa07477a3a69e61779db615afc5a to your computer and use it in GitHub Desktop.
Chroot daemon for OpenRC
#!/sbin/openrc-run
depend() {
need localmount
need bootmisc
}
start() {
ebegin "Mounting chroot directories"
mount -o rbind /dev /mnt/dev > /dev/null &
mount -t proc none /mnt/proc > /dev/null &
mount -o bind /sys /mnt/sys > /dev/null &
mount -o bind /tmp /mnt/tmp > /dev/null &
eend $? "An error occurred while mounting chroot directories"
}
stop() {
ebegin "Unmounting chroot directories"
umount -f /mnt/dev > /dev/null &
umount -f /mnt/proc > /dev/null &
umount -f /mnt/sys > /dev/null &
umount -f /mnt/tmp > /dev/null &
eend $? "An error occurred while unmounting chroot directories"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment