commit
995947f185
61
NIXOS_INSTALL.md
Normal file
61
NIXOS_INSTALL.md
Normal file
@ -0,0 +1,61 @@
|
||||
# Installation (NixOS)
|
||||
## Install methods
|
||||
### Declarative Nix
|
||||
To install with nix, create a `.nix` file like this and import it to your `configuration.nix` :
|
||||
```nix
|
||||
{ config, pkgs, ... }:
|
||||
|
||||
let
|
||||
archbox = pkgs.stdenv.mkDerivation rec {
|
||||
name = "archbox";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "lemniskett";
|
||||
repo = "archbox";
|
||||
rev = "rev_here";
|
||||
sha256 = "rev_sha256_here";
|
||||
};
|
||||
sourceRoot = ".";
|
||||
installPhase = ''
|
||||
mkdir -p $out
|
||||
cd source
|
||||
export FORCE_INSTALL_CONFIG=1
|
||||
export ETC_DIR=$out/etc
|
||||
export PREFIX=$out
|
||||
export ARCHBOX_USER=your_user_here
|
||||
export MOUNT_RUN=no
|
||||
${pkgs.bash}/bin/bash install.sh
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
environment.systemPackages = [ archbox ];
|
||||
environment.etc = {
|
||||
"archbox.conf" = {
|
||||
source = "${archbox}/etc/archbox.conf";
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
Replace `your_user_here`, `rev_here`, and `rev_sha256_here`. to get rev and sha256 you can do :
|
||||
```sh
|
||||
nix-shell -p nix-prefetch-git
|
||||
nix-prefetch-git --url https://github.com/lemniskett/archbox.git
|
||||
```
|
||||
|
||||
Configuration can be done by modifying `installPhase` e.g. :
|
||||
```sh
|
||||
mkdir -p $out
|
||||
cd source
|
||||
export FORCE_INSTALL_CONFIG=1
|
||||
export ETC_DIR=$out/etc
|
||||
export PREFIX=$out
|
||||
export ARCHBOX_USER=lemni
|
||||
export MOUNT_RUN=no
|
||||
export ENV_VAR="TERM=foot"
|
||||
export SHARED_FOLDER="/home /var/www"
|
||||
${pkgs.bash}/bin/bash install.sh
|
||||
```
|
||||
### Regular Installation
|
||||
See [INSTALL.md](INSTALL.md)
|
||||
## Issues
|
||||
See [issues](https://github.com/lemniskett/archbox/#nixos-specific-issues)
|
12
README.md
12
README.md
@ -5,6 +5,8 @@ Ever since I'm running some niche distros like Void, Solus, I had a problem find
|
||||
## Installation
|
||||
See [INSTALL.md](INSTALL.md)
|
||||
|
||||
For NixOS users, [NIXOS_INSTALL.md](NIXOS_INSTALL.md)
|
||||
|
||||
For ChromeOS users, [CROS_INSTALL.md](CROS_INSTALL.md)
|
||||
## Using Archbox
|
||||
### Installing chroot environment
|
||||
@ -84,14 +86,14 @@ This isn't actually using systemd to start services, rather it parses systemd .s
|
||||
##### Autostart services
|
||||
To enable service on host boot, edit `/etc/archbox.conf` :
|
||||
```
|
||||
SERVICES=( vmware-networks-configuration vmware-networks vmware-usbarbitrator nginx )
|
||||
SERVICES="vmware-networks-configuration vmware-networks vmware-usbarbitrator nginx"
|
||||
```
|
||||
Keep in mind that this doesn't resolve service dependencies, so you may need to enable the dependencies manually. you can use ```archboxctl desc <service>``` to read the .service file
|
||||
|
||||
##### Post-exec delay
|
||||
Services are asynchronously started, if some services have some issues when starting together you may want to add post-exec delay.
|
||||
```
|
||||
SERVICES=( php-fpm:3 nginx )
|
||||
SERVICES="php-fpm:3 nginx"
|
||||
```
|
||||
|
||||
This will add 3 seconds delay after executing php-fpm.
|
||||
@ -161,6 +163,12 @@ sudo ln -s /usr /run/current-system/sw
|
||||
```
|
||||
make sure /run isn't mounted.
|
||||
|
||||
##### Archbox didn't recognize commands
|
||||
Add ```PATH``` variable to ```/etc/archbox.conf```, for example:
|
||||
```
|
||||
ENV_VAR="PATH=/usr/bin:/usr/local/bin"
|
||||
```
|
||||
|
||||
#### PulseAudio refused to connect
|
||||
This can be caused by different dbus machine-id between chroot and host, copying ```/etc/machine-id``` from host to chroot should do the job.
|
||||
#### XDG_RUNTIME_DIR is not visible in Archbox
|
||||
|
20
install.sh
20
install.sh
@ -27,14 +27,14 @@ ENV_VAR="${ENV_VAR:-}"
|
||||
|
||||
# Parse a Systemd service and executes it on boot, order matters, for example:
|
||||
#
|
||||
# SERVICES=( vmware-networks-configuration vmware-networks vmware-usbarbitrator php-fpm:3 nginx )
|
||||
# SERVICES="vmware-networks-configuration vmware-networks vmware-usbarbitrator php-fpm:3 nginx"
|
||||
#
|
||||
# Keep in mind that this doesn't resolve service dependencies, so you may need to
|
||||
# enable the dependencies manually.
|
||||
SERVICES=( ${SERVICES:-} )
|
||||
SERVICES="${SERVICES:-}"
|
||||
|
||||
# Share other host directories into Archbox, absolute path needed.
|
||||
SHARED_FOLDER=( ${SHARED_FOLDERS:-/home} )
|
||||
SHARED_FOLDER="${SHARED_FOLDERS:-/home}"
|
||||
EOF
|
||||
}
|
||||
|
||||
@ -43,14 +43,14 @@ PREFIX="${PREFIX:-/usr/local}"
|
||||
|
||||
mkdir -p $PREFIX/share/archbox/bin
|
||||
mkdir -p $ETC_DIR
|
||||
install -v -D -m 755 ./src/archbox.bash $PREFIX/bin/archbox
|
||||
install -v -D -m 755 ./src/archbox-desktop.bash $PREFIX/bin/archbox-desktop
|
||||
install -v -D -m 755 ./src/archbox $PREFIX/bin/archbox
|
||||
install -v -D -m 755 ./src/archbox-desktop $PREFIX/bin/archbox-desktop
|
||||
[[ ! -e /etc/archbox.conf || ! -z $FORCE_INSTALL_CONFIG ]] && genconfig > $ETC_DIR/archbox.conf
|
||||
install -v -D -m 755 ./src/exec.bash $PREFIX/share/archbox/bin/exec
|
||||
install -v -D -m 755 ./src/enter.bash $PREFIX/share/archbox/bin/enter
|
||||
install -v -D -m 755 ./src/chroot_setup.bash $PREFIX/share/archbox/chroot_setup.bash
|
||||
install -v -D -m 755 ./src/init.bash $PREFIX/share/archbox/bin/init
|
||||
install -v -D -m 755 ./src/uth.bash $PREFIX/share/archbox/bin/uth
|
||||
install -v -D -m 755 ./src/exec $PREFIX/share/archbox/bin/exec
|
||||
install -v -D -m 755 ./src/enter $PREFIX/share/archbox/bin/enter
|
||||
install -v -D -m 755 ./src/chroot_setup $PREFIX/share/archbox/chroot_setup
|
||||
install -v -D -m 755 ./src/init $PREFIX/share/archbox/bin/init
|
||||
install -v -D -m 755 ./src/uth $PREFIX/share/archbox/bin/uth
|
||||
|
||||
grep 'PREFIX=' $ETC_DIR/archbox.conf >/dev/null 2>&1 || cat << EOF >> $ETC_DIR/archbox.conf
|
||||
|
||||
|
135
src/archbox
Normal file
135
src/archbox
Normal file
@ -0,0 +1,135 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /etc/archbox.conf
|
||||
|
||||
# Text colors/formatting
|
||||
red="\033[38;5;1"
|
||||
green="\033[38;5;2"
|
||||
bold="\033[1m"
|
||||
reset="\033[m"
|
||||
|
||||
err(){
|
||||
printf "${red}${bold}%s${reset}\n" "==> $*" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
msg(){
|
||||
printf "${green}${bold}%s${reset}\n" "==> $*"
|
||||
}
|
||||
|
||||
checkdep(){
|
||||
command -v $1 >/dev/null 2>&1 || err "Install $1!"
|
||||
}
|
||||
|
||||
asroot(){
|
||||
[ $(id -u) -eq 0 ] || err "Run this as root!"
|
||||
}
|
||||
|
||||
storeenv() {
|
||||
printf "%s\n" "# This will be sourced when entering Archbox" > /tmp/archbox_env
|
||||
"$PRIV" ${PREFIX}/share/archbox/bin/uth chownvar $USER
|
||||
[ $WAYLAND_DISPLAY ] && \
|
||||
printf "%s\n" "WAYLAND_DISPLAY=${WAYLAND_DISPLAY}" >> /tmp/archbox_env
|
||||
if [ $DISPLAY ]; then
|
||||
command -v xhost >/dev/null 2>&1 && xhost +local: > /dev/null
|
||||
printf "%s\n" "DISPLAY=${DISPLAY}" >> /tmp/archbox_env
|
||||
fi
|
||||
printf "%s\n" "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS:-disabled:}" >> /tmp/archbox_env
|
||||
printf "%s\n" "XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR:-/tmp}" >> /tmp/archbox_env
|
||||
}
|
||||
|
||||
help_text(){
|
||||
printf "%s" "
|
||||
USAGE: $0 <arguments>
|
||||
|
||||
OPTIONS:
|
||||
-c, --create URL Creates a chroot enviroment.
|
||||
-e, --enter Enters chroot enviroment.
|
||||
-h, --help Displays this help message.
|
||||
-m, --mount Mount Archbox directories.
|
||||
-u, --umount Unmount Archbox directories.
|
||||
--remount-run Remount /run in chroot enviroment.
|
||||
--mount-runtime-only Mount XDG_RUNTIME_DIR to chroot enviroment.
|
||||
|
||||
"
|
||||
}
|
||||
|
||||
fetch_tarball(){
|
||||
if command -v aria2c 2>/dev/null; then
|
||||
aria2c -o archlinux.tar.gz $1
|
||||
elif command -v wget 2>/dev/null; then
|
||||
wget -O archlinux.tar.gz $1
|
||||
elif command -v curl 2>/dev/null; then
|
||||
curl -o archlinux.tar.gz $1
|
||||
else
|
||||
err "No supported downloader found."
|
||||
fi
|
||||
}
|
||||
|
||||
case $1 in
|
||||
-c|--create)
|
||||
asroot
|
||||
echo $2
|
||||
[ ! $2 ] && err "Specify the link of Arch Linux bootstrap tarball!"
|
||||
msg "Creating chroot directory..."
|
||||
mkdir -p $INSTALL_PATH
|
||||
cd $INSTALL_PATH
|
||||
msg "Downloading Arch Linux tarball..."
|
||||
while true; do fetch_tarball $2 && break; done
|
||||
msg "Extracting the tarball..."
|
||||
checkdep tar
|
||||
tar xzf archlinux.tar.gz
|
||||
msg "Enabling internet connection in chroot enviroment..."
|
||||
cp /etc/resolv.conf "${CHROOT}"/etc/resolv.conf
|
||||
msg "You will need to edit which mirror you want to use, uncomment needed mirrors and save it."
|
||||
printf "%s " "Editor of your choice:"
|
||||
read MIRROR_EDITOR
|
||||
$MIRROR_EDITOR "${CHROOT}"/etc/pacman.d/mirrorlist || exit 1
|
||||
msg "Disabling Pacman's CheckSpace..."
|
||||
checkdep sed
|
||||
sed -i "s/CheckSpace/#CheckSpace/g" "${CHROOT}"/etc/pacman.conf
|
||||
msg "Mounting necessary filesystems..."
|
||||
"${PREFIX}"/share/archbox/bin/init start
|
||||
cp "${PREFIX}"/share/archbox/chroot_setup "${CHROOT}"/chroot_setup
|
||||
printf "%s" $ARCHBOX_USER > /tmp/archbox_user
|
||||
chroot $CHROOT /bin/sh /chroot_setup
|
||||
exit $?
|
||||
;;
|
||||
-e|--enter)
|
||||
storeenv
|
||||
"$PRIV" "${PREFIX}"/share/archbox/bin/uth copyresolv
|
||||
"$PRIV" "${PREFIX}"/share/archbox/bin/enter
|
||||
exit $?
|
||||
;;
|
||||
-m|--mount)
|
||||
"$PRIV" "${PREFIX}"/share/archbox/bin/init start
|
||||
;;
|
||||
-u|--umount)
|
||||
"$PRIV" "${PREFIX}"/share/archbox/bin/init stop
|
||||
;;
|
||||
--remount-run)
|
||||
"$PRIV" "${PREFIX}"/share/archbox/bin/uth remountrun
|
||||
exit $?
|
||||
;;
|
||||
--mount-runtime-only)
|
||||
"$PRIV" "${PREFIX}"/share/archbox/bin/uth runtimeonly
|
||||
exit $?
|
||||
;;
|
||||
-h|--help)
|
||||
help_text
|
||||
exit 0
|
||||
;;
|
||||
"")
|
||||
help_text
|
||||
exit 1
|
||||
;;
|
||||
-*)
|
||||
err "Unknown option: $1"
|
||||
;;
|
||||
*)
|
||||
storeenv
|
||||
"$PRIV" "${PREFIX}"/share/archbox/bin/uth copyresolv
|
||||
"$PRIV" "${PREFIX}"/share/archbox/bin/exec $@
|
||||
exit $?
|
||||
;;
|
||||
esac
|
@ -1,29 +1,39 @@
|
||||
#!/usr/bin/env bash
|
||||
#!/bin/sh
|
||||
|
||||
source /etc/archbox.conf &>/dev/null
|
||||
. /etc/archbox.conf >/dev/null 2>&1
|
||||
|
||||
# Text colors/formatting
|
||||
red="\033[38;5;1"
|
||||
green="\033[38;5;2"
|
||||
bold="\033[1m"
|
||||
reset="\033[m"
|
||||
|
||||
err(){
|
||||
printf "${red}${bold}%s${reset}\n" "==> $*" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
msg(){
|
||||
printf "${green}${bold}%s${reset}\n" "==> $*" 1>&2
|
||||
}
|
||||
|
||||
install_desktop(){
|
||||
mkdir -p ~/.local/share/applications/archbox
|
||||
for i in $@; do
|
||||
archbox readlink /usr/share/applications/$i >/dev/null 2>&1 \
|
||||
&& cp $CHROOT/$(archbox readlink /usr/share/applications/$i) ~/.local/share/applications/archbox \
|
||||
|| cp $CHROOT/usr/share/applications/$i ~/.local/share/applications/archbox
|
||||
&& cp "${CHROOT}"/$(archbox readlink /usr/share/applications/$i) ~/.local/share/applications/archbox \
|
||||
|| cp "${CHROOT}"/usr/share/applications/$i "~/.local/share/applications/archbox"
|
||||
sed -i 's/Exec=/Exec=archbox\ /g' ~/.local/share/applications/archbox/$i
|
||||
sed -i '/TryExec=/d' ~/.local/share/applications/archbox/$i
|
||||
done
|
||||
}
|
||||
|
||||
checkdep(){
|
||||
hash $1 2>/dev/null || err "Install $1!"
|
||||
}
|
||||
|
||||
err(){
|
||||
echo "$(tput bold)$(tput setaf 1)==> $@ $(tput sgr0)" 1>&2
|
||||
exit 1
|
||||
command -v $1 >/dev/null 2>&1 || err "Install $1!"
|
||||
}
|
||||
|
||||
help_text(){
|
||||
cat << EOF
|
||||
printf "%s" "
|
||||
USAGE: $0 <arguments>
|
||||
|
||||
OPTIONS:
|
||||
@ -33,19 +43,25 @@ OPTIONS:
|
||||
-s, --list-installed List installed desktop entries
|
||||
-h, --help Displays this help message
|
||||
|
||||
EOF
|
||||
"
|
||||
}
|
||||
|
||||
list(){
|
||||
for i in $*/*; do
|
||||
printf "%s\n" "$i"
|
||||
done
|
||||
}
|
||||
|
||||
case $1 in
|
||||
-i|--install)
|
||||
checkdep update-desktop-database
|
||||
install_desktop ${@:2}
|
||||
install_desktop ${@#$1}
|
||||
update-desktop-database
|
||||
exit $?
|
||||
;;
|
||||
-r|--remove)
|
||||
checkdep update-desktop-database
|
||||
selected_entry=${@:2}
|
||||
selected_entry=${@#$1}
|
||||
for i in $selected_entry; do
|
||||
rm ~/.local/share/applications/archbox/$i
|
||||
done
|
||||
@ -57,12 +73,11 @@ case $1 in
|
||||
exit 0
|
||||
;;
|
||||
-l|--list)
|
||||
archbox ls -1 --color=none /usr/share/applications
|
||||
exit $?
|
||||
list "${CHROOT}"/usr/share/applications
|
||||
;;
|
||||
-s|--list-installed)
|
||||
ls -1 --color=none ~/.local/share/applications/archbox
|
||||
exit $?
|
||||
mkdir -p ~/.local/share/applications/archbox
|
||||
list ~/.local/share/applications/archbox
|
||||
;;
|
||||
*)
|
||||
checkdep zenity
|
||||
@ -74,23 +89,22 @@ case $1 in
|
||||
FALSE 'Install desktop entries' FALSE 'Remove desktop entries')"
|
||||
case $action in
|
||||
'Install desktop entries')
|
||||
list_desktop="$(archbox ls --color=none -1 /usr/share/applications)"
|
||||
zenity_entry="$(echo $list_desktop | sed 's/\ /\ FALSE\ /g')"
|
||||
zenity_entry="$(list "${CHROOT}"/usr/share/applications | sed 's/\ /\ FALSE\ /g')"
|
||||
selected_entry=$(zenity --list --checklist --height=500 --width=450 \
|
||||
--title="Archbox Desktop Manager" \
|
||||
--text "Select .desktop entries those you want to install" \
|
||||
--column "Select" --column "Applications" \
|
||||
FALSE $zenity_entry | sed 's/|/\ /g')
|
||||
[[ -z $selected_entry ]] && exit 1
|
||||
[ $selected_entry ] || exit 1
|
||||
install_desktop $selected_entry
|
||||
update-desktop-database
|
||||
exit 0
|
||||
;;
|
||||
'Remove desktop entries')
|
||||
list_desktop="$(ls --color=none -1 ~/.local/share/applications/archbox)"
|
||||
[[ -z $list_desktop ]] && zenity --info --title "Archbox Desktop Manager" \
|
||||
list_desktop="$(list ~/.local/share/applications/archbox)"
|
||||
[ $list_desktop = "*" ] && zenity --info --title "Archbox Desktop Manager" \
|
||||
--text "No .desktop files installed" --width=300 && exit 1
|
||||
zenity_entry="$(echo $list_desktop | sed 's/\ /\ FALSE\ /g')"
|
||||
zenity_entry="$(printf "%s" "$list_desktop" | sed 's/\ /\ FALSE\ /g')"
|
||||
selected_entry=$(zenity --list --checklist --height=500 --width=450 \
|
||||
--title="Archbox Desktop Manager" \
|
||||
--text "Select .desktop entries those you want to remove" \
|
127
src/archbox.bash
127
src/archbox.bash
@ -1,127 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source /etc/archbox.conf
|
||||
|
||||
checkdep(){
|
||||
hash $1 2>/dev/null || err "Install $1!"
|
||||
}
|
||||
|
||||
asroot(){
|
||||
[[ $EUID -ne 0 ]] && err "Run this as root!"
|
||||
}
|
||||
|
||||
storeenv() {
|
||||
echo "# This will be sourced when entering Archbox" > /tmp/archbox_env
|
||||
$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
|
||||
echo "DISPLAY=$DISPLAY" >> /tmp/archbox_env
|
||||
fi
|
||||
echo "DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS" >> /tmp/archbox_env
|
||||
echo "XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR" >> /tmp/archbox_env
|
||||
}
|
||||
|
||||
help_text(){
|
||||
cat << EOF
|
||||
USAGE: $0 <arguments>
|
||||
|
||||
OPTIONS:
|
||||
-c, --create URL Creates a chroot enviroment.
|
||||
-e, --enter Enters chroot enviroment.
|
||||
-h, --help Displays this help message.
|
||||
-m, --mount Mount Archbox directories.
|
||||
-u, --umount Unmount Archbox directories.
|
||||
--remount-run Remount /run in chroot enviroment.
|
||||
--mount-runtime-only Mount XDG_RUNTIME_DIR to chroot enviroment.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
fetch_tarball(){
|
||||
if hash aria2c 2>/dev/null; then
|
||||
aria2c -o archlinux.tar.gz $1
|
||||
elif hash wget 2>/dev/null; then
|
||||
wget -O archlinux.tar.gz $1
|
||||
elif hash curl 2>/dev/null; then
|
||||
curl -o archlinux.tar.gz $1
|
||||
else
|
||||
err "No supported downloader found."
|
||||
fi
|
||||
}
|
||||
|
||||
err(){
|
||||
echo "$(tput bold)$(tput setaf 1)==> $@ $(tput sgr0)" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
msg(){
|
||||
echo "$(tput bold)$(tput setaf 2)==> $@ $(tput sgr0)"
|
||||
}
|
||||
|
||||
case $1 in
|
||||
-c|--create)
|
||||
asroot
|
||||
[[ -z $2 ]] && err "Specify the link of Arch Linux bootstrap tarball!"
|
||||
msg "Creating chroot directory..."
|
||||
mkdir -p $INSTALL_PATH
|
||||
cd $INSTALL_PATH
|
||||
msg "Downloading Arch Linux tarball..."
|
||||
while true; do fetch_tarball $2 && break; done
|
||||
msg "Extracting the tarball..."
|
||||
checkdep tar
|
||||
tar xzf archlinux.tar.gz
|
||||
msg "Enabling internet connection in chroot enviroment..."
|
||||
cp /etc/resolv.conf $CHROOT/etc/resolv.conf
|
||||
msg "You will need to edit which mirror you want to use, uncomment needed mirrors and save it."
|
||||
echo "Editor of your choice:"
|
||||
read MIRROR_EDITOR
|
||||
$MIRROR_EDITOR $CHROOT/etc/pacman.d/mirrorlist || exit 1
|
||||
msg "Disabling Pacman's CheckSpace..."
|
||||
checkdep sed
|
||||
sed -i 's/CheckSpace/#CheckSpace/g' $CHROOT/etc/pacman.conf
|
||||
msg "Mounting necessary filesystems..."
|
||||
$PREFIX/share/archbox/bin/init start
|
||||
cp $PREFIX/share/archbox/chroot_setup.bash $CHROOT/chroot_setup
|
||||
echo $ARCHBOX_USER > /tmp/archbox_user
|
||||
chroot $CHROOT /bin/bash -c "/chroot_setup"
|
||||
exit $?
|
||||
;;
|
||||
-e|--enter)
|
||||
storeenv
|
||||
$PRIV $PREFIX/share/archbox/bin/uth copyresolv
|
||||
$PRIV $PREFIX/share/archbox/bin/enter
|
||||
exit $?
|
||||
;;
|
||||
-m|--mount)
|
||||
$PRIV $PREFIX/share/archbox/bin/init start
|
||||
;;
|
||||
-u|--umount)
|
||||
$PRIV $PREFIX/share/archbox/bin/init stop
|
||||
;;
|
||||
--remount-run)
|
||||
$PRIV $PREFIX/share/archbox/bin/uth remountrun
|
||||
exit $?
|
||||
;;
|
||||
--mount-runtime-only)
|
||||
$PRIV $PREFIX/share/archbox/bin/uth runtimeonly
|
||||
exit $?
|
||||
;;
|
||||
-h|--help)
|
||||
help_text
|
||||
exit 0
|
||||
;;
|
||||
"")
|
||||
help_text
|
||||
exit 1
|
||||
;;
|
||||
-*)
|
||||
err "Unknown option: $1"
|
||||
;;
|
||||
*)
|
||||
storeenv
|
||||
$PRIV $PREFIX/share/archbox/bin/uth copyresolv
|
||||
$PRIV $PREFIX/share/archbox/bin/exec $@
|
||||
exit $?
|
||||
;;
|
||||
esac
|
58
src/chroot_setup
Normal file
58
src/chroot_setup
Normal file
@ -0,0 +1,58 @@
|
||||
# Text colors/formatting
|
||||
red="\033[38;5;1"
|
||||
green="\033[38;5;2"
|
||||
bold="\033[1m"
|
||||
reset="\033[m"
|
||||
|
||||
err(){
|
||||
printf "${red}${bold}%s${reset}\n" "==> $*" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
msg(){
|
||||
printf "${green}${bold}%s${reset}\n" "==> $*" 1>&2
|
||||
}
|
||||
|
||||
PATH=/usr/bin
|
||||
|
||||
msg "Initializing pacman keyrings..."
|
||||
pacman-key --init
|
||||
pacman-key --populate archlinux
|
||||
msg "Installing essential packages..."
|
||||
pacman -Syu base base-devel nano --noconfirm
|
||||
printf "%s" "Do you want to use GUI apps? (y/n) "
|
||||
read INSTALL_GUI
|
||||
[ "$INSTALL_GUI" = "y" ] && pacman -Syu xorg pulseaudio --noconfirm
|
||||
msg "Installing archboxctl..."
|
||||
mkdir -p /usr/local/bin
|
||||
curl https://raw.githubusercontent.com/lemniskett/archboxctl/master/archboxctl.bash > /usr/local/bin/archboxctl
|
||||
chmod 755 /usr/local/bin/archboxctl
|
||||
msg "Setting up locale..."
|
||||
printf "%s" "Uncomment needed locale, enter to continue"
|
||||
read
|
||||
nano /etc/locale.gen
|
||||
locale-gen
|
||||
msg "Setting up timezone..."
|
||||
printf "%s\n" "Enter your timezone, for example : \"Asia/Jakarta\""
|
||||
while true; do
|
||||
read TIMEZONE \
|
||||
&& [ -e /usr/share/zoneinfo/$TIMEZONE ] \
|
||||
&& rm -f /etc/localtime \
|
||||
&& ln -s /usr/share/zoneinfo/$TIMEZONE /etc/localtime \
|
||||
&& break \
|
||||
|| printf "%s\n" "Timezone not found, enter it again."
|
||||
done
|
||||
msg "Creating user account..."
|
||||
read CHROOT_USER < /tmp/archbox_user
|
||||
useradd -m $CHROOT_USER
|
||||
usermod -aG wheel $CHROOT_USER
|
||||
printf "%s\n" "Enter root password"
|
||||
while true; do
|
||||
passwd && break
|
||||
done
|
||||
printf "%s\n" "Enter $CHROOT_USER password"
|
||||
while true; do
|
||||
passwd $CHROOT_USER && break
|
||||
done
|
||||
sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers
|
||||
printf "%s\n" "Don't forget to run \"archbox --mount\" in host on boot"
|
@ -1,49 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
err(){
|
||||
echo "$(tput bold)$(tput setaf 1)==> $@ $(tput sgr0)" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
msg(){
|
||||
echo "$(tput bold)$(tput setaf 2)==> $@ $(tput sgr0)"
|
||||
}
|
||||
|
||||
PATH=/usr/bin
|
||||
msg "Initializing pacman keyrings..."
|
||||
pacman-key --init
|
||||
pacman-key --populate archlinux
|
||||
msg "Installing essential packages..."
|
||||
pacman -Syu base base-devel xorg pulseaudio nano --noconfirm
|
||||
msg "Installing archboxctl..."
|
||||
mkdir -p /usr/local/bin
|
||||
curl https://raw.githubusercontent.com/lemniskett/archboxctl/master/archboxctl.bash > /usr/local/bin/archboxctl
|
||||
chmod 755 /usr/local/bin/archboxctl
|
||||
msg "Setting up locale..."
|
||||
echo "Uncomment needed locale, enter to continue"
|
||||
read
|
||||
nano /etc/locale.gen
|
||||
locale-gen
|
||||
msg "Setting up timezone..."
|
||||
echo "Enter your timezone, for example : \"Asia/Jakarta\""
|
||||
while true; do
|
||||
read TIMEZONE \
|
||||
&& [[ -e /usr/share/zoneinfo/$TIMEZONE ]] \
|
||||
&& ln -s /usr/share/zoneinfo/$TIMEZONE /etc/localtime \
|
||||
&& break \
|
||||
|| echo "Timezone not found, enter it again."
|
||||
done
|
||||
msg "Creating user account..."
|
||||
CHROOT_USER="$(cat /tmp/archbox_user)"
|
||||
useradd -m $CHROOT_USER
|
||||
gpasswd -a $CHROOT_USER wheel
|
||||
echo "Enter root password"
|
||||
while true; do
|
||||
passwd && break
|
||||
done
|
||||
echo "Enter $CHROOT_USER password"
|
||||
while true; do
|
||||
passwd $CHROOT_USER && break
|
||||
done
|
||||
sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers
|
||||
echo "Don't forget to run \"archbox --mount\" in host on boot"
|
10
src/enter
Normal file
10
src/enter
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /etc/archbox.conf >/dev/null 2>&1
|
||||
. /tmp/archbox_env >/dev/null 2>&1
|
||||
|
||||
REQ_ENV="DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS} XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} DISPLAY=${DISPLAY} WAYLAND_DISPLAY=${WAYLAND_DISPLAY}"
|
||||
|
||||
ENV="$REQ_ENV $ENV_VAR"
|
||||
COMMAND="$@"
|
||||
chroot $CHROOT /usr/bin/env $ENV /bin/su $ARCHBOX_USER
|
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source /etc/archbox.conf &>/dev/null
|
||||
source /tmp/archbox_env &>/dev/null
|
||||
|
||||
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 /sbin/env $ENV /bin/su $ARCHBOX_USER
|
10
src/exec
Normal file
10
src/exec
Normal file
@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /etc/archbox.conf >/dev/null 2>&1
|
||||
. /tmp/archbox_env >/dev/null 2>&1
|
||||
|
||||
REQ_ENV="DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS} XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR} DISPLAY=${DISPLAY} WAYLAND_DISPLAY=${WAYLAND_DISPLAY}"
|
||||
|
||||
ENV="$REQ_ENV $ENV_VAR"
|
||||
COMMAND="$@"
|
||||
chroot $CHROOT /bin/su -c "/usr/bin/env $ENV $COMMAND" $ARCHBOX_USER
|
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source /etc/archbox.conf &>/dev/null
|
||||
source /tmp/archbox_env &>/dev/null
|
||||
|
||||
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
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
|
||||
source /etc/archbox.conf
|
||||
. /etc/archbox.conf
|
||||
|
||||
startx
|
||||
$PRIV $PREFIX/share/archbox/bin/uth killxdg
|
||||
|
121
src/init
Normal file
121
src/init
Normal file
@ -0,0 +1,121 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /etc/archbox.conf
|
||||
|
||||
# Text colors/formatting
|
||||
red="\033[38;5;1"
|
||||
green="\033[38;5;2"
|
||||
bold="\033[1m"
|
||||
reset="\033[m"
|
||||
|
||||
err(){
|
||||
printf "${red}${bold}%s${reset}\n" "==> $*" 1>&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
msg(){
|
||||
printf "${green}${bold}%s${reset}\n" "==> $*" 1>&2
|
||||
}
|
||||
|
||||
rbind(){
|
||||
if [ "$(mount | grep "${CHROOT}"${1} >/dev/null 2>&1)" ]; then
|
||||
msg "${CHROOT}${1} already mounted."
|
||||
else
|
||||
mount -R $1 "${CHROOT}"${1}
|
||||
msg "${CHROOT}${1} mounted!"
|
||||
fi
|
||||
if [ "$2" = "make-rslave" ]; then
|
||||
mount --make-rslave ${CHROOT}${1}
|
||||
fi
|
||||
}
|
||||
|
||||
rbind_diff() {
|
||||
if [ "$(mount | grep "${CHROOT}"${2})" ]; then
|
||||
msg "$CHROOT$2 already mounted."
|
||||
else
|
||||
mount -R $1 "${CHROOT}"${2}
|
||||
msg "${CHROOT}${2} mounted!"
|
||||
fi
|
||||
}
|
||||
|
||||
bindproc() {
|
||||
if [ "$(mount | grep "${CHROOT}"/proc)" ]; then
|
||||
msg "${CHROOT}/proc already mounted."
|
||||
else
|
||||
mount -t proc /proc "${CHROOT}"/proc
|
||||
msg "${CHROOT}/proc mounted!"
|
||||
fi
|
||||
}
|
||||
|
||||
rmbind() {
|
||||
umount_args=-R
|
||||
[ "$LAZY_UMOUNT" = "yes" ] && umount_args=-Rl
|
||||
if [ "$(mount | grep "${CHROOT}"${1})" ]; then
|
||||
umount $umount_args "${CHROOT}"${1}
|
||||
msg "${CHROOT}${1} unmounted!"
|
||||
fi
|
||||
}
|
||||
|
||||
case $1 in
|
||||
start)
|
||||
bindproc
|
||||
rbind /tmp
|
||||
rbind /sys make-rslave
|
||||
rbind /dev make-rslave
|
||||
[ "$MOUNT_RUN" = "yes" ] && rbind /run
|
||||
if [ "$MOUNT_MOD" = "yes" ]; then
|
||||
rbind "$(readlink -f /lib/modules)"
|
||||
rbind /boot
|
||||
fi
|
||||
[ -d /var/lib/dbus ] && rbind /var/lib/dbus
|
||||
for i in $SHARED_FOLDER; do
|
||||
if [ $i = *:* ]; then
|
||||
source=$(printf "%s" "$i" | sed 's/:.*//')
|
||||
target=$(printf "%s" "$i" | sed 's/.*://')
|
||||
mkdir -p "${CHROOT}"${target}
|
||||
rbind_diff $source $target;
|
||||
else
|
||||
rbind $i;
|
||||
fi
|
||||
done
|
||||
msg "Starting services"
|
||||
for j in $SERVICES; do
|
||||
if [ $j = *:* ]; then
|
||||
delay=$(printf "%s" "$j" | sed 's/.*://')
|
||||
service=$(printf "%s" "$j" | sed 's/:.*//')
|
||||
chroot "$CHROOT" /bin/su -c "/usr/local/bin/archboxctl exec $service" > /dev/null 2>&1 &
|
||||
sleep $delay
|
||||
else
|
||||
chroot "$CHROOT" /bin/su -c "/usr/local/bin/archboxctl exec $j" > /dev/null 2>&1 &
|
||||
fi
|
||||
done
|
||||
if [ -e /etc/archbox.rc ]; then
|
||||
cp /etc/archbox.rc /tmp/archbox.rc
|
||||
chmod +x /tmp/archbox.rc
|
||||
chroot "$CHROOT" /bin/su -c '/tmp/archbox.rc' > /tmp/archbox.rc.log 2>&1
|
||||
rm /tmp/archbox.rc
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
stop)
|
||||
rmbind /proc
|
||||
rmbind /tmp
|
||||
rmbind /sys
|
||||
rmbind /dev
|
||||
[ $MOUNT_RUN = "yes" ] && rmbind /run
|
||||
if [ $MOUNT_MOD = "yes" ]; then
|
||||
rmbind $(readlink -f /lib/modules)
|
||||
rmbind /boot
|
||||
fi
|
||||
rmbind /var/lib/dbus
|
||||
for i in $SHARED_FOLDER; do
|
||||
if [ $i = *:* ]; then
|
||||
target=$(printf "%s" "$i" | sed 's/.*://')
|
||||
rmbind $target;
|
||||
else
|
||||
rmbind $i;
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
;;
|
||||
esac
|
@ -1,94 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source /etc/archbox.conf
|
||||
|
||||
msg(){
|
||||
echo "$(tput bold)$(tput setaf 2)==> $@ $(tput sgr0)"
|
||||
}
|
||||
|
||||
rbind() {
|
||||
[[ $(mount | grep $CHROOT$1) ]] && msg "$CHROOT$1 already mounted." \
|
||||
|| (mount -R $1 $CHROOT$1 && msg "$CHROOT$1 mounted!")
|
||||
[[ $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() {
|
||||
[[ $(mount | grep $CHROOT/proc) ]] && msg "$CHROOT/proc already mounted." \
|
||||
|| (mount -t proc /proc $CHROOT/proc && msg "$CHROOT/proc mounted!")
|
||||
}
|
||||
|
||||
rmbind() {
|
||||
umount_args=-R
|
||||
[[ $LAZY_UMOUNT = "yes" ]] && umount_args=-Rl
|
||||
[[ $(mount | grep $CHROOT$1) ]] && umount $umount_args $CHROOT$1 \
|
||||
&& msg "$CHROOT$1 unmounted!"
|
||||
}
|
||||
|
||||
case $1 in
|
||||
start)
|
||||
bindproc
|
||||
rbind /tmp
|
||||
rbind /sys make-rslave
|
||||
rbind /dev make-rslave
|
||||
[[ $MOUNT_RUN = "yes" ]] && rbind /run
|
||||
if [[ $MOUNT_MOD = "yes" ]]; then
|
||||
rbind $(readlink -f /lib/modules)
|
||||
rbind /boot
|
||||
fi
|
||||
[[ -d /var/lib/dbus ]] && rbind /var/lib/dbus
|
||||
for i in ${SHARED_FOLDER[@]}; do
|
||||
if [[ $i = *:* ]]; then
|
||||
source=$(echo $i | sed 's/:.*//')
|
||||
target=$(echo $i | sed 's/.*://')
|
||||
mkdir -p $CHROOT$target
|
||||
rbind_diff $source $target;
|
||||
else
|
||||
rbind $i;
|
||||
fi
|
||||
done
|
||||
msg "Starting services"
|
||||
for j in ${SERVICES[@]}; do
|
||||
if [[ $j = *:* ]]; then
|
||||
delay=$(echo $j | sed 's/.*://')
|
||||
service=$(echo $j | sed 's/:.*//')
|
||||
chroot $CHROOT /bin/su -c "/usr/local/bin/archboxctl exec $service" > /dev/null 2>&1 &
|
||||
sleep $delay
|
||||
else
|
||||
chroot $CHROOT /bin/su -c "/usr/local/bin/archboxctl exec $j" > /dev/null 2>&1 &
|
||||
fi
|
||||
done
|
||||
if [[ -e /etc/archbox.rc ]]; then
|
||||
cp /etc/archbox.rc /tmp/archbox.rc
|
||||
chmod +x /tmp/archbox.rc
|
||||
chroot $CHROOT /bin/su -c '/tmp/archbox.rc' > /tmp/archbox.rc.log 2>&1
|
||||
rm /tmp/archbox.rc
|
||||
fi
|
||||
exit 0
|
||||
;;
|
||||
stop)
|
||||
rmbind /proc
|
||||
rmbind /tmp
|
||||
rmbind /sys
|
||||
rmbind /dev
|
||||
[[ $MOUNT_RUN = "yes" ]] && rmbind /run
|
||||
if [[ $MOUNT_MOD = "yes" ]]; then
|
||||
rmbind $(readlink -f /lib/modules)
|
||||
rmbind /boot
|
||||
fi
|
||||
rmbind /var/lib/dbus
|
||||
for i in ${SHARED_FOLDER[@]}; do
|
||||
if [[ $i = *:* ]]; then
|
||||
target=$(echo $i | sed 's/.*://')
|
||||
rmbind $target;
|
||||
else
|
||||
rmbind $i;
|
||||
fi
|
||||
done
|
||||
exit 0
|
||||
;;
|
||||
esac
|
31
src/uth
Normal file
31
src/uth
Normal file
@ -0,0 +1,31 @@
|
||||
#!/bin/sh
|
||||
|
||||
. /etc/archbox.conf >/dev/null 2>&1
|
||||
. /tmp/archbox_env >/dev/null 2>&1
|
||||
|
||||
case $1 in
|
||||
copyresolv)
|
||||
cp /etc/resolv.conf "${CHROOT}"/etc/resolv.conf
|
||||
;;
|
||||
killxdg)
|
||||
umount -l "${CHROOT}"/run
|
||||
fuser -km $XDG_RUNTIME_DIR
|
||||
exit $?
|
||||
;;
|
||||
runtimeonly)
|
||||
mkdir -p "${CHROOT}"${XDG_RUNTIME_DIR}
|
||||
umount -Rl "${CHROOT}"${XDG_RUNTIME_DIR} 2>/dev/null
|
||||
mount | grep "${CHROOT}"${XDG_RUNTIME_DIR} || \
|
||||
mount --rbind $XDG_RUNTIME_DIR "${CHROOT}"${XDG_RUNTIME_DIR}
|
||||
exit $?
|
||||
;;
|
||||
remountrun)
|
||||
umount -l "${CHROOT}"/run 2>/dev/null
|
||||
mount --rbind /run "${CHROOT}"/run
|
||||
exit $?
|
||||
;;
|
||||
chownvar)
|
||||
chown $2 /tmp/archbox_env
|
||||
chmod 755 /tmp/archbox_env
|
||||
;;
|
||||
esac
|
31
src/uth.bash
31
src/uth.bash
@ -1,31 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source /etc/archbox.conf &>/dev/null
|
||||
source /tmp/archbox_env &>/dev/null
|
||||
|
||||
case $1 in
|
||||
copyresolv)
|
||||
cp /etc/resolv.conf $CHROOT/etc/resolv.conf
|
||||
;;
|
||||
killxdg)
|
||||
umount -l $CHROOT/run
|
||||
fuser -km $XDG_RUNTIME_DIR
|
||||
exit $?
|
||||
;;
|
||||
runtimeonly)
|
||||
mkdir -p $CHROOT$XDG_RUNTIME_DIR
|
||||
umount -Rl $CHROOT$XDG_RUNTIME_DIR 2>/dev/null
|
||||
mount | grep $CHROOT$XDG_RUNTIME_DIR || \
|
||||
mount --rbind $XDG_RUNTIME_DIR $CHROOT$XDG_RUNTIME_DIR
|
||||
exit $?
|
||||
;;
|
||||
remountrun)
|
||||
umount -l $CHROOT/run 2>/dev/null
|
||||
mount --rbind /run $CHROOT/run
|
||||
exit $?
|
||||
;;
|
||||
chownvar)
|
||||
chown $2 /tmp/archbox_env
|
||||
chmod 755 /tmp/archbox_env
|
||||
;;
|
||||
esac
|
Loading…
Reference in New Issue
Block a user