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
|
PartOf=multi-user.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStart=/usr/local/bin/archbox --mount
|
ExecStart=/usr/local/share/archbox/bin/init start
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
User=root
|
User=root
|
||||||
|
|
||||||
@ -38,7 +38,10 @@ WantedBy=multi-user.target
|
|||||||
```
|
```
|
||||||
Thanks to [@SamsiFPV](https://github.com/SamsiFPV)
|
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
|
### 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 :
|
**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```) :
|
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
|
#### 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
|
#### Doas
|
||||||
```
|
```
|
||||||
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/archbox
|
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/enter
|
||||||
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/copyresolv
|
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/exec
|
||||||
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/remount_run
|
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/uth
|
||||||
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/archboxinit
|
permit nopass :wheel as root cmd /usr/local/share/archbox/bin/init
|
||||||
```
|
```
|
||||||
### Misc
|
### Misc
|
||||||
#### Systemd services
|
#### Systemd services
|
||||||
|
30
archbox.bash
30
archbox.bash
@ -6,17 +6,13 @@ checkdep(){
|
|||||||
hash $1 2>/dev/null || err "Install $1!"
|
hash $1 2>/dev/null || err "Install $1!"
|
||||||
}
|
}
|
||||||
|
|
||||||
copyresolv(){
|
|
||||||
$PRIV $PREFIX/share/archbox/bin/copyresolv
|
|
||||||
}
|
|
||||||
|
|
||||||
asroot(){
|
asroot(){
|
||||||
[[ $EUID -ne 0 ]] && err "Run this as root!"
|
[[ $EUID -ne 0 ]] && err "Run this as root!"
|
||||||
}
|
}
|
||||||
|
|
||||||
storeenv() {
|
storeenv() {
|
||||||
echo "# This will be sourced when entering Archbox" > /tmp/archbox_env
|
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
|
[[ ! -z $WAYLAND_DISPLAY ]] && echo "WAYLAND_DISPLAY=$WAYLAND_DISPLAY" >> /tmp/archbox_env
|
||||||
if [[ ! -z $DISPLAY ]]; then
|
if [[ ! -z $DISPLAY ]]; then
|
||||||
hash xhost >/dev/null 2>&1 && xhost +local: > /dev/null
|
hash xhost >/dev/null 2>&1 && xhost +local: > /dev/null
|
||||||
@ -86,34 +82,30 @@ case $1 in
|
|||||||
checkdep sed
|
checkdep sed
|
||||||
sed -i 's/CheckSpace/#CheckSpace/g' $CHROOT/etc/pacman.conf
|
sed -i 's/CheckSpace/#CheckSpace/g' $CHROOT/etc/pacman.conf
|
||||||
msg "Mounting necessary filesystems..."
|
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
|
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"
|
chroot $CHROOT /bin/bash -c "/chroot_setup"
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
-e|--enter)
|
-e|--enter)
|
||||||
storeenv
|
storeenv
|
||||||
copyresolv
|
$PRIV $PREFIX/share/archbox/bin/uth copyresolv
|
||||||
$PRIV $PREFIX/share/archbox/bin/archbox enter
|
$PRIV $PREFIX/share/archbox/bin/enter
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
-m|--mount)
|
-m|--mount)
|
||||||
storeenv
|
$PRIV $PREFIX/share/archbox/bin/init start
|
||||||
$PRIV $PREFIX/share/archbox/bin/archboxinit start
|
|
||||||
;;
|
;;
|
||||||
-u|--umount)
|
-u|--umount)
|
||||||
storeenv
|
$PRIV $PREFIX/share/archbox/bin/init stop
|
||||||
$PRIV $PREFIX/share/archbox/bin/archboxinit stop
|
|
||||||
;;
|
;;
|
||||||
--remount-run)
|
--remount-run)
|
||||||
storeenv
|
$PRIV $PREFIX/share/archbox/bin/uth remountrun
|
||||||
$PRIV $PREFIX/share/archbox/bin/remount_run
|
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
--mount-runtime-only)
|
--mount-runtime-only)
|
||||||
storeenv
|
$PRIV $PREFIX/share/archbox/bin/uth runtimeonly
|
||||||
$PRIV $PREFIX/share/archbox/bin/remount_run runtimeonly
|
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
@ -129,8 +121,8 @@ case $1 in
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
storeenv
|
storeenv
|
||||||
copyresolv
|
$PRIV $PREFIX/share/archbox/bin/uth copyresolv
|
||||||
$PRIV $PREFIX/share/archbox/bin/archbox $@
|
$PRIV $PREFIX/share/archbox/bin/exec $@
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
USER="lemniskett"
|
ARCHBOX_USER="lemniskett"
|
||||||
PRIV="sudo"
|
PRIV="sudo"
|
||||||
INSTALL_PATH="/var/archlinux"
|
INSTALL_PATH="/var/archlinux"
|
||||||
CHROOT="$INSTALL_PATH/root.x86_64"
|
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"
|
ENV="$REQ_ENV $ENV_VAR"
|
||||||
COMMAND="$@"
|
COMMAND="$@"
|
||||||
[[ $1 = "enter" ]] && (chroot $CHROOT /sbin/env $ENV /bin/su $USER; exit 0) \
|
chroot $CHROOT /sbin/env $ENV /bin/su $ARCHBOX_USER
|
||||||
|| chroot $CHROOT /bin/su -c "env $ENV $COMMAND" $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
|
source /etc/archbox.conf
|
||||||
|
|
||||||
startx
|
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.bash $PREFIX/bin/archbox
|
||||||
install -v -D -m 755 ./archbox-desktop.bash $PREFIX/bin/archbox-desktop
|
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
|
[[ ! -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 ./exec.bash $PREFIX/share/archbox/bin/exec
|
||||||
install -v -D -m 755 ./archboxcommand.bash $PREFIX/share/archbox/bin/archbox
|
install -v -D -m 755 ./enter.bash $PREFIX/share/archbox/bin/enter
|
||||||
install -v -D -m 755 ./remount_run.bash $PREFIX/share/archbox/bin/remount_run
|
|
||||||
install -v -D -m 755 ./chroot_setup.bash $PREFIX/share/archbox/chroot_setup.bash
|
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
|
grep 'PREFIX=' /etc/archbox.conf >/dev/null 2>&1 || cat << EOF >> /etc/archbox.conf
|
||||||
|
|
||||||
|
@ -3,22 +3,29 @@
|
|||||||
source /etc/archbox.conf
|
source /etc/archbox.conf
|
||||||
source /tmp/archbox_env
|
source /tmp/archbox_env
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
|
copyresolv)
|
||||||
|
cp /etc/resolv.conf $CHROOT/etc/resolv.conf
|
||||||
|
;;
|
||||||
killxdg)
|
killxdg)
|
||||||
umount -l $CHROOT/run
|
umount -l $CHROOT/run
|
||||||
fuser -km $XDG_RUNTIME_DIR
|
fuser -km $XDG_RUNTIME_DIR
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
runtimeonly)
|
runtimeonly)
|
||||||
mkdir -p $CHROOT$XDG_RUNTIME_DIR
|
mkdir -p $CHROOT$XDG_RUNTIME_DIR
|
||||||
umount -Rl $CHROOT$XDG_RUNTIME_DIR 2>/dev/null
|
umount -Rl $CHROOT$XDG_RUNTIME_DIR 2>/dev/null
|
||||||
mount | grep $CHROOT$XDG_RUNTIME_DIR || \
|
mount | grep $CHROOT$XDG_RUNTIME_DIR || \
|
||||||
mount --rbind $XDG_RUNTIME_DIR $CHROOT$XDG_RUNTIME_DIR
|
mount --rbind $XDG_RUNTIME_DIR $CHROOT$XDG_RUNTIME_DIR
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
*)
|
remountrun)
|
||||||
umount -l $CHROOT/run
|
umount -l $CHROOT/run 2>/dev/null
|
||||||
mount --rbind /run $CHROOT/run
|
mount --rbind /run $CHROOT/run
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
esac
|
chownvar)
|
||||||
|
chown $2:$2 /tmp/archbox_env
|
||||||
|
chmod 700 /tmp/archbox_env
|
||||||
|
;;
|
||||||
|
esac
|
Loading…
Reference in New Issue
Block a user