59 lines
1.7 KiB
Bash
Executable File
59 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
URI="https://git.scypher.org/taicrafter/helperScripts/raw/branch/main"
|
|
function _promptBool(){
|
|
while true; do
|
|
read -r -p "$1 [y/n]: " res < /dev/tty
|
|
if [[ "$res" == "Y" || "$res" == "y" ]]; then
|
|
return 0;
|
|
elif [[ "$res" == "N" || "$res" == "n" ]]; then
|
|
return 1;
|
|
fi
|
|
done
|
|
}
|
|
function detectOS(){
|
|
if [ -f /etc/debian_version ]; then
|
|
OS_TYPE="deb"
|
|
elif [ -f /etc/arch-release ]; then
|
|
OS_TYPE="arch"
|
|
else
|
|
echo "Unable to detect OS..."
|
|
if _promptBool "Manually set to Debian?"; then
|
|
OS_TYPE="deb"
|
|
elif _promptBool "Manually set to Arch?"; then
|
|
OS_TYPE="arch"
|
|
else
|
|
echo "Failed OS-Detection";
|
|
exit 1
|
|
fi
|
|
fi
|
|
echo "Detected OS-Type: $OS_TYPE"
|
|
export OS_TYPE
|
|
}
|
|
function AppInstaller(){
|
|
#Get App-List for OS
|
|
if _promptBool "Use Source: $URI?"; then
|
|
echo "Downloading App List..."
|
|
APPS=$(curl -fsSL "$URI/$OS_TYPE/apps.txt");
|
|
COUNT=$(echo "$APPS" | wc -l);
|
|
#TODO Handle 404 or 0 Installers
|
|
echo "Found $COUNT Installers..."
|
|
TMP_FILE=$(mktemp)
|
|
while IFS= read -r APPNAME; do
|
|
#Handle Install
|
|
if _promptBool "Install $APPNAME?"; then
|
|
SOURCE="$URI/$OS_TYPE/installers/$APPNAME.sh"
|
|
echo "Downloading Installer: $SOURCE"
|
|
curl -fsSL "$SOURCE" -o "$TMP_FILE"
|
|
bash "$TMP_FILE" < /dev/tty
|
|
echo "Finished $APPNAME Installer!"
|
|
fi
|
|
done <<< "$APPS"
|
|
else
|
|
echo "Aborted App-Installer!"
|
|
fi
|
|
}
|
|
#Main
|
|
detectOS
|
|
if _promptBool "Run App-Installer?"; then
|
|
AppInstaller
|
|
fi |