Last active
November 19, 2021 15:01
-
-
Save ckxng/38346ccee6212905fb8884a7ea951a7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# password for vscode | |
PASS=XXX | |
# hostname at duckdns.org | |
HOST=XXX | |
# duckdns.org token | |
DUCK=XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX | |
# sysadmin email | |
EMAIL=XXX@XXX.XXX | |
# clear oracle provided local firewall | |
sudo iptables -F | |
sudo iptables-save | sudo dd of=/etc/iptables/rules.v4 | |
sudo ip6tables -F | |
sudo ip6tables-save | sudo dd of=/etc/iptables/rules.v6 | |
curl -fsSL https://code-server.dev/install.sh | sudo su -c sh ubuntu | |
sudo systemctl enable --now code-server@ubuntu | |
echo "#\!/bin/sh | |
echo url='https://www.duckdns.org/update?domains=$HOST&token=$DUCK&ip=' | curl -k -K - | |
" | sudo dd of=/etc/cron.daily/duckdns | |
sudo chmod +x /etc/cron.daily/duckdns | |
/etc/cron.daily/duckdns | |
sudo apt update | |
sudo DEBIAN_FRONTEND=noninteractive apt -y upgrade | |
sudo DEBIAN_FRONTEND=noninteractive apt install -y nginx certbot python3-certbot-nginx cron-apt | |
echo 'server{listen 80 default_server;server_name _;location /{proxy_pass http://localhost:56980;proxy_http_version 1.1;proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "Upgrade";proxy_set_header Host $host;}}' | sudo dd of=/etc/nginx/sites-enabled/default | |
sudo systemctl restart nginx | |
while true; do | |
sudo certbot -n --nginx --redirect -d $HOST.duckdns.org --agree-tos --email $EMAIL | |
if [ "$?" = "0" ]; then | |
echo SUCCESS | |
break | |
fi | |
echo TRY AGAIN | |
sleep 300 | |
done | |
echo $EMAIL | sudo dd of=/root/.forward | |
echo '#!/bin/sh | |
certbot -n --nginx renew' | sudo dd of=/etc/cron.daily/certbot | |
sudo chmod +x /etc/cron.daily/certbot | |
sed -i "s/^bind-addr: .*/bind-addr: 127.0.0.1:56980/" /home/ubuntu/.config/code-server/config.yaml | |
sed -i "s/^password: .*/password: $PASS/" /home/ubuntu/.config/code-server/config.yaml | |
sudo reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment