setup

personal system configuration scripts
git clone git://git.pyratebeard.net/setup.git
Log | Files | Refs | README

forge (2602B)


      1 #!/usr/bin/env bash
      2 #
      3 #    ████
      4 #   ░██░                   █████
      5 #  ██████  ██████  ██████ ██░░░██  █████
      6 # ░░░██░  ██░░░░██░░██░░█░██  ░██ ██░░░██
      7 #   ░██  ░██   ░██ ░██ ░ ░░██████░███████
      8 #   ░██  ░██   ░██ ░██    ░░░░░██░██░░░░
      9 #   ░██  ░░██████ ░███     █████ ░░██████
     10 #   ░░    ░░░░░░  ░░░     ░░░░░   ░░░░░░
     11 #
     12 #  author ▓▒ pyratebeard <root@pyratebeard.net>
     13 #    code ▓▒ https://git.pyratebeard.net/setup
     14 #   usage ▓▒ curl -L https://s.rum.sh/forge > forge && chmod +x forge && ./forge
     15 
     16 # ▓▓▒░ vars
     17 EMAIL="root@pyratebeard.net"
     18 
     19 # ▓▓▒░ functions
     20 function _echo() { printf "\n╓───── %s \n╙────────────────────────────────────── ─ ─ \n" "$1"; }
     21 
     22 [ "$(id -u)" -ne 0 ] && {
     23 	_echo "got root?" >&2
     24 	exit 1
     25 }
     26 
     27 # ▓▓▒░ vault
     28 _echo "enter domain"
     29 read DOMAIN
     30 
     31 echo "$(hostname -s).${DOMAIN}" > /etc/hostname
     32 
     33 # ▓▓▒░ locale
     34 _echo "setting up locales"
     35 locale-gen "en_US.UTF-8"
     36 localectl set-locale en_US.UTF-8
     37 dpkg-reconfigure locales
     38 systemctl daemon-reload
     39 
     40 # ▓▓▒░ packages
     41 _echo "installing runtime deps"
     42 apt update && apt install -y ansible curl git sudo unzip
     43 
     44 # ▓▓▒░ install collection for bitwarden lookup
     45 ansible-galaxy collection install community.general
     46 
     47 # ▓▓▒░ bitwarden
     48 _echo "bitwarden setup"
     49 curl -sL -o /tmp/bw.zip "https://vault.bitwarden.com/download/?app=cli&platform=linux" && \
     50 	unzip -d /usr/local/bin /tmp/bw.zip
     51 export BW_SESSION=$(bw login "${EMAIL}" --raw --method 0)
     52 
     53 # ▓▓▒░ pull play
     54 _echo "cloning repo"
     55 git clone git://git.pyratebeard.net/setup.git /tmp/setup && \
     56 	cd /tmp/setup
     57 
     58 _echo "let's play"
     59 ansible-playbook playbook.yml
     60 
     61 _echo "forge complete"
     62 LIP=$(ip a s $(ip r | grep default | grep -oP '(?<=dev )[^ ]*') | awk '/inet\ / {print $2}' | awk -F/ '{print $1}')
     63 RIP=$(dig -4 ip @dns.toys | awk '/^ip./ {print $NF}' | tr -d '"')
     64 echo "local addr: $LIP"
     65 echo "remote addr: $RIP"
     66 
     67 _echo "cleanup"
     68 bw logout
     69 rm -rf /tmp/bw.zip &>/dev/null
     70 rm -rf /usr/local/bin/bw &>/dev/null
     71 srm -drvl /usr/dwarf/.config/Bitwarden\ CLI &>/dev/null
     72 srm -drvl /etc/ssh/hostca-* &>/dev/null
     73 srm -dvrl /tmp/setup &>/dev/null
     74 srm -dvrl "$0" &>/dev/null
     75 reboot