From c6116bac2155e16416fbe6806c1a336fface316a Mon Sep 17 00:00:00 2001 From: exu Date: Thu, 4 Jan 2024 10:08:23 +0100 Subject: [PATCH] Move user, root and management parts into separate scripts --- arch-config/scripts/arch-config.sh | 505 ++--------------------------- arch-config/scripts/config-root.sh | 143 ++++++++ arch-config/scripts/config-user.sh | 332 +++++++++++++++++++ 3 files changed, 496 insertions(+), 484 deletions(-) create mode 100644 arch-config/scripts/config-root.sh create mode 100644 arch-config/scripts/config-user.sh diff --git a/arch-config/scripts/arch-config.sh b/arch-config/scripts/arch-config.sh index d782fd21..51e7183e 100755 --- a/arch-config/scripts/arch-config.sh +++ b/arch-config/scripts/arch-config.sh @@ -18,32 +18,6 @@ fi # keep sudo active in background func_dont_timeout & -cat <&1 >/dev/tty) - clear - for choice in $choices; do - case $choice in - 1) - echo "nyarch" >"$HOME/.seltheme" - ;; - 2) - echo "space-pink" >"$HOME/.seltheme" - ;; - esac - done -} - -echo cat </dev/null +git clone -b rewrite-in-python https://gitea.exu.li/realstickman/configs.git "$tempdir" &>/dev/null # check if the install scripts are the same # NOTE Arguments get passed automatically now @@ -77,468 +42,40 @@ if ! cmp --silent "$scriptloc" "$HOME/scripts/arch-config.sh"; then cp "$tempdir/arch-config/scripts/arch-config.sh" "$HOME/scripts/" && bash ~/scripts/arch-config.sh "$@" fi -# if no seltheme file exists, ask to select a theme -if [[ ! -f "$HOME/.seltheme" ]]; then - func_seltheme -fi +# FIXME compare correct script +# check config-user script +#if ! cmp --silent "$scriptloc" "$HOME/scripts/config-user.sh"; then +# echo Updated config-user script. +# cp "$tempdir/arch-config/scripts/config-user.sh" "$HOME/scripts/" +#fi -#################### -#### Arguments #### -#################### +# FIXME compare correct script +# check config-root script +#if ! cmp --silent "$scriptloc" "$HOME/scripts/config-root.sh"; then +# echo Updated config-root script. +# cp "$tempdir/arch-config/scripts/config-root.sh" "$HOME/scripts/" +#fi -copy_firefox=0 - -# handle arguments -if [[ "$#" -eq 1 ]]; then - # -t/--theme to change theme - if [[ "$1" == "-t" || "$1" == "--theme" ]]; then - func_seltheme - elif [[ "$1" == "-f" || "$1" == "--firefox" ]]; then - copy_firefox=1 - elif [[ "$1" == "-h" || "$1" == "--help" ]]; then - echo "-h, --help Show help menu" - echo "-t, --theme Show theme selection screen" - echo "-f, --firefox Update firefox config" - exit 0 - fi -elif [[ "$#" -gt 1 ]]; then - echo "Too many arguments" - exit 1 -fi - -echo cat </tmp/i3config.ini - cp /tmp/i3config.ini ~/.config/polybar/i3config.ini - # xresources dpi - xftdpi="$(cat ~/configs/arch-config/per-device/lupusregina/xresources-dpi-override)" - awk -v xftdpi="$xftdpi" '/!per-device dpi insert/{print;print xftdpi;next}1' ~/.Xdefaults >/tmp/.Xdefaults - cp /tmp/.Xdefaults ~/.Xdefaults - sudo cp ~/configs/arch-config/per-device/lupusregina/10-monitor.conf /etc/X11/xorg.conf.d/ - sudo cp ~/configs/arch-config/per-device/lupusregina/20-amdgpu.conf /etc/X11/xorg.conf.d/ -fi - -echo -cat </dev/null -cp "$tempdir/bash-cat-with-cat/cat.sh" "$HOME/scripts/pieces/cat.sh" -#rm -rf ./bash-cat-with-cat - -echo -cat </dev/null -fi - -# set group for libvirt -if [[ $(pacman -Q | grep libvirt) ]]; then - echo "Setting group for libvirt" - sudo gpasswd -a "$USER" libvirt 1>/dev/null -fi - -# set group for wireshark (only if installed) -if [[ $(pacman -Q | grep wireshark-qt) ]]; then - echo "Setting up group for wireshark" - sudo groupadd -f wireshark - sudo gpasswd -a "$USER" wireshark 1>/dev/null -fi - -# add group for corectrl -if [[ $(pacman -Q | grep corectrl) ]]; then - echo "Setting up group for corectrl" - sudo groupadd -f corectrl - sudo gpasswd -a "$USER" corectrl 1>/dev/null -fi - -# group for controlling backlight -echo "Setting group for backlight" -sudo groupadd -f video -sudo gpasswd -a "$USER" video 1>/dev/null - -# group for monitoring wireguard -echo "Setting group for wireguard" -sudo groupadd -f wireguard -sudo gpasswd -a "$USER" wireguard 1>/dev/null - -echo -cat </dev/null; then -# i3-msg restart 1>/dev/null -#fi - -if [ $XDG_SESSION_DESKTOP == "sway" ]; then - swaymsg reload - echo "Reloaded sway" -fi +# call root script +bash "$tempdir/arch-config/scripts/config-root.sh" & +pids="$pids $!" # wait for all background jobs to finish wait $pids && echo "Finished background jobs" -echo cat </dev/null +fi + +# set group for libvirt +if [[ $(pacman -Q | grep libvirt) ]]; then + echo "Setting group for libvirt" + sudo gpasswd -a "$USER" libvirt 1>/dev/null +fi + +# set group for wireshark (only if installed) +if [[ $(pacman -Q | grep wireshark-qt) ]]; then + echo "Setting up group for wireshark" + sudo groupadd -f wireshark + sudo gpasswd -a "$USER" wireshark 1>/dev/null +fi + +# add group for corectrl +if [[ $(pacman -Q | grep corectrl) ]]; then + echo "Setting up group for corectrl" + sudo groupadd -f corectrl + sudo gpasswd -a "$USER" corectrl 1>/dev/null +fi + +# group for controlling backlight +echo "Setting group for backlight" +sudo groupadd -f video +sudo gpasswd -a "$USER" video 1>/dev/null + +# group for monitoring wireguard +echo "Setting group for wireguard" +sudo groupadd -f wireguard +sudo gpasswd -a "$USER" wireguard 1>/dev/null + +cat <&1 >/dev/tty) + clear + for choice in $choices; do + case $choice in + 1) + echo "nyarch" >"$HOME/.seltheme" + ;; + 2) + echo "space-pink" >"$HOME/.seltheme" + ;; + esac + done +} + +# if no seltheme file exists, ask to select a theme +if [[ ! -f "$HOME/.seltheme" ]]; then + func_seltheme +fi + +#################### +#### Arguments #### +#################### + +copy_firefox=0 + +# handle arguments +if [[ "$#" -eq 1 ]]; then + # -t/--theme to change theme + if [[ "$1" == "-t" || "$1" == "--theme" ]]; then + func_seltheme + elif [[ "$1" == "-f" || "$1" == "--firefox" ]]; then + copy_firefox=1 +elif [[ "$#" -gt 1 ]]; then + echo "Too many arguments" + exit 1 +fi + +cat </tmp/i3config.ini + cp /tmp/i3config.ini ~/.config/polybar/i3config.ini + # xresources dpi + xftdpi="$(cat ~/configs/arch-config/per-device/lupusregina/xresources-dpi-override)" + awk -v xftdpi="$xftdpi" '/!per-device dpi insert/{print;print xftdpi;next}1' ~/.Xdefaults >/tmp/.Xdefaults + cp /tmp/.Xdefaults ~/.Xdefaults +fi + +cat </dev/null +cp "$tempdir/bash-cat-with-cat/cat.sh" "$HOME/scripts/pieces/cat.sh" + +cat <