-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·71 lines (59 loc) · 2.06 KB
/
bootstrap.sh
File metadata and controls
executable file
·71 lines (59 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/bin/bash
# SytUp Bootstrap Script
#
# Arguments:
# 1: user
# target user to apply the setup to, default is current user
# 2: user link
# link for user repo to use, default is
# https://github.com/gregerspoulsen/sys-setup-gp.git
# 3: extra_vars
# extra_vars to pass to ansible provisioning
# Exit on error:
set -e
# Process arguements:
TARGET_USER=${1:-$USER}
USER_REPO=${2:-https://github.com/gregerspoulsen/sys-setup-gp.git}
MAIN_DIR=~"$TARGET_USER/sytup"
EXTRA_VARS=${3:-user=$TARGET_USER}
# Expand ~ in MAIN_DIR
if [ "${MAIN_DIR:0:1}" == \~ ]; then
eval MAIN_DIR="$(printf '~%q' "${MAIN_DIR#\~}")"
fi
echo "Installing for user: $TARGET_USER at $MAIN_DIR"
echo "Using user repo: $USER_REPO"
# Create main dir if not excisting
sudo -u $TARGET_USER mkdir -p $MAIN_DIR
# Update System:
sudo apt update
sudo apt upgrade -y
# Install ansible:
sudo apt install -y python3-pip
sudo apt remove -y ansible # Pip cannot upgrade apt installed pkg as of 20210610
sudo pip3 install ansible>=4 ansible-lint
# Install required galaxy roles
ansible-galaxy install sicruse.powerline-fonts gantsign.antigen oefenweb.locales gantsign.keyboard
# To enable the user to execute the plays when logged in, install for user:
#sudo -u $TARGET_USER ansible-galaxy install sicruse.powerline-fonts gantsign.antigen oefenweb.locales gantsign.keyboard
# Install git
sudo apt -y install git
# Deploy sytup base repo, skip if exist
if [[ -d "$MAIN_DIR/base" ]]
then
echo "$MAIN_DIR/base already exists - left intact."
else
sudo -u $TARGET_USER git clone https://github.com/gregerspoulsen/system-setup.git $MAIN_DIR/base
fi
# Deploy user repo, skip if exist
if [[ -d "$MAIN_DIR/user" ]]
then
echo "$MAIN_DIR/user already exists - left intact."
else
# Use first argument to script - if unset use gp:
URL=$USER_REPO
sudo -u $TARGET_USER git clone $URL $MAIN_DIR/user
fi
# Set correct owner of $MAIN_DIR
sudo chown -R $TARGET_USER:$TARGET_USER $MAIN_DIR
echo "running provisining with --extra-vars: $EXTRA_VARS"
ansible-playbook --extra-vars "$EXTRA_VARS" $MAIN_DIR/base/recipes/basic.yaml