Merge pull request #10 from lemniskett/unified_uth
Unified under the hood commands.
This commit is contained in:
commit
a7a36de8fe
17
README.md
17
README.md
@ -29,7 +29,7 @@ Description=Archbox init
|
||||
PartOf=multi-user.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/local/bin/archbox --mount
|
||||
ExecStart=/usr/local/share/archbox/bin/init start
|
||||
Type=oneshot
|
||||
User=root
|
||||
|
||||
@ -38,7 +38,10 @@ WantedBy=multi-user.target
|
||||
```
|
||||
Thanks to [@SamsiFPV](https://github.com/SamsiFPV)
|
||||
|
||||
If you don't use systemd, either create your own init service, or create a @reboot cronjob.
|
||||
If you don't use systemd, either create your own init service, or create a @reboot cronjob :
|
||||
```
|
||||
@reboot /usr/local/share/archbox/bin/init start
|
||||
```
|
||||
### Removing chroot environment
|
||||
**IMPORTANT**, Make sure you've unmounted everything in chroot environment, it's better to remove the init script and reboot to unmount everything. if you can't reboot for some reason, do :
|
||||
```
|
||||
@ -70,14 +73,14 @@ archbox sudo pacman -Syu
|
||||
You may want to add these rules if you want to use Archbox without password (assuming the install prefix is ```/usr/local``` and you're in group ```wheel```) :
|
||||
#### Sudo
|
||||
```
|
||||
%wheel ALL=(root) NOPASSWD: /usr/local/share/archbox/bin/archbox,/usr/local/share/archbox/bin/copyresolv,/usr/local/share/archbox/bin/remount_run,/usr/local/share/archbox/bin/archboxinit
|
||||
%wheel ALL=(root) NOPASSWD: /usr/local/shre/archbox/bin/enter,/usr/local/share/archbox/bin/exec,/usr/local/share/archbox/bin/uth,/usr/local/share/archbox/bin/init
|
||||
```
|
||||
#### Doas
|
||||
```
|
||||
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/archbox
|
||||
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/copyresolv
|
||||
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/remount_run
|
||||
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/archboxinit
|
||||
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/enter
|
||||
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/exec
|
||||
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/uth
|
||||
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/init
|
||||
```
|
||||
### Misc
|
||||
#### Systemd services
|
||||
|
30
archbox.bash
30
archbox.bash
@ -6,17 +6,13 @@ checkdep(){
|
||||
hash $1 2>/dev/null || err "Install $1!"
|
||||
}
|
||||
|
||||
copyresolv(){
|
||||
$PRIV $PREFIX/share/archbox/bin/copyresolv
|
||||
}
|
||||
|
||||
asroot(){
|
||||
[[ $EUID -ne 0 ]] && err "Run this as root!"
|
||||
}
|
||||
|
||||
storeenv() {
|
||||
echo "# This will be sourced when entering Archbox" > /tmp/archbox_env
|
||||
chmod 777 /tmp/archbox_env >/dev/null 2>&1
|
||||
$PRIV $PREFIX/share/archbox/bin/uth chownvar $USER
|
||||
[[ ! -z $WAYLAND_DISPLAY ]] && echo "WAYLAND_DISPLAY=$WAYLAND_DISPLAY" >> /tmp/archbox_env
|
||||
if [[ ! -z $DISPLAY ]]; then
|
||||
hash xhost >/dev/null 2>&1 && xhost +local: > /dev/null
|
||||
@ -86,34 +82,30 @@ case $1 in
|
||||
checkdep sed
|
||||
sed -i 's/CheckSpace/#CheckSpace/g' $CHROOT/etc/pacman.conf
|
||||
msg "Mounting necessary filesystems..."
|
||||
$PREFIX/share/archbox/bin/archboxinit start
|
||||
$PREFIX/share/archbox/bin/init start
|
||||
cp $PREFIX/share/archbox/chroot_setup.bash $CHROOT/chroot_setup
|
||||
echo $USER > /tmp/archbox_user
|
||||
echo $ARCHBOX_USER > /tmp/archbox_user
|
||||
chroot $CHROOT /bin/bash -c "/chroot_setup"
|
||||
exit $?
|
||||
;;
|
||||
-e|--enter)
|
||||
storeenv
|
||||
copyresolv
|
||||
$PRIV $PREFIX/share/archbox/bin/archbox enter
|
||||
$PRIV $PREFIX/share/archbox/bin/uth copyresolv
|
||||
$PRIV $PREFIX/share/archbox/bin/enter
|
||||
exit $?
|
||||
;;
|
||||
-m|--mount)
|
||||
storeenv
|
||||
$PRIV $PREFIX/share/archbox/bin/archboxinit start
|
||||
$PRIV $PREFIX/share/archbox/bin/init start
|
||||
;;
|
||||
-u|--umount)
|
||||
storeenv
|
||||
$PRIV $PREFIX/share/archbox/bin/archboxinit stop
|
||||
$PRIV $PREFIX/share/archbox/bin/init stop
|
||||
;;
|
||||
--remount-run)
|
||||
storeenv
|
||||
$PRIV $PREFIX/share/archbox/bin/remount_run
|
||||
$PRIV $PREFIX/share/archbox/bin/uth remountrun
|
||||
exit $?
|
||||
;;
|
||||
--mount-runtime-only)
|
||||
storeenv
|
||||
$PRIV $PREFIX/share/archbox/bin/remount_run runtimeonly
|
||||
$PRIV $PREFIX/share/archbox/bin/uth runtimeonly
|
||||
exit $?
|
||||
;;
|
||||
-h|--help)
|
||||
@ -129,8 +121,8 @@ case $1 in
|
||||
;;
|
||||
*)
|
||||
storeenv
|
||||
copyresolv
|
||||
$PRIV $PREFIX/share/archbox/bin/archbox $@
|
||||
$PRIV $PREFIX/share/archbox/bin/uth copyresolv
|
||||
$PRIV $PREFIX/share/archbox/bin/exec $@
|
||||
exit $?
|
||||
;;
|
||||
esac
|
||||
|
@ -1,4 +1,4 @@
|
||||
USER="lemniskett"
|
||||
ARCHBOX_USER="lemniskett"
|
||||
PRIV="sudo"
|
||||
INSTALL_PATH="/var/archlinux"
|
||||
CHROOT="$INSTALL_PATH/root.x86_64"
|
||||
|
@ -1,4 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source /etc/archbox.conf
|
||||
cp /etc/resolv.conf $CHROOT/etc/resolv.conf
|
@ -10,5 +10,4 @@ REQ_ENV+="XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR "
|
||||
|
||||
ENV="$REQ_ENV $ENV_VAR"
|
||||
COMMAND="$@"
|
||||
[[ $1 = "enter" ]] && (chroot $CHROOT /sbin/env $ENV /bin/su $USER; exit 0) \
|
||||
|| chroot $CHROOT /bin/su -c "env $ENV $COMMAND" $USER
|
||||
chroot $CHROOT /sbin/env $ENV /bin/su $ARCHBOX_USER
|
13
exec.bash
Normal file
13
exec.bash
Normal file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source /etc/archbox.conf
|
||||
source /tmp/archbox_env
|
||||
|
||||
REQ_ENV="DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS "
|
||||
REQ_ENV+="XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR "
|
||||
[[ ! -z $DISPLAY ]] && REQ_ENV+="DISPLAY=$DISPLAY "
|
||||
[[ ! -z $WAYLAND_DISPLAY ]] && REQ_ENV+="WAYLAND_DISPLAY=$WAYLAND_DISPLAY "
|
||||
|
||||
ENV="$REQ_ENV $ENV_VAR"
|
||||
COMMAND="$@"
|
||||
chroot $CHROOT /bin/su -c "env $ENV $COMMAND" $ARCHBOX_USER
|
@ -3,4 +3,4 @@
|
||||
source /etc/archbox.conf
|
||||
|
||||
startx
|
||||
$PRIV $PREFIX/share/archbox/bin/remount_run killxdg
|
||||
$PRIV $PREFIX/share/archbox/bin/uth killxdg
|
||||
|
@ -6,11 +6,11 @@ mkdir -p $PREFIX/share/archbox/bin
|
||||
install -v -D -m 755 ./archbox.bash $PREFIX/bin/archbox
|
||||
install -v -D -m 755 ./archbox-desktop.bash $PREFIX/bin/archbox-desktop
|
||||
[[ ! -e /etc/archbox.conf ]] && install -v -D -m 755 ./archbox.conf /etc/archbox.conf
|
||||
install -v -D -m 755 ./copyresolv.bash $PREFIX/share/archbox/bin/copyresolv
|
||||
install -v -D -m 755 ./archboxcommand.bash $PREFIX/share/archbox/bin/archbox
|
||||
install -v -D -m 755 ./remount_run.bash $PREFIX/share/archbox/bin/remount_run
|
||||
install -v -D -m 755 ./exec.bash $PREFIX/share/archbox/bin/exec
|
||||
install -v -D -m 755 ./enter.bash $PREFIX/share/archbox/bin/enter
|
||||
install -v -D -m 755 ./chroot_setup.bash $PREFIX/share/archbox/chroot_setup.bash
|
||||
install -v -D -m 755 ./archboxinit.bash $PREFIX/share/archbox/bin/archboxinit
|
||||
install -v -D -m 755 ./init.bash $PREFIX/share/archbox/bin/init
|
||||
install -v -D -m 755 ./uth.bash $PREFIX/share/archbox/bin/uth
|
||||
|
||||
grep 'PREFIX=' /etc/archbox.conf >/dev/null 2>&1 || cat << EOF >> /etc/archbox.conf
|
||||
|
||||
|
@ -4,6 +4,9 @@ source /etc/archbox.conf
|
||||
source /tmp/archbox_env
|
||||
|
||||
case $1 in
|
||||
copyresolv)
|
||||
cp /etc/resolv.conf $CHROOT/etc/resolv.conf
|
||||
;;
|
||||
killxdg)
|
||||
umount -l $CHROOT/run
|
||||
fuser -km $XDG_RUNTIME_DIR
|
||||
@ -16,9 +19,13 @@ case $1 in
|
||||
mount --rbind $XDG_RUNTIME_DIR $CHROOT$XDG_RUNTIME_DIR
|
||||
exit $?
|
||||
;;
|
||||
*)
|
||||
umount -l $CHROOT/run
|
||||
remountrun)
|
||||
umount -l $CHROOT/run 2>/dev/null
|
||||
mount --rbind /run $CHROOT/run
|
||||
exit $?
|
||||
;;
|
||||
chownvar)
|
||||
chown $2:$2 /tmp/archbox_env
|
||||
chmod 700 /tmp/archbox_env
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue
Block a user