mirror of
https://github.com/aljazceru/shurikenpi.io.git
synced 2025-12-17 06:04:23 +01:00
update install script, move more constant to global vars
This commit is contained in:
6
Scripts/create_configuration.sh
Executable file
6
Scripts/create_configuration.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
source ./global.sh
|
||||
source ./utils.sh
|
||||
|
||||
p "create new config"
|
||||
24
Scripts/global.sh
Normal file
24
Scripts/global.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
|
||||
VERBOSE=0
|
||||
while getopts ":v" option; do
|
||||
case "${option}" in
|
||||
v)
|
||||
VERBOSE=1
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [-v]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
LOGS=/dev/null
|
||||
INSTALLATION_FOLDER="$HOME/shurikenpi"
|
||||
GIT_FOLDER="$HOME/shurikenpi/shurikenpi.io"
|
||||
TMP_DIRECTORY=/tmp/shuriken_io
|
||||
|
||||
rm -fr $TMP_DIRECTORY 2>&1
|
||||
mkdir $TMP_DIRECTORY 2>&1
|
||||
|
||||
GIT_URL=https://github.com/Urban-Hacker/shurikenpi.io/
|
||||
@@ -2,31 +2,30 @@
|
||||
install_prerequisites(){
|
||||
p "Installing pre-requisites..."
|
||||
spin_it "goland-go (1/5)" sudo apt-get install -y golang-go
|
||||
spin_it "gum (2/5)" go install github.com/charmbracelet/gum@latest && sleep 0.1
|
||||
spin_it "git (3/5)" sudo apt-get install -y git && sleep 0.1
|
||||
spin_it "tor (4/5)" sudo apt-get install -y tor && sleep 0.1
|
||||
spin_it "curl (5/5)" sudo apt-get install -y curl && sleep 0.1
|
||||
spin_it "gum (2/5)" go install github.com/charmbracelet/gum@latest
|
||||
spin_it "git (3/5)" sudo apt-get install -y git
|
||||
spin_it "tor (4/5)" sudo apt-get install -y tor
|
||||
spin_it "curl (5/5)" sudo apt-get install -y curl
|
||||
}
|
||||
|
||||
go_to_install_directory(){
|
||||
echo ""
|
||||
cd ~
|
||||
local install_folder="$(pwd)/shurikenpi"
|
||||
p "Install directory will be: $install_folder"
|
||||
if [ -d $install_folder ]; then
|
||||
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 $install_folder
|
||||
rm -fr $INSTALLATION_FOLDER
|
||||
else
|
||||
p_err "Fatal: Aborting the installation script now"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
mkdir $install_folder
|
||||
cd $install_folder
|
||||
mkdir $INSTALLATION_FOLDER
|
||||
cd $INSTALLATION_FOLDER
|
||||
}
|
||||
|
||||
check_if_root(){
|
||||
@@ -51,12 +50,12 @@ check_if_root(){
|
||||
}
|
||||
|
||||
do_update() {
|
||||
spin_it "Updating, please wait..." sudo apt update
|
||||
spin_it "Updating, please wait..." sudo apt-get update
|
||||
}
|
||||
|
||||
check_if_upgrade(){
|
||||
|
||||
UPGRADABLE_COUNT=$(apt list --upgradable 2>/dev/null | grep -c ^)
|
||||
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' after ShurikenPi installation"
|
||||
@@ -66,32 +65,9 @@ check_if_upgrade(){
|
||||
}
|
||||
|
||||
clone_repository(){
|
||||
spin_it "Downloading ShurikenPi, please wait..." git clone https://github.com/Urban-Hacker/shurikenpi.io/
|
||||
spin_it "Downloading ShurikenPi, please wait..." git clone $GIT_URL
|
||||
}
|
||||
|
||||
create_tmp_log_directory() {
|
||||
rm -fr /tmp/shuriken 2>&1
|
||||
mkdir /tmp/shuriken 2>&1
|
||||
}
|
||||
|
||||
|
||||
VERBOSE=0
|
||||
|
||||
# check if -v is passed as argument
|
||||
while getopts ":v" option; do
|
||||
case "${option}" in
|
||||
v)
|
||||
VERBOSE=1
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [-v]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
create_tmp_log_directory
|
||||
|
||||
# Entry point
|
||||
check_if_root
|
||||
do_update
|
||||
@@ -99,6 +75,6 @@ install_prerequisites
|
||||
check_if_upgrade
|
||||
go_to_install_directory
|
||||
clone_repository
|
||||
cd ./shuriken/Tools/
|
||||
chmod +x dependencies.sh
|
||||
./dependencies.sh
|
||||
|
||||
cd $GIT_FOLDER/Scripts/
|
||||
./create_configuration.sh
|
||||
@@ -50,7 +50,7 @@ spin_it(){
|
||||
shift
|
||||
local command=$@
|
||||
local hash=$(echo -n "$command" | md5sum | awk '{print $1}')
|
||||
local logfile="/tmp/shuriken/$hash.txt"
|
||||
local logfile="$TMP_DIRECTORY/$hash.txt"
|
||||
"$@" > $logfile 2>&1 &
|
||||
chars=(" ⠋ " " ⠙ " " ⠹ " " ⠸ " " ⠼ " " ⠴ " " ⠦ " " ⠧ " " ⠇ " " ⠏ ")
|
||||
pid=$!
|
||||
|
||||
24
build.sh
24
build.sh
@@ -1,12 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
build_installer(){
|
||||
# Header
|
||||
echo "#!/bin/bash" > install.sh
|
||||
echo "# File generated automatically by build.sh. Do not modify" >> install.sh
|
||||
echo "# DO NOT MODIFY" >> install.sh
|
||||
echo "" >> install.sh
|
||||
|
||||
cat Scripts/global.sh >> install.sh
|
||||
echo -e "\n\n" >> install.sh
|
||||
cat Scripts/utils.sh >> install.sh
|
||||
echo -e "\n\n" >> install.sh
|
||||
cat Scripts/installer.sh >> install.sh
|
||||
chmod +x install.sh
|
||||
}
|
||||
|
||||
echo -e "Script to build Shuriken"
|
||||
echo "#!/bin/bash" > install.sh
|
||||
echo "# File generated automatically by build.sh. Do not modify" >> install.sh
|
||||
echo "# DO NOT MODIFY" >> install.sh
|
||||
echo "" >> install.sh
|
||||
cat Scripts/utils.sh >> install.sh
|
||||
echo -e "\n\n" >> install.sh
|
||||
cat Scripts/installer.sh >> install.sh
|
||||
chmod +x install.sh
|
||||
build_installer
|
||||
echo "Finished"
|
||||
107
install.sh
107
install.sh
@@ -2,6 +2,32 @@
|
||||
# File generated automatically by build.sh. Do not modify
|
||||
# DO NOT MODIFY
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
VERBOSE=0
|
||||
while getopts ":v" option; do
|
||||
case "${option}" in
|
||||
v)
|
||||
VERBOSE=1
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 [-v]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
LOGS=/dev/null
|
||||
INSTALLATION_FOLDER="$HOME/shurikenpi"
|
||||
GIT_FOLDER="$HOME/shurikenpi/shurikenpi.io"
|
||||
TMP_DIRECTORY=/tmp/shuriken_io
|
||||
|
||||
rm -fr $TMP_DIRECTORY 2>&1
|
||||
mkdir $TMP_DIRECTORY 2>&1
|
||||
|
||||
GIT_URL=https://github.com/Urban-Hacker/shurikenpi.io/
|
||||
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
p() {
|
||||
@@ -54,7 +80,7 @@ spin_it(){
|
||||
shift
|
||||
local command=$@
|
||||
local hash=$(echo -n "$command" | md5sum | awk '{print $1}')
|
||||
local logfile="/tmp/shuriken/$hash.txt"
|
||||
local logfile="$TMP_DIRECTORY/$hash.txt"
|
||||
"$@" > $logfile 2>&1 &
|
||||
chars=(" ⠋ " " ⠙ " " ⠹ " " ⠸ " " ⠼ " " ⠴ " " ⠦ " " ⠧ " " ⠇ " " ⠏ ")
|
||||
pid=$!
|
||||
@@ -84,3 +110,82 @@ spin_it(){
|
||||
|
||||
|
||||
|
||||
install_prerequisites(){
|
||||
p "Installing pre-requisites..."
|
||||
spin_it "goland-go (1/5)" sudo apt-get install -y golang-go
|
||||
spin_it "gum (2/5)" go install github.com/charmbracelet/gum@latest
|
||||
spin_it "git (3/5)" sudo apt-get install -y git
|
||||
spin_it "tor (4/5)" sudo apt-get install -y tor
|
||||
spin_it "curl (5/5)" sudo apt-get install -y curl
|
||||
}
|
||||
|
||||
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 :)"
|
||||
}
|
||||
|
||||
do_update() {
|
||||
spin_it "Updating, please wait..." sudo apt-get update
|
||||
}
|
||||
|
||||
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' after ShurikenPi installation"
|
||||
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
|
||||
do_update
|
||||
install_prerequisites
|
||||
check_if_upgrade
|
||||
go_to_install_directory
|
||||
clone_repository
|
||||
|
||||
cd $GIT_FOLDER/Scripts/
|
||||
./create_configuration.sh
|
||||
Reference in New Issue
Block a user