Browse Source

Merge branch 'autoscript-20210115' of tmp/arozos into master

LGTM
TC 3 years ago
parent
commit
001f047bfa

+ 64 - 0
documents/headless setup files/install_latest_hkwtc.sh

@@ -0,0 +1,64 @@
+#!/bin/bash
+
+# Automatic install script for ArozOS - by tobychui
+# For internal use only, All Right Reserved
+echo "[ArozOS Installer]"
+echo "Updating apt"
+sudo apt upgrade -y
+sudo apt-get update -y
+sudo apt-get install ffmpeg samba git net-tools -y
+
+echo "Cloning ArozOS from source"
+git clone https://git.hkwtc.org/TC/arozos.git
+
+echo "Installing Golang"
+arch=$(uname -i)
+gover="1.17.6"
+if [[ $arch == x86_64* ]]; then
+    echo "Selecting x64 Architecture"
+    wget https://golang.org/dl/go$gover.linux-amd64.tar.gz
+elif  [[ $arch == arm* ]]; then
+    echo "Selecting ARM Architecture"
+    wget https://golang.org/dl/go$gover.linux-arm64.tar.gz
+elif [[ $arch == "unknown" ]]; then
+    echo "Unknown CPU arch. Please enter CPU architecture manually (arm/arm64/amd64)"
+    read -p "Architecture: " arch
+    if [ "$arch" = "arm" ]; then
+        echo "Installing arm version of go"
+        wget https://golang.org/dl/go$gover.linux-armv6l.tar.gz
+    fi
+    if [ "$arch" = "arm64" ]; then
+	echo "Installing arm64 version of go"
+	wget https://golang.org/dl/go$gover.linux-arm64.tar.gz
+    fi
+
+    if [ "$arch" = "amd64" ]; then
+	echo "Installing amd64 version of go"
+	wget https://golang.org/dl/go$gover.linux-amd64.tar.gz
+    fi
+fi
+sudo tar -C /usr/local -xzf go*
+echo 'export PATH=$PATH:/usr/local/go/bin' >> ~/.bashrc
+PATH=$PATH:/usr/local/go/bin
+
+echo "Building ArozOS"
+cd arozos
+sudo chmod 777 -R ./
+cd src
+go mod tidy
+go build
+
+echo "Setting up system services"
+sudo systemctl enable systemd-networkd.service systemd-networkd-wait-online.service
+cd /etc/systemd/system/
+
+printf "[Unit]\nDescription=ArozOS Cloud Service\nAfter=systemd-networkd-wait-online.service\nWants=systemd-networkd-wait-online.service\n\n[Service]\nType=simple\nExecStartPre=/bin/sleep 10\nWorkingDirectory=/home/pi/arozos/src/\nExecStart=/bin/bash /home/pi/arozos/src/start.sh\n\nRestart=always\nRestartSec=10\n\n[Install]\nWantedBy=multi-user.target" | sudo tee -a ./arozos.service
+
+echo "Registering systemctl service"
+sudo systemctl start arozos.service
+
+echo "Starting arozos"
+sudo systemctl enable arozos.service
+
+thisip=$(hostname -I | cut -d' ' -f1)
+echo "Installation completed. Visit ArozOS web UI with http://$thisip:8080"

+ 98 - 0
documents/headless setup files/install_latest_jenkins.sh

@@ -0,0 +1,98 @@
+#!/bin/bash
+
+# Automatic install script for ArozOS - by tobychui
+# For internal use only, All Right Reserved
+# This code compitiable with Amazon Linux 2 and Debian
+
+server="https://jenkins.alanyeung.co"
+echo "[ArozOS Installer]"
+echo "Jenkins Server: "
+echo $server
+echo "You are downloading: "
+curl -slient $server/job/arozos/lastBuild/api/json | grep -iEo '"fullDisplayName":"([^"]*)"' | awk -F ":" '{gsub(/"/, "", $2);print $2}'
+echo "With build timestamp: "
+time=$(curl -slient $server/job/arozos/lastBuild/api/json | grep -iEo '"timestamp":([0-9]*)'  | awk -F ":" '{gsub(/"/, "", $2);print $2}')
+echo $time
+timeHuman=$(date -d "@$(($time/1000))")
+echo "$timeHuman"
+sleep 3
+
+echo "Installing necessary packages..."
+
+if [ -f /etc/os-release ]; then
+    # freedesktop.org and systemd
+    . /etc/os-release
+    OS=$NAME
+elif type lsb_release >/dev/null 2>&1; then
+    # linuxbase.org
+    OS=$(lsb_release -si)
+elif [ -f /etc/lsb-release ]; then
+    # For some versions of Debian/Ubuntu without lsb_release command
+    . /etc/lsb-release
+    OS=$DISTRIB_ID
+elif [ -f /etc/debian_version ]; then
+    # Older Debian/Ubuntu/etc.
+    OS=Debian
+else
+    # Fall back to uname, e.g. "Linux <version>", also works for BSD, etc.
+    OS=$(uname -s)
+fi
+
+if [[ $OS == "Amazon Linux" ]]; then
+    echo "YUM Package Manager"
+    sudo yum update
+    sudo yum install epel-release
+    sudo yum localinstall --nogpgcheck https://download1.rpmfusion.org/free/el/rpmfusion-free-release-7.noarch.rpm
+    sudo yum install ffmpeg ffmpeg-devel samba git net-tools unzip -y
+else
+#elif [[ $OS == "Debian" ]]; then
+    echo "APT Package Manager"
+    sudo apt upgrade -y
+    sudo apt-get update -y
+    sudo apt-get install ffmpeg samba git net-tools unzip -y
+fi
+    
+echo "Installing Web components from Jenkins..."
+wget $server/job/arozos/lastSuccessfulBuild/artifact/arozos_web_components.zip
+unzip arozos_web_components.zip
+
+echo "Creating ArozOS structure..."
+cd arozos
+
+echo "Installing Core binary from Jenkins...."
+arch=$(uname -i)
+sysname=$(uname | tr '[:upper:]' '[:lower:]')
+echo "Your system is $sysname"
+if [[ $arch == "x86_64" ]]; then
+    arch="i386"
+fi
+if [[ $arch == "unknown" ]]; then
+    echo "Unknown CPU arch. Please enter CPU architecture manually (arm/arm64/amd64/i386/armv7/misple)"
+    read -p "Architecture: " arch
+    wget $server/job/arozos/lastSuccessfulBuild/artifact/arozos_$sysname\_$arch
+else
+    wget $server/job/arozos/lastSuccessfulBuild/artifact/arozos_$sysname\_$arch
+fi
+
+mv arozos_$sysname\_$arch arozos
+sudo chmod 777 -R ./
+
+printf "#%c/bin/bash\nsudo ./arozos -port 8080 -tls=true -tls_port 8443" ! | sudo tee -a ./start.sh
+
+echo "Setting up system services"
+sudo systemctl enable systemd-networkd.service systemd-networkd-wait-online.service
+cd /etc/systemd/system/
+
+username=$USER
+printf "[Unit]\nDescription=ArozOS Cloud Service\nAfter=systemd-networkd-wait-online.service\nWants=systemd-networkd-wait-online.service\n\n[Service]\nType=simple\nExecStartPre=/bin/sleep 10\nWorkingDirectory=/home/$username/arozos/\nExecStart=/bin/bash /home/$username/arozos/start.sh\n\nRestart=always\nRestartSec=10\n\n[Install]\nWantedBy=multi-user.target" | sudo tee -a ./arozos.service
+
+echo "Reloading daemon"
+sudo systemctl daemon-reload
+echo "Registering systemctl service"
+sudo systemctl start arozos.service
+
+echo "Starting arozos"
+sudo systemctl enable arozos.service
+
+thisip=$(hostname -I | cut -d' ' -f1)
+echo "Installation completed. Visit ArozOS web UI with http://$thisip:8080"

+ 2 - 2
documents/headless setup files/arozos_installer.sh → documents/headless setup files/install_release_github.sh

@@ -1,4 +1,4 @@
-#/bin/bash
+#!/bin/bash
 
 # Automatic install script for ArozOS - by tobychui
 # For internal use only, All Right Reserved
@@ -60,5 +60,5 @@ sudo systemctl start arozos.service
 echo "Starting arozos"
 sudo systemctl enable arozos.service
 
-thisip=$(hostname -I)
+thisip=$(hostname -I | cut -d' ' -f1)
 echo "Installation completed. Visit ArozOS web UI with http://$thisip:8080"