Last active
May 11, 2023 05:04
-
-
Save Ozymandias42/6b6c9484001e36e8ebff2d505da04438 to your computer and use it in GitHub Desktop.
Chroot script for use with locked down Linux based NAS OSes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
basepath=$(dirname "${0}") | |
if [ "${basepath}" = "." ] | |
then | |
alpine="${PWD}/alpine" | |
else | |
alpine="${basepath}/alpine" | |
fi | |
#Folder to check for | |
folders="proc sys dev " | |
for i in ${folders} | |
do | |
mkdir -p "${alpine}"/"${i}" | |
done | |
mount -t proc none "${alpine}/proc" | |
mount -t sysfs /sys "${alpine}/sys" -o ro | |
mount --bind /dev "${alpine}/dev" | |
mount --bind /dev/sda "${alpine}/dev/sda" | |
mount --bind /dev/sdb "${alpine}/dev/sdb" | |
if [ -f /etc/resolv.conf ] ; then cp /etc/resolv.conf "${alpine}/etc/resolv.conf" ; fi | |
chroot "${alpine}" ${1} | |
umount -R "${alpine}/proc" | |
umount -R "${alpine}/sys" | |
umount -R "${alpine}/dev" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment