From f2ca32f7903abdce523f887c03e217bbd2ddb1e1 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Mon, 4 Jul 2022 05:51:51 +0100 Subject: add provision script for openbsd vms --- provision_openbsd.ksh | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100755 provision_openbsd.ksh (limited to 'provision_openbsd.ksh') diff --git a/provision_openbsd.ksh b/provision_openbsd.ksh new file mode 100755 index 0000000..5d595cd --- /dev/null +++ b/provision_openbsd.ksh @@ -0,0 +1,100 @@ +#!/bin/ksh + +# Send in id_rsa.pub and id_rsa +# send in /etc/doas.conf and install and chown root:wheel /etc/doas.conf +# pkg_add git in guest +# send in openbsddotfiles/profile_vm_provisioning (or similar) and rename to .profile +# source .profile in guest +# send in THIS FILE AND EXECUTE IT ON THERE + +# download ISO from https://cdn.openbsd.org/pub/OpenBSD/$(uname -r)/amd64/install71.iso + +INC_CODE=0 + + +usage() +{ + print "Usage: $0 [-c]" + exit 2 +} + +while getopts 'ch' opt +do + case $opt in + c) INC_CODE=1; print "Will fetch code from github." ;; + h) usage ;; + ?) usage ;; + esac +done + + + +command -v vim > /dev/null 2>&1 +if [ "$?" != 0 ]; then + doas pkg-add vim +fi + + +doas pkg_add fzf the_silver_searcher zip + +if [ $INC_CODE -eq 1 ]; then + ssh-add -v + print -n "Creating necessary directories..." + mkdir -p ~/code/python + mkdir -p ~/.config/ + mkdir -p ~/.fzf/ + print "ok" + + print -n "Fetching dotfiles..." + if [ ! -d ~/openbsddotfiles ]; then + git clone git@github.com:yulqen/openbsddotfiles.git ~/openbsddotfiles 2>&1 > /dev/null + print "ok" + else + print "dotfiles directory already exists." + fi + + print -n "Fetching dbasik..." + if [ ! -d ~/code/python/dbasik ]; then + git clone git@github.com:yulqen/dbasik.git ~/code/python/dbasik 2>&1 > /dev/null + print "ok" + else + print "dbasik directory already exists." + fi + + print -n "Fetching datamaps..." + if [ ! -d ~/code/python/datamaps ]; then + git clone git@github.com:yulqen/datamaps.git ~/code/python/datamaps 2>&1 > /dev/null + print "ok" + else + print "datamaps directory already exists." + fi + + print -n "Fetching bcompiler-engine..." + if [ ! -d ~/code/python/bcompiler-engine ]; then + git clone git@github.com:yulqen/bcompiler-engine.git ~/code/python/bcompiler-engine 2>&1 > /dev/null + print "ok" + else + print "bcompiler-engine directory already exists." + fi + + print -n "Creating code-related symlinks..." + ln -sf openbsddotfiles/pdbrc .pdbrc + ln -sf openbsddotfiles/pdbrc.py .pdbrc.py + ln -sf openbsddotfiles/flake8 /home/lemon/.config/.flake8 + ln -sf $(which fzf) ~/.fzf + print "ok" +fi + + +print -n "Creating regular symlinks..." +cd ~ +ln -sf openbsddotfiles/kshrc_vm_provision .kshrc +ln -sf openbsddotfiles/ksh_aliases .ksh_aliases +ln -sf openbsddotfiles/profile_vm_provisioning .profile +ln -sf openbsddotfiles/tmux.conf .tmux.conf +ln -shf openbsddotfiles/vim ~/.vim +ln -sf openbsddotfiles/gitconfig .gitconfig +ln -sf openbsddotfiles/gitignore_global .gitignore_global +print "ok" + + -- cgit v1.2.3