This commit is contained in:
ColinK_ 2022-10-28 18:01:03 -04:00
parent a80897759b
commit 0feef73e08
No known key found for this signature in database
GPG Key ID: 4AAD22F8C49A5E9B
3 changed files with 64 additions and 26 deletions

View File

@ -1,2 +1,17 @@
## Scope
Digital Ocean droplet "user data" instruction set for bootstrapping a Digital Ocean droplet to certain specifications required for deployment scopes. Each branch should contain a bootstrap instruction set to restore a droplet to the latest update of a configuration. This way one static file can be updated and a droplet can be more like a container designed to be "as ephemeral as possible"
Generic server bootstrap to get some of the most basic utilities installed that would typically be everywhere I deploy these days. This includes ZSH, Sentry, Gluster, Salt, Docker and support tools and various other optimizations.
## Usage
```bash
#!/usr/bin/env bash
## source <(curl -s https://digitalocean-user-data:sHEG3NTC6og8pCJDTF6EPYb8jLmbskx5Ns@git.nixc.us/Colin_/bootstrap-scripts/raw/branch/main/strap.sh) defaults-bootstrap
```
Copy the above into any server post install scripts box and it should get things going pretty quickly.
## Advanced Usage and Provider Specific Deploys
For example if you wanted to deploy to DigitalOcean you would use the following example.
```bash
#!/usr/bin/env bash
source <(curl -s https://imp-bootstap:sHEG3NTC6og8pCJDTF6EPYb8jLmbskx5Ns@git.nixc.us/Colin_/bootstrap-scripts/raw/branch/main/strap.sh) bootstrap
```

View File

