autoinstallers/alma-x64/code-server
2022-07-06 12:06:45 -05:00

55 lines
1.8 KiB
Bash

#!/bin/bash
echo "Welcome to the Discord-Linux CodeServer Automated installer"
echo "This installer will automatically select a port on your container."
echo "I will let you know how to access your installation when installation is complete."
echo ""
echo "downloading the Notification Bot"
wget -q -O /usr/bin/notif https://ssh.surf/alma-x64/notif && chmod +x /usr/bin/notif
echo "Done"
notif "Welcome to the Code-Server Automated installer for Discord-Linux ARM, We are preparing your installation..."
notif "Installing Code-Server 4.5.0 using RPM"
wget https://github.com/coder/code-server/releases/download/v4.5.0/code-server-4.5.0-amd64.rpm
rpm -U code-server-4.5.0-amd64.rpm
rm -f code-server-4.5.0-amd64.rpm
notif "Downloading our configurations"
wget -q -O /var/tools/startCodeServer.json https://ssh.surf/install/code-server/startCodeServer.json
wget -q -O /var/tools/startCodeServer.sh https://ssh.surf/install/code-server/startCodeServer.sh
chmod +x /var/tools/startCodeServer.sh
mkdir -vp /root/.config/code-server/
wget -q -O /root/.config/code-server/config.yaml https://ssh.surf/install/code-server/config.yaml
PASS=$(openssl rand -hex 12)
sed -i "s/replaceme/${PASS}/g" ~/.config/code-server/config.yaml
sed -i "s/#code-server/cd \/var\/tools \&\& pm2 start startCodeServer.json \&\& relayPort 8080/g" /start.sh
sed -i "s/127.0.0.1:8080/0.0.0.0:8080/g" /root/.config/code-server/config.yaml
pm2 start /var/tools/startCodeServer.json
sleep 5
notif "Sleeping for 5 seconds to allow for code-server to start...."
relayPort 8080
sleep 5
notif "Sleeping to allow the relay to start..."
url=$(grep -hPo "(?<=listening ).*" /root/.pm2/logs/Relay-8080-out.log | head -n 1 | sed 's/$/.virt.fun/')
notif "The installation has completed. You may access your install at: https://$url with the password $PASS"