autoinstallers/alma/code-server
2022-07-04 20:23:32 -05:00

54 lines
1.7 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/debian/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-arm64.rpm
rpm -U code-server-4.5.0-arm64.rpm
rm -f code-server-4.5.0-arm64.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
notif "Requesting port from API Server"
hostname=$(hostname)
echo "Grabbing a port from your container from our API"
port=$(curl -s https://findport.ssh.surf/?id=$hostname)
sed -i "s/127.0.0.1:8080/0.0.0.0:${port}/g" /root/.config/code-server/config.yaml
pm2 start /var/tools/startCodeServer.json
notif "The installation has completed. You may access your install at: http://ssh.surf:$port with the password $PASS"