@ -4,27 +4,50 @@ set -e
echo 'export SENTRY_DSN=https://4d089076433c4a7aa31bbb2741f053fe@sentry.aenow.com/3'
eval "$(sentry-cli bash-hook)"
## Determine in the future why these were here. https://docs.digitalocean.com/products/droplets/how-to/provide-user-data/
## digitalocean-user-data sHEG3NTC6og8pCJDTF6EPYb8jLmbskx5Ns
## digitalocean-user-data@nixc.us
# curl -sL https://sentry.io/get-cli/ | bash
## DigitalOcean's API for obtaining server metadata.
function digitalocean() {
export HOSTNAME=$(curl -s http://169.254.169.254/metadata/v1/hostname)
hostnamectl set-hostname $HOSTNAME
# echo $HOSTNAME > /etc/hostname
# hostname -F /etc/hostname
# hostname -f
export PUBLIC_IPV4=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)
export PUBLIC_IPV6=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv6/address)
}
## Add anything for OVH here.
function ovh() {
echo Nothing special for DigitalOcean at this stage.
}
## Choose which DC provider sepecifics need installed.
case $1 in
digitalocean )
digitalocean
;;
ovh )
ovh
;;
none )
echo Nothing special going to be done here.
;;
* )
echo bootstrap options are:
echo bootstrap ovh [gluster/nogluster] [salt/nosalt]
echo bootstrap digitalocean [gluster/nogluster] [salt/nosalt]
echo bootstrap none [gluster/nogluster] [salt/nosalt]
;;
esac
## BLOCK THIS OUT IF NOT DEPLOYING TO DIGITALOCEAN ##
export HOSTNAME=$(curl -s http://169.254.169.254/metadata/v1/hostname)
echo $HOSTNAME > /etc/hostname
hostname -F /etc/hostname
hostname -f
export PUBLIC_IPV4=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv4/address)
export PUBLIC_IPV6=$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/ipv6/address)
## BLOCK THIS OUT IF NOT DEPLOYING TO DIGITALOCEAN ##
function install_salt() {
## Installing Salt for Ubuntu 20.04
curl -fsSL -o /usr/share/keyrings/salt-archive-keyring.gpg https://repo.saltproject.io/py3/ubuntu/20.04/amd64/latest/salt-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/salt-archive-keyring.gpg arch=amd64] https://repo.saltproject.io/py3/ubuntu/20.04/amd64/latest focal main" | sudo tee /etc/apt/sources.list.d/salt.list
mkdir -p /etc/salt/minion.d/
echo 'master: salt.aenow.fun' > /etc/salt/minion.d/99-master-address.conf
echo 'master: rios.aenow.fun' > /etc/salt/minion.d/99-master-address.conf
}
function install_gluster_pre() {
@ -42,7 +65,7 @@ wget -qO - https://azlux.fr/repo.gpg.key | sudo apt-key add -
## Install Gluster Pre
echo Gluster Pre Function
case $1 in
case $2 in
gluster )
install_gluster_pre
;;
@ -52,8 +75,8 @@ case $1 in
* )
echo no gluster instructions received.
echo options are:
echo ./bootstrap gluster [salt/nosalt]
echo ./bootstrap nogluster [salt/nosalt]
echo bootstrap [hostingProvider] gluster [salt/nosalt]
echo bootstrap [hostingProvider] nogluster [salt/nosalt]
;;
esac
@ -65,7 +88,7 @@ DEBIAN_FRONTEND=noninteractive apt-get install -y asciinema docker-ctop git glan
## Install Gluster Post
echo Gluster Post Function
case $1 in
case $2 in
gluster )
install_gluster_post
;;
@ -76,7 +99,7 @@ esac
## Install salt
echo Installing Salt
case $2 in
case $3 in
salt )
install_salt
;;
@ -86,12 +109,12 @@ case $2 in
* )
echo no salt instructions received.
echo options are:
echo ./bootstrap [gluster/nogluster] salt
echo ./bootstrap [gluster/nogluster] nosalt
echo bootstrap [hostingProvider] [gluster/nogluster] salt
echo bootstrap [hostingProvider] [gluster/nogluster] nosalt
;;
esac
## Install docker-compose and docker using convenience scripts docker-compose-plugin via apt and container top via wget
## Install docker-compose and docker using convenience scripts
echo Install docker-compose and docker via convenience scripts
curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
@ -99,7 +122,7 @@ curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
DEBIAN_FRONTEND=noninteractive apt-get install -y docker-compose-plugin
## Install CTOP Container Top https://github.com/bcicen/ctop
wget https://github.com/bcicen/ctop/releases/download/0.7.7/ctop-0.7.7-linux-amd64 -O /usr/local/bin/ctop
wget https://github.com/bcicen/ctop/releases/download/0.7.6/ctop-0.7.6-linux-amd64 -O /usr/local/bin/ctop
chmod +x /usr/local/bin/ctop
## This may no longer be required going forward, it'll be better to call it on first login instead with args.

View File

@ -1,10 +1,10 @@
## #!/usr/bin/env bash
#!/usr/bin/env bash
set -e
## Basic deps
DEBIAN_FRONTEND=noninteractive apt-get install -y curl wget
## source <(curl -s https://digitalocean-user-data:sHEG3NTC6og8pCJDTF6EPYb8jLmbskx5Ns@git.nixc.us/Colin_/bootstrap-scripts/raw/branch/main/strap.sh) defaults-bootstrap
## source <(curl -s https://imp-bootstrap:sHEG3NTC6og8pCJDTF6EPYb8jLmbskx5Ns@git.nixc.us/Colin_/bootstrap-scripts/raw/branch/main/strap.sh) defaults-bootstrap
curl -sL https://sentry.io/get-cli/ | bash
# echo 'export SENTRY_DSN=https://4d089076433c4a7aa31bbb2741f053fe@sentry.aenow.com/3'
# eval "$(sentry-cli bash-hook)"
@ -14,7 +14,7 @@ curl -o /usr/local/sbin/bootstrap https://imp-bootstrap:sHEG3NTC6og8pCJDTF6EPYb8
## Run bootstrap
case $1 in
bootstrap )
/usr/local/sbin/bootstrap $2 $3
/usr/local/sbin/bootstrap $2 $3 $4
;;
defaults-bootstrap )
/usr/local/sbin/bootstrap nogluster nosalt