54 lines
2.6 KiB
Bash
54 lines
2.6 KiB
Bash
##Build of a release tag
|
|
RelVer=stable
|
|
##Build of a master branch, but config is vaidated
|
|
#RelVer=latest_Tested
|
|
##Build of a master branch
|
|
#RelVer=latest
|
|
|
|
#Go to script directory
|
|
cd "$(dirname "$0")"
|
|
#Setting up services needed for ShellHub
|
|
##PreReqs
|
|
apt-get -y install --no-install-recommends wget gnupg ca-certificates openssl uuid-runtime
|
|
###add openresty Repo
|
|
wget -O - https://openresty.org/package/pubkey.gpg | apt-key add -
|
|
echo "deb http://openresty.org/package/$(grep --color=never -Po "^ID=\K.*" "/etc/os-release") $(grep -oP '(?<=^VERSION_CODENAME=).+' /etc/os-release | tr -d '"') openresty" > /etc/apt/sources.list.d/openresty.list
|
|
###add mongoDB Repo
|
|
wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | apt-key add -
|
|
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/$(grep --color=never -Po "^ID=\K.*" "/etc/os-release") $(grep -oP '(?<=^VERSION_CODENAME=).+' /etc/os-release | tr -d '"')/mongodb-org/4.4 multiverse" > tee /etc/apt/sources.list.d/mongodb-org-4.4.list
|
|
##Installing packages
|
|
apt-get update
|
|
apt install -y openresty mongodb-org
|
|
##Configuring external services
|
|
opm get bungle/lua-resty-template
|
|
systemctl stop openresty mongod
|
|
systemctl enable openresty mongod
|
|
# config openresty(nginx)
|
|
rm /etc/openresty/nginx.conf
|
|
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/nginx.env -O /opt/ShellHub/nginx.env
|
|
mv config/openresty.conf /etc/openresty/nginx.conf
|
|
echo " 127.0.0.1 ui api ssh mongo" > /etc/hosts
|
|
systemctl start openresty mongod
|
|
|
|
##Setup Binaries
|
|
mkdir -p /opt/ShellHub/{ui,keys,tools}
|
|
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/.env -O /opt/ShellHub/shellhub.env
|
|
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/BinServices/ShellHubSSH-amd64 -O /opt/ShellHub/ShellHubSSH
|
|
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/BinServices/ShellHubAPI-amd64 -O /opt/ShellHub/ShellHubAPI
|
|
wget https://git.bprieshof.nl/ci/Releases/ShellHub/"$RelVer"/BinServices/webui.tar.gz -O /tmp/webui.tar.gz
|
|
chmod +x /opt/ShellHub/BinServices/ShellHubAPI
|
|
chmod +x /opt/ShellHub/BinServices/ShellHubSSH
|
|
tar -zxvf /tmp/webui.tar.gz -C /opt/ShellHub/ui
|
|
mv Tools /opt/ShellHub/tools
|
|
|
|
##Generating keys
|
|
openssl genrsa -out /opt/ShellHub/keys/api_private_key 2048
|
|
openssl rsa -in /opt/ShellHub/keys/api_private_key -out /opt/ShellHub/keys/api_public_key -pubout
|
|
openssl genrsa -out /opt/ShellHub/keys/ssh_private_key 2048
|
|
|
|
##Setup services
|
|
mv config/ServiceTemplates/ShellHubAPI.service /etc/systemd/system/ShellHubAPI.service
|
|
mv config/ServiceTemplates/ShellHubSSH.service /etc/systemd/system/ShellHubSSH.service
|
|
systemctl daemon-reload
|
|
systemctl enable --now ShellHubAPI ShellHubSSH
|