diff --git a/updatescripts.sh b/updatescripts.sh new file mode 100644 index 0000000..eb2170b --- /dev/null +++ b/updatescripts.sh @@ -0,0 +1,36 @@ +#!/bin/bash +NF="\e[0m" +FB="\e[1m" +CG="\e[38;5;40m" +CR="\e[38;5;9m" +CY="\033[38;5;226m" +USER=$(getent passwd 1000 | cut -d: -f1) +PC=$(uname -n | awk '{print $1}') + +if [ "$UID" -ne 0 ]; then + echo -e "${CR}This script must be run as root.${NF}" + exit 1 +fi + +guardband() { +if [ $? -ne 0 ]; then +echo -e "${CY}Cleaning up temp directory...${NF}" +rm -rf /opt/franscorack/scripts/ +sleep 2 +echo -e "${CR}Script Exited with an Error.${NF}" +exit 1 +fi +} + +verifygit(){ +SRV="https://git.franscorack.com" +echo -e "${C_YELLOW}Verifying Server availability...${NO_FORMAT}" +if ! wget --spider "$SRV" 2>/dev/null; then + echo -e "${C_RED}Error: Cannot reach Server - ${F_BOLD}Are you connected on the Internet ? / Is the Server down ?${NO_FORMAT}" + echo -e "${C_RED}Scripts can only be updated if $SRV is reachable. Script Halted. ${NO_FORMAT}" + return 1 + else + echo -e "${C_GREEN}Server available - ${F_BOLD}Proceeding...${NO_FORMAT}" + sleep 2 +fi +}