Files
shurikenpi.io/Scripts/installer.sh
2023-09-01 00:12:49 +02:00

82 lines
3.2 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

install_prerequisites(){
p "Installing pre-requisites..."
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://repo.charm.sh/apt/gpg.key | sudo gpg --batch --yes --dearmor -o /etc/apt/keyrings/charm.gpg
echo "deb [signed-by=/etc/apt/keyrings/charm.gpg] https://repo.charm.sh/apt/ * *" | sudo tee /etc/apt/sources.list.d/charm.list >/dev/null
spin_it "Update cache..." sudo apt update
spin_it "apt install gum                                                           \033[32m✓\033[0m" sudo apt-get install -y gum
spin_it "apt install git                                                           \033[32m✓\033[0m" sudo apt-get install -y git
spin_it "apt install tor                                                           \033[32m✓\033[0m" sudo apt-get install -y tor
spin_it "apt install curl                                                          \033[32m✓\033[0m" sudo apt-get install -y curl
spin_it "apt install screen                                                        \033[32m✓\033[0m" sudo apt-get install -y screen
}
go_to_install_directory(){
echo ""
cd $INSTALLATION_FOLDER
p "Install directory will be: $INSTALLATION_FOLDER"
if [ -d $INSTALLATION_FOLDER ]; then
echo ""
p_warn "An existing installation of ShurikenPi was detected!"
ask_yes_or_no "Would you like to re-install ShurikenPi and wipe the existing installation?"
local result=$?
if [ $result == 0 ]; then
rm -fr $INSTALLATION_FOLDER
else
p_err "Fatal: Aborting the installation script now"
exit 1
fi
fi
mkdir $INSTALLATION_FOLDER
cd $INSTALLATION_FOLDER
}
check_if_root(){
echo ""
p "Root user check..."
if [[ $EUID -ne 0 ]]; then
echo ""
echo -e " ShurikenPi called with non-root priviledeges \033[31m:(\033[0m"
echo -e " Elevated priviledeges are required to install and run ShurikenPi"
echo -e " Please check the installer for any concerns about this requirement"
echo -e " Make sure you downloaded this script from a trusted source"
echo ""
if sudo true; then
p "Correct password."
else
p_err "Wrong password. Exiting."
exit 1
fi
fi
p_ok "We are root :)"
}
check_if_upgrade(){
UPGRADABLE_COUNT=$(apt list --upgradable 2>$LOGS| grep -c ^)
if (( UPGRADABLE_COUNT > 0 )); then
p_warn "There are $UPGRADABLE_COUNT packages that can be upgraded."
p_warn "It is recommended to run 'sudo apt upgrade' afterwards."
else
p "All packages are up to date."
fi
}
clone_repository(){
spin_it "Downloading ShurikenPi, please wait..." git clone $GIT_URL
}
# Entry point
check_if_root
echo ""
p "The next steps might take some time, be patient"
install_prerequisites
check_if_upgrade
go_to_install_directory
clone_repository
cd $GIT_FOLDER/Scripts/
./create_configuration.sh