#!/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 ", 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"