2023-11-18 13:27:52 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
# function to keep sudo from timing out
|
|
|
|
function func_dont_timeout {
|
|
|
|
while true; do
|
|
|
|
sudo -v
|
|
|
|
sleep 60
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# check if user is root
|
|
|
|
if [ "$EUID" -ne 0 ]; then
|
|
|
|
sudo -v
|
|
|
|
fi
|
|
|
|
|
|
|
|
# keep sudo active in background
|
|
|
|
func_dont_timeout &
|
|
|
|
|
2024-01-04 16:34:23 +01:00
|
|
|
cat <<EOF
|
|
|
|
############################################################
|
|
|
|
###################### INSTALL CONFIG ######################
|
|
|
|
############################################################
|
|
|
|
EOF
|
|
|
|
|
2023-11-18 13:27:52 +01:00
|
|
|
cat <<EOF
|
|
|
|
########################################
|
|
|
|
################ Setup ################
|
|
|
|
########################################
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# get script directory
|
|
|
|
scriptloc="$BASH_SOURCE"
|
2023-12-08 20:11:16 +01:00
|
|
|
|
|
|
|
# Use temporary directory for download
|
|
|
|
tempdir="$(mktemp -d)"
|
2023-11-18 13:27:52 +01:00
|
|
|
|
|
|
|
echo "Checking config file"
|
|
|
|
|
|
|
|
#clone this repo
|
2024-01-04 10:08:23 +01:00
|
|
|
git clone -b rewrite-in-python https://gitea.exu.li/realstickman/configs.git "$tempdir" &>/dev/null
|
2023-11-18 13:27:52 +01:00
|
|
|
|
|
|
|
# check if the install scripts are the same
|
|
|
|
# NOTE Arguments get passed automatically now
|
2023-12-08 20:11:16 +01:00
|
|
|
if ! cmp --silent "$scriptloc" "$HOME/scripts/arch-config.sh"; then
|
2023-11-18 13:27:52 +01:00
|
|
|
echo Removed old config file and launched new one.
|
2023-12-08 20:11:16 +01:00
|
|
|
cp "$tempdir/arch-config/scripts/arch-config.sh" "$HOME/scripts/" && bash ~/scripts/arch-config.sh "$@"
|
2023-11-18 13:27:52 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
########################################
|
2024-01-04 10:08:23 +01:00
|
|
|
############## Start Setup #############
|
2023-11-18 13:27:52 +01:00
|
|
|
########################################
|
|
|
|
EOF
|
|
|
|
|
2024-01-04 10:08:23 +01:00
|
|
|
# Collect all PIDs of background processes that should be waited for
|
|
|
|
pids=""
|
2023-11-18 13:27:52 +01:00
|
|
|
|
2024-01-04 10:08:23 +01:00
|
|
|
# call user script
|
2024-01-04 16:34:23 +01:00
|
|
|
python "$tempdir/arch-config/scripts/config-user.py" &
|
2024-01-04 10:08:23 +01:00
|
|
|
pids="$pids $!"
|
2023-11-18 13:27:52 +01:00
|
|
|
|
2024-01-04 10:08:23 +01:00
|
|
|
# call root script
|
|
|
|
bash "$tempdir/arch-config/scripts/config-root.sh" &
|
|
|
|
pids="$pids $!"
|
2023-11-18 13:27:52 +01:00
|
|
|
|
|
|
|
# wait for all background jobs to finish
|
|
|
|
wait $pids && echo "Finished background jobs"
|
|
|
|
|
|
|
|
cat <<EOF
|
|
|
|
########################################
|
|
|
|
############### Finished ###############
|
|
|
|
########################################
|
|
|
|
EOF
|
|
|
|
|
|
|
|
#output
|
|
|
|
echo -e "\033[38;2;20;200;20mFinished updating everything!\033[0m"
|
|
|
|
echo Launching new shell!
|
|
|
|
|
|
|
|
# reminder for enable additional gpu features for corectrl with amd gpus
|
|
|
|
if [[ $(pacman -Q corectrl) ]]; then
|
|
|
|
echo -e "\033[38;2;200;20;20mRemember to set \"amdgpu.ppfeaturemask=0xffffffff\" in the kernel!!\033[0m"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# reload user default shell
|
|
|
|
exec "$(getent passwd $LOGNAME | cut -d: -f7)"
|
|
|
|
|
|
|
|
# exit successfully
|
|
|
|
exit 0
|