Update init.sh
This commit is contained in:
parent
d593b6122b
commit
7c2d4db10f
139
init.sh
139
init.sh
@ -1,33 +1,116 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get update
|
set -e
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get upgrade -y
|
|
||||||
DEBIAN_FRONTEND=noninteractive apt-get install build-essential curl make git wget qrencode python-3 python3-pip -y
|
|
||||||
|
|
||||||
mkdir -p /opt/go
|
colorized_echo() {
|
||||||
cd /opt/go
|
local color=$1
|
||||||
wget https://go.dev/dl/go1.22.0.linux-amd64.tar.gz
|
local text=$2
|
||||||
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.0.linux-amd64.tar.gz
|
|
||||||
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
|
case $color in
|
||||||
sleep 2
|
"red")
|
||||||
source /etc/profile
|
printf "\e[91m${text}\e[0m\n";;
|
||||||
# if the go version does not show, then update the session
|
"green")
|
||||||
|
printf "\e[92m${text}\e[0m\n";;
|
||||||
|
"yellow")
|
||||||
|
printf "\e[93m${text}\e[0m\n";;
|
||||||
|
"blue")
|
||||||
|
printf "\e[94m${text}\e[0m\n";;
|
||||||
|
"magenta")
|
||||||
|
printf "\e[95m${text}\e[0m\n";;
|
||||||
|
"cyan")
|
||||||
|
printf "\e[96m${text}\e[0m\n";;
|
||||||
|
*)
|
||||||
|
echo "${text}"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
#Install amnezia-go
|
installing() {
|
||||||
git clone https://github.com/amnezia-vpn/amneziawg-go.git /opt/amnezia-go
|
check_running_as_root
|
||||||
cd /opt/amnezia-go
|
detect_os
|
||||||
sleep 1
|
detect_and_update_package_manager
|
||||||
source /etc/profile
|
install_package
|
||||||
sleep 1
|
install_go
|
||||||
make
|
install_awg
|
||||||
#copy to amneziawg-go
|
install_awg_tools
|
||||||
cp /opt/amnezia-go/amneziawg-go /usr/bin/amneziawg-go
|
}
|
||||||
|
check_running_as_root() {
|
||||||
|
if [ "$(id -u)" != "0" ]; then
|
||||||
|
colorized_echo red "This command must be run as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
detect_os() {
|
||||||
|
# Detect the operating system
|
||||||
|
if [ -f /etc/lsb-release ]; then
|
||||||
|
OS=$(lsb_release -si)
|
||||||
|
elif [ -f /etc/os-release ]; then
|
||||||
|
OS=$(awk -F= '/^NAME/{print $2}' /etc/os-release | tr -d '"')
|
||||||
|
elif [ -f /etc/redhat-release ]; then
|
||||||
|
OS=$(cat /etc/redhat-release | awk '{print $1}')
|
||||||
|
elif [ -f /etc/arch-release ]; then
|
||||||
|
OS="Arch"
|
||||||
|
else
|
||||||
|
colorized_echo red "Unsupported operating system"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
detect_and_update_package_manager() {
|
||||||
|
colorized_echo blue "Updating package manager"
|
||||||
|
if [[ "$OS" == "Ubuntu"* ]] || [[ "$OS" == "Debian"* ]]; then
|
||||||
|
PKG_MANAGER="apt-get"
|
||||||
|
$PKG_MANAGER update
|
||||||
|
else
|
||||||
|
colorized_echo red "Unsupported operating system"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
install_package () {
|
||||||
|
if [ -z $PKG_MANAGER ]; then
|
||||||
|
detect_and_update_package_manager
|
||||||
|
fi
|
||||||
|
colorized_echo blue "Installing Package"
|
||||||
|
if [[ "$OS" == "Ubuntu"* ]] || [[ "$OS" == "Debian"* ]]; then
|
||||||
|
$PKG_MANAGER -y install build-essential \
|
||||||
|
curl \
|
||||||
|
make \
|
||||||
|
git \
|
||||||
|
wget \
|
||||||
|
qrencode \
|
||||||
|
python3 \
|
||||||
|
python3-pip
|
||||||
|
else
|
||||||
|
colorized_echo red "Unsupported operating system"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
#Install amnezia-tools
|
|
||||||
git clone https://github.com/amnezia-vpn/amneziawg-tools.git /opt/amnezia-tools
|
|
||||||
cd /opt/amnezia-tools/src
|
|
||||||
make
|
|
||||||
make install
|
|
||||||
|
|
||||||
#Install PyQt6
|
install_go() {
|
||||||
pip3 install PyQt6
|
mkdir -p /opt/go
|
||||||
|
cd /opt/go
|
||||||
|
curl -O https://go.dev/dl/go1.22.0.linux-amd64.tar.gz
|
||||||
|
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.22.0.linux-amd64.tar.gz
|
||||||
|
echo "export PATH=$PATH:/usr/local/go/bin" >> /etc/profile
|
||||||
|
source ~/.profile
|
||||||
|
if go version >/dev/null 2>&1; then
|
||||||
|
echo "Golang installed"
|
||||||
|
else
|
||||||
|
colorized_echo red "golang not found"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
install_awg() {
|
||||||
|
|
||||||
|
}
|
||||||
|
install_awg_tools() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
case "$1" in
|
||||||
|
install)
|
||||||
|
shift; installing "$@";;
|
||||||
|
*)
|
||||||
|
usage;;
|
||||||
|
esac
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user