-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup-do.sh
executable file
·7 lines (7 loc) · 1.59 KB
/
setup-do.sh
1
2
3
4
5
6
7
#!/bin/bash
# documentation at https://docs.digitalocean.com/reference/api/api-reference/#operation/create_droplet
# image sizes: https://slugs.do-api.dev/
curl -X POST "https://api.digitalocean.com/v2/droplets" \
-d'{"name":"LTG","region":"fra1","size":"c-2","image":"ubuntu-20-04-x64","ssh_keys":["03:70:30:c4:3c:bf:25:c4:6f:62:35:34:d5:74:91:ec"],"user_data":"#!/bin/bash\n\n# install docker\napt-get -y update\napt-get -y remove docker docker-engine docker.io containerd runc\napt-get -y install \\n ca-certificates \\n curl \\n gnupg \\n lsb-release\n# export HOSTNAME=$(curl -s http://169.254.169.254/metadata/v1/hostname)\n# export PUBLIC_IPV4=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)\n# echo Droplet: $HOSTNAME, IP Address: $PUBLIC_IPV4 > /var/www/html/index.html\ncurl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg\necho \\n "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \\n $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null\napt-get -y update\napt-get -y install docker-ce docker-ce-cli containerd.io\n\n# prepare git repository\nmkdir /tmp/repo\ncd /tmp/repo\ngit init\n\napt install -y nodejs npm\ncd /tmp\ncurl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh\nbash ./nodesource_setup.sh\nsudo apt install -y nodejs gcc g++ make\n\nmkdir /tmp/x\nnpm install -g npm\n"}' \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json"