Add way to mount to different directory.

This commit is contained in:
Syahrial Agni Prasetya 2021-03-06 13:58:22 +07:00
parent ed0e441644
commit fe2e490ff4
No known key found for this signature in database
GPG Key ID: 46F88749C8C79383
2 changed files with 24 additions and 5 deletions

View File

@ -141,7 +141,10 @@ Edit SHARED_FOLDER in ```/etc/archbox.conf```. For example:
``` ```
SHARED_FOLDER=( /home /var/www ) SHARED_FOLDER=( /home /var/www )
``` ```
Note that this will recursively mount directories. To mount to different directory, use ```:``` separator :
```
SHARED_FOLDER=( /home /var/www:/host_webroot )
```
### Known issues ### Known issues
#### NixOS-specific issues #### NixOS-specific issues
##### /run mounting ##### /run mounting
@ -161,7 +164,7 @@ Or alternatively if you use WM-only, just disable mounting ```/run``` entirely a
##### Archbox didn't access resources in /usr/share ##### Archbox didn't access resources in /usr/share
In Archbox, Symlink ```/usr``` to ```/run/current-system/sw```: In Archbox, Symlink ```/usr``` to ```/run/current-system/sw```:
``` ```
sudo mkdir -p /run/current-system/ sudo mkdir -p /run/current-system
sudo ln -s /usr /run/current-system/sw sudo ln -s /usr /run/current-system/sw
``` ```
make sure /run isn't mounted. make sure /run isn't mounted.

View File

@ -12,6 +12,11 @@ rbind() {
[[ $2 = "make-rslave" ]] && mount --make-rslave $CHROOT$1 [[ $2 = "make-rslave" ]] && mount --make-rslave $CHROOT$1
} }
rbind_diff() {
[[ $(mount | grep $CHROOT$2) ]] && msg "$CHROOT$2 already mounted." \
|| (mount -R $1 $CHROOT$2 && msg "$CHROOT$2 mounted!")
}
bindproc() { bindproc() {
[[ $(mount | grep $CHROOT/proc) ]] && msg "$CHROOT/proc already mounted." \ [[ $(mount | grep $CHROOT/proc) ]] && msg "$CHROOT/proc already mounted." \
|| (mount -t proc /proc $CHROOT/proc && msg "$CHROOT/proc mounted!") || (mount -t proc /proc $CHROOT/proc && msg "$CHROOT/proc mounted!")
@ -37,8 +42,14 @@ case $1 in
fi fi
[[ -d /var/lib/dbus ]] && rbind /var/lib/dbus [[ -d /var/lib/dbus ]] && rbind /var/lib/dbus
for i in ${SHARED_FOLDER[@]}; do for i in ${SHARED_FOLDER[@]}; do
mkdir -p $CHROOT/$i if [[ $i = *:* ]]; then
rbind $i source=$(echo $i | sed 's/:.*//')
target=$(echo $i | sed 's/.*://')
mkdir -p $CHROOT$target
rbind_diff $source $target;
else
rbind $i;
fi
done done
msg "Starting services" msg "Starting services"
for j in ${SERVICES[@]}; do for j in ${SERVICES[@]}; do
@ -71,7 +82,12 @@ case $1 in
fi fi
rmbind /var/lib/dbus rmbind /var/lib/dbus
for i in ${SHARED_FOLDER[@]}; do for i in ${SHARED_FOLDER[@]}; do
rmbind $i if [[ $i = *:* ]]; then
target=$(echo $i | sed 's/.*://')
rmbind $target;
else
rmbind $i;
fi
done done
exit 0 exit 0
;; ;;