Compare commits
12 Commits
POSIX-rewr
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
1f30ea56bf | ||
|
7748b7d7c5 | ||
|
c2a1bdbdd7 | ||
|
1db04e6fb4 | ||
|
0b29ff372d | ||
|
ca6b078ee4 | ||
|
6ab4402160 | ||
|
a6293e6098 | ||
|
286542f481 | ||
|
2e0b458f11 | ||
|
5d9ed8cdff | ||
|
995947f185 |
@ -25,7 +25,7 @@ Add `archbox -m` to `~/.bashrc` in host.
|
|||||||
Install [`cros-adapta-gtk-theme`](https://aur.archlinux.org/packages/cros-adapta-gtk-theme/), `ttf-roboto`, and `papirus-icon-theme` and use it with :
|
Install [`cros-adapta-gtk-theme`](https://aur.archlinux.org/packages/cros-adapta-gtk-theme/), `ttf-roboto`, and `papirus-icon-theme` and use it with :
|
||||||
```sh
|
```sh
|
||||||
gsettings set org.gnome.desktop.interface gtk-theme "cros-adapta"
|
gsettings set org.gnome.desktop.interface gtk-theme "cros-adapta"
|
||||||
gsettings set org.gnome.desktop.interface icon-theme "Papirus"
|
gsettings set org.gnome.desktop.interface icon-theme "Papirus-Light"
|
||||||
gsettings set org.gnome.desktop.interface font-name "Roboto 10"
|
gsettings set org.gnome.desktop.interface font-name "Roboto 10"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ SERVICES="php-fpm:3 nginx"
|
|||||||
This will add 3 seconds delay after executing php-fpm.
|
This will add 3 seconds delay after executing php-fpm.
|
||||||
##### Start services immediately
|
##### Start services immediately
|
||||||
To start services immediately, in Archbox, do :
|
To start services immediately, in Archbox, do :
|
||||||
```
|
```8
|
||||||
sudo archboxctl exec <Service name>
|
sudo archboxctl exec <Service name>
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -133,11 +133,11 @@ ENV_VAR="QT_QPA_PLATFORMTHEME=qt5ct GTK_CSD=0 LD_PRELOAD=/var/home/lemniskett/gi
|
|||||||
#### Adding more shared directories
|
#### Adding more shared directories
|
||||||
Edit SHARED_FOLDER in ```/etc/archbox.conf```. For example:
|
Edit SHARED_FOLDER in ```/etc/archbox.conf```. For example:
|
||||||
```
|
```
|
||||||
SHARED_FOLDER=( /home /var/www )
|
SHARED_FOLDER="/home /var/www"
|
||||||
```
|
```
|
||||||
To mount to different directory, use ```:``` separator :
|
To mount to different directory, use ```:``` separator :
|
||||||
```
|
```
|
||||||
SHARED_FOLDER=( /home /var/www:/host_webroot )
|
SHARED_FOLDER="/home /var/www:/host_webroot"
|
||||||
```
|
```
|
||||||
### Known issues
|
### Known issues
|
||||||
#### NixOS-specific issues
|
#### NixOS-specific issues
|
||||||
|
@ -34,7 +34,7 @@ ENV_VAR="${ENV_VAR:-}"
|
|||||||
SERVICES="${SERVICES:-}"
|
SERVICES="${SERVICES:-}"
|
||||||
|
|
||||||
# Share other host directories into Archbox, absolute path needed.
|
# Share other host directories into Archbox, absolute path needed.
|
||||||
SHARED_FOLDER="${SHARED_FOLDERS:-/home}"
|
SHARED_FOLDER="${SHARED_FOLDER:-/home}"
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
. /etc/archbox.conf
|
. /etc/archbox.conf
|
||||||
|
|
||||||
# Text colors/formatting
|
# Text colors/formatting
|
||||||
red="\033[38;5;1"
|
red='\033[1;31m'
|
||||||
green="\033[38;5;2"
|
green='\033[1;32m'
|
||||||
bold="\033[1m"
|
bold='\033[1m'
|
||||||
reset="\033[m"
|
reset='\033[m'
|
||||||
|
|
||||||
err(){
|
err(){
|
||||||
printf "${red}${bold}%s${reset}\n" "==> $*" 1>&2
|
printf "${red}${bold}%s${reset}\n" "==> $*" 1>&2
|
||||||
|
@ -2,11 +2,108 @@
|
|||||||
|
|
||||||
. /etc/archbox.conf >/dev/null 2>&1
|
. /etc/archbox.conf >/dev/null 2>&1
|
||||||
|
|
||||||
|
multiselect() {
|
||||||
|
echo "\nSelect with <space>, confirm with <enter>"
|
||||||
|
|
||||||
|
# little helpers for terminal print control and key input
|
||||||
|
ESC=$( printf "\033")
|
||||||
|
cursor_blink_on() { printf "$ESC[?25h"; }
|
||||||
|
cursor_blink_off() { printf "$ESC[?25l"; }
|
||||||
|
cursor_to() { printf "$ESC[$1;${2:-1}H"; }
|
||||||
|
print_inactive() { printf "$2 $1 "; }
|
||||||
|
print_active() { printf "$2 $ESC[7m $1 $ESC[27m"; }
|
||||||
|
get_cursor_row() { IFS=';' read -sdR -p $'\E[6n' ROW COL; echo ${ROW#*[}; }
|
||||||
|
key_input() {
|
||||||
|
local key
|
||||||
|
IFS= read -rsn1 key 2>/dev/null >&2
|
||||||
|
if [[ $key = "" ]]; then echo enter; fi;
|
||||||
|
if [[ $key = $'\x20' ]]; then echo space; fi;
|
||||||
|
if [[ $key = $'\x1b' ]]; then
|
||||||
|
read -rsn2 key
|
||||||
|
if [[ $key = [A ]]; then echo up; fi;
|
||||||
|
if [[ $key = [B ]]; then echo down; fi;
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
toggle_option() {
|
||||||
|
local arr_name=$1
|
||||||
|
eval "local arr=(\"\${${arr_name}[@]}\")"
|
||||||
|
local option=$2
|
||||||
|
if [[ ${arr[option]} == true ]]; then
|
||||||
|
arr[option]=
|
||||||
|
else
|
||||||
|
arr[option]=true
|
||||||
|
fi
|
||||||
|
eval $arr_name='("${arr[@]}")'
|
||||||
|
}
|
||||||
|
|
||||||
|
local retval=$1
|
||||||
|
local options
|
||||||
|
local defaults
|
||||||
|
|
||||||
|
IFS=';' read -r -a options <<< "$2"
|
||||||
|
if [[ -z $3 ]]; then
|
||||||
|
defaults=()
|
||||||
|
else
|
||||||
|
IFS=';' read -r -a defaults <<< "$3"
|
||||||
|
fi
|
||||||
|
local selected=()
|
||||||
|
|
||||||
|
for ((i=0; i<${#options[@]}; i++)); do
|
||||||
|
selected+=("${defaults[i]}")
|
||||||
|
printf "\n"
|
||||||
|
done
|
||||||
|
|
||||||
|
# determine current screen position for overwriting the options
|
||||||
|
local lastrow=`get_cursor_row`
|
||||||
|
local startrow=$(($lastrow - ${#options[@]}))
|
||||||
|
|
||||||
|
# ensure cursor and input echoing back on upon a ctrl+c during read -s
|
||||||
|
trap "cursor_blink_on; stty echo; printf '\n'; exit" 2
|
||||||
|
cursor_blink_off
|
||||||
|
|
||||||
|
local active=0
|
||||||
|
while true; do
|
||||||
|
# print options by overwriting the last lines
|
||||||
|
local idx=0
|
||||||
|
for option in "${options[@]}"; do
|
||||||
|
local prefix="[ ]"
|
||||||
|
if [[ ${selected[idx]} == true ]]; then
|
||||||
|
prefix="[x]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
cursor_to $(($startrow + $idx))
|
||||||
|
if [ $idx -eq $active ]; then
|
||||||
|
print_active "$option" "$prefix"
|
||||||
|
else
|
||||||
|
print_inactive "$option" "$prefix"
|
||||||
|
fi
|
||||||
|
((idx++))
|
||||||
|
done
|
||||||
|
|
||||||
|
# user key control
|
||||||
|
case `key_input` in
|
||||||
|
space) toggle_option selected $active;;
|
||||||
|
enter) break;;
|
||||||
|
up) ((active--));
|
||||||
|
if [ $active -lt 0 ]; then active=$((${#options[@]} - 1)); fi;;
|
||||||
|
down) ((active++));
|
||||||
|
if [ $active -ge ${#options[@]} ]; then active=0; fi;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
# cursor position back to normal
|
||||||
|
cursor_to $lastrow
|
||||||
|
printf "\n"
|
||||||
|
cursor_blink_on
|
||||||
|
|
||||||
|
eval $retval='("${selected[@]}")'
|
||||||
|
}
|
||||||
|
|
||||||
# Text colors/formatting
|
# Text colors/formatting
|
||||||
red="\033[38;5;1"
|
red='\033[1;31m'
|
||||||
green="\033[38;5;2"
|
green='\033[1;32m'
|
||||||
bold="\033[1m"
|
bold='\033[1m'
|
||||||
reset="\033[m"
|
reset='\033[m'
|
||||||
|
|
||||||
err(){
|
err(){
|
||||||
printf "${red}${bold}%s${reset}\n" "==> $*" 1>&2
|
printf "${red}${bold}%s${reset}\n" "==> $*" 1>&2
|
||||||
@ -19,13 +116,12 @@ msg(){
|
|||||||
|
|
||||||
install_desktop(){
|
install_desktop(){
|
||||||
mkdir -p ~/.local/share/applications/archbox
|
mkdir -p ~/.local/share/applications/archbox
|
||||||
for i in $@; do
|
i="$(echo $1 | sed 's|.*/||')"
|
||||||
archbox readlink /usr/share/applications/$i >/dev/null 2>&1 \
|
archbox readlink /usr/share/applications/$i >/dev/null 2>&1 \
|
||||||
&& cp "${CHROOT}"/$(archbox readlink /usr/share/applications/$i) ~/.local/share/applications/archbox \
|
&& cp "${CHROOT}"/$(archbox readlink /usr/share/applications/$i) $HOME/.local/share/applications/archbox/$i \
|
||||||
|| cp "${CHROOT}"/usr/share/applications/$i "~/.local/share/applications/archbox"
|
|| cp "${CHROOT}"/usr/share/applications/$i "$HOME/.local/share/applications/archbox/$i"
|
||||||
sed -i 's/Exec=/Exec=archbox\ /g' ~/.local/share/applications/archbox/$i
|
sed -i 's/Exec=/Exec=archbox\ /g' ~/.local/share/applications/archbox/$i
|
||||||
sed -i '/TryExec=/d' ~/.local/share/applications/archbox/$i
|
sed -i '/TryExec=/d' ~/.local/share/applications/archbox/$i
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
checkdep(){
|
checkdep(){
|
||||||
@ -35,14 +131,13 @@ checkdep(){
|
|||||||
help_text(){
|
help_text(){
|
||||||
printf "%s" "
|
printf "%s" "
|
||||||
USAGE: $0 <arguments>
|
USAGE: $0 <arguments>
|
||||||
|
|
||||||
OPTIONS:
|
OPTIONS:
|
||||||
|
<no option> Choice to install or uninstall desktop entries
|
||||||
-i, --install FILE Installs desktop entries in /usr/share/applications
|
-i, --install FILE Installs desktop entries in /usr/share/applications
|
||||||
-r, --remove FILE Removes desktop entries in ~/.local/share/applications/archbox
|
-r, --remove FILE Removes desktop entries in ~/.local/share/applications/archbox
|
||||||
-l, --list List available desktop entries
|
-l, --list List available desktop entries
|
||||||
-s, --list-installed List installed desktop entries
|
-s, --list-installed List installed desktop entries
|
||||||
-h, --help Displays this help message
|
-h, --help Displays this help message
|
||||||
|
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,44 +175,41 @@ case $1 in
|
|||||||
list ~/.local/share/applications/archbox
|
list ~/.local/share/applications/archbox
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
checkdep zenity
|
|
||||||
checkdep sed
|
checkdep sed
|
||||||
checkdep update-desktop-database
|
checkdep tr
|
||||||
action="$(zenity --list --radiolist --title 'Archbox Desktop Manager' \
|
checkdep update-desktop-databse
|
||||||
--height=200 --width=450 --column 'Select' --column 'Action' \
|
printf "What do you want to do?\nPress I to install desktop entries.\nPress R to remove desktop entries. (I/r)"
|
||||||
--text 'What do you want to do?' \
|
read -rn 1
|
||||||
FALSE 'Install desktop entries' FALSE 'Remove desktop entries')"
|
case $REPLY in
|
||||||
case $action in
|
[rR])
|
||||||
'Install desktop entries')
|
LIST="$(list "${HOME}"/.local/share/applications/archbox)"
|
||||||
zenity_entry="$(list "${CHROOT}"/usr/share/applications | sed 's/\ /\ FALSE\ /g')"
|
printf "$LIST" >/tmp/archboxlist
|
||||||
selected_entry=$(zenity --list --checklist --height=500 --width=450 \
|
LIST2="$(cat /tmp/archboxlist | sed -z 's/\n/;/g;s/,$/\n/')"
|
||||||
--title="Archbox Desktop Manager" \
|
multiselect RESULT "${LIST2}"
|
||||||
--text "Select .desktop entries those you want to install" \
|
for i in "${!RESULT[@]}"; do
|
||||||
--column "Select" --column "Applications" \
|
if [ "${RESULT[$i]}" == "true" ]; then
|
||||||
FALSE $zenity_entry | sed 's/|/\ /g')
|
rm ${HOME}/.local/share/applications/archbox/"$(sed "$((i+1))q;d" /tmp/archboxlist | sed 's|.*/||')"
|
||||||
[ $selected_entry ] || exit 1
|
fi
|
||||||
install_desktop $selected_entry
|
|
||||||
update-desktop-database
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
'Remove desktop entries')
|
|
||||||
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="$(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" \
|
|
||||||
--column "Select" --column "Applications" \
|
|
||||||
FALSE $zenity_entry | sed 's/|/\ /g')
|
|
||||||
[[ -z $selected_entry ]] && exit 1
|
|
||||||
for i in $selected_entry; do
|
|
||||||
rm ~/.local/share/applications/archbox/$i
|
|
||||||
done
|
done
|
||||||
update-desktop-database
|
update-desktop-database
|
||||||
|
rm /tmp/archboxlist
|
||||||
exit $?
|
exit $?
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
LIST="$(list "${CHROOT}"/usr/share/applications)"
|
||||||
|
printf "$LIST" >/tmp/archboxlist
|
||||||
|
LIST2="$(cat /tmp/archboxlist | sed -z 's/\n/;/g;s/,$/\n/')"
|
||||||
|
multiselect RESULT "${LIST2}"
|
||||||
|
for i in "${!RESULT[@]}"; do
|
||||||
|
if [ "${RESULT[$i]}" == "true" ]; then
|
||||||
|
install_desktop "$(sed "$((i+1))q;d" /tmp/archboxlist)"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
update-desktop-database
|
||||||
|
rm /tmp/archboxlist
|
||||||
|
exit 0
|
||||||
|
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
exit 1
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
# Text colors/formatting
|
# Text colors/formatting
|
||||||
red="\033[38;5;1"
|
red='\033[1;31m'
|
||||||
green="\033[38;5;2"
|
green='\033[1;32m'
|
||||||
bold="\033[1m"
|
bold='\033[1m'
|
||||||
reset="\033[m"
|
reset='\033[m'
|
||||||
|
|
||||||
err(){
|
err(){
|
||||||
printf "${red}${bold}%s${reset}\n" "==> $*" 1>&2
|
printf "${red}${bold}%s${reset}\n" "==> $*" 1>&2
|
||||||
@ -54,5 +54,6 @@ printf "%s\n" "Enter $CHROOT_USER password"
|
|||||||
while true; do
|
while true; do
|
||||||
passwd $CHROOT_USER && break
|
passwd $CHROOT_USER && break
|
||||||
done
|
done
|
||||||
sed -i 's/# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/g' /etc/sudoers
|
|
||||||
|
sed -i 's/# %wheel ALL=(ALL:ALL) NOPASSWD: ALL/%wheel ALL=(ALL:ALL) NOPASSWD: ALL/g' sudoers
|
||||||
printf "%s\n" "Don't forget to run \"archbox --mount\" in host on boot"
|
printf "%s\n" "Don't forget to run \"archbox --mount\" in host on boot"
|
||||||
|
28
src/init
28
src/init
@ -3,10 +3,10 @@
|
|||||||
. /etc/archbox.conf
|
. /etc/archbox.conf
|
||||||
|
|
||||||
# Text colors/formatting
|
# Text colors/formatting
|
||||||
red="\033[38;5;1"
|
red='\033[1;31m'
|
||||||
green="\033[38;5;2"
|
green='\033[1;32m'
|
||||||
bold="\033[1m"
|
bold='\033[1m'
|
||||||
reset="\033[m"
|
reset='\033[m'
|
||||||
|
|
||||||
err(){
|
err(){
|
||||||
printf "${red}${bold}%s${reset}\n" "==> $*" 1>&2
|
printf "${red}${bold}%s${reset}\n" "==> $*" 1>&2
|
||||||
@ -17,11 +17,16 @@ msg(){
|
|||||||
printf "${green}${bold}%s${reset}\n" "==> $*" 1>&2
|
printf "${green}${bold}%s${reset}\n" "==> $*" 1>&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkmount(){
|
||||||
|
mount | grep "${CHROOT}${1}" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
rbind(){
|
rbind(){
|
||||||
if [ "$(mount | grep "${CHROOT}"${1} >/dev/null 2>&1)" ]; then
|
if checkmount $1; then
|
||||||
msg "${CHROOT}${1} already mounted."
|
msg "${CHROOT}${1} already mounted."
|
||||||
else
|
else
|
||||||
mount -R $1 "${CHROOT}"${1}
|
mkdir -p "${CHROOT}${1}"
|
||||||
|
mount -R $1 "${CHROOT}${1}"
|
||||||
msg "${CHROOT}${1} mounted!"
|
msg "${CHROOT}${1} mounted!"
|
||||||
fi
|
fi
|
||||||
if [ "$2" = "make-rslave" ]; then
|
if [ "$2" = "make-rslave" ]; then
|
||||||
@ -30,16 +35,17 @@ rbind(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
rbind_diff() {
|
rbind_diff() {
|
||||||
if [ "$(mount | grep "${CHROOT}"${2})" ]; then
|
if checkmount $2; then
|
||||||
msg "$CHROOT$2 already mounted."
|
msg "${CHROOT}${2} already mounted."
|
||||||
else
|
else
|
||||||
mount -R $1 "${CHROOT}"${2}
|
mkdir -p "${CHROOT}${1}"
|
||||||
|
mount -R $1 "${CHROOT}${2}"
|
||||||
msg "${CHROOT}${2} mounted!"
|
msg "${CHROOT}${2} mounted!"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
bindproc() {
|
bindproc() {
|
||||||
if [ "$(mount | grep "${CHROOT}"/proc)" ]; then
|
if checkmount /proc; then
|
||||||
msg "${CHROOT}/proc already mounted."
|
msg "${CHROOT}/proc already mounted."
|
||||||
else
|
else
|
||||||
mount -t proc /proc "${CHROOT}"/proc
|
mount -t proc /proc "${CHROOT}"/proc
|
||||||
@ -50,7 +56,7 @@ bindproc() {
|
|||||||
rmbind() {
|
rmbind() {
|
||||||
umount_args=-R
|
umount_args=-R
|
||||||
[ "$LAZY_UMOUNT" = "yes" ] && umount_args=-Rl
|
[ "$LAZY_UMOUNT" = "yes" ] && umount_args=-Rl
|
||||||
if [ "$(mount | grep "${CHROOT}"${1})" ]; then
|
if checkmount $1; then
|
||||||
umount $umount_args "${CHROOT}"${1}
|
umount $umount_args "${CHROOT}"${1}
|
||||||
msg "${CHROOT}${1} unmounted!"
|
msg "${CHROOT}${1} unmounted!"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user