forked from atomantic/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bootstrap.sh
executable file
·86 lines (72 loc) · 2.74 KB
/
bootstrap.sh
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
LOCAL_USER=${2:-tg}
PASSWORD_STORE_REPO=${1:-https://gitlab.com/thomas.groch/password-store.git}
# Check if sudo is installed and the user has sudo privileges
if sudo -v &>/dev/null; then
echo "User has sudo privileges"
else
echo "sudo is not installed or user does not have sudo privileges"
fi
if [ ! -f ~/.ssh/tgroch_id_rsa ]; then
chown $LOCAL_USER:$LOCAL_USER ~/.ssh/tgroch_id_rsa
chown $LOCAL_USER:$LOCAL_USER ~/.ssh
chmod 700 ~/.ssh
chmod 600 ~/.ssh/tgroch_id_rsa
ssh-add ~/.ssh/tgroch_id_rsa
fi
# Clone password store
if [[ ! -e ~/.password-store ]]; then
git clone "$PASSWORD_STORE_REPO" ~/.password-store
fi
# Install Homebrew if not installed on macOS
if [[ $(uname) == "Darwin" ]] && ! command -v brew &> /dev/null; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Install pass
if ! command -v pass &> /dev/null; then
if command -v brew &> /dev/null; then
brew install pass
elif command -v pacman &> /dev/null; then
sudo pacman -S --noconfirm pass
elif command -v apt &> /dev/null; then
sudo apt-get update
sudo apt-get install -y pass
else
echo "Unsupported package manager. Please install 'pass' manually."
fi
fi
# Install Ansible
if ! command -v ansible-pull &> /dev/null; then
if [[ $(uname) == "Darwin" ]] && command -v brew &> /dev/null; then
brew install ansible
elif command -v pacman &> /dev/null; then
sudo pacman -S --noconfirm ansible
elif command -v apt &> /dev/null; then
sudo apt-get update
sudo apt-get install -y ansible
else
echo "Unsupported package manager. Please install 'ansible' manually."
fi
fi
sudo pacman -S --noconfirm xclip
# Update system
if command -v brew &> /dev/null; then
echo "Updating Homebrew..."
brew update
brew upgrade
brew cleanup
elif command -v pacman &> /dev/null; then
sudo sed -i "s/#ParallelDownloads = 5/ParallelDownloads = 50/g" /etc/pacman.conf
sudo sed -i "s/#Color/Color/g" /etc/pacman.conf
sudo pacman -Syyu --noconfirm
elif command -v apt &> /dev/null; then
sudo apt-get update
sudo apt-get upgrade -y
fi
# cat "/run/media/${LOCAL_USER}/SAFE/safe/gpg/[email protected]" | xclip -selection clipboard
# gpg --import "/run/media/${LOCAL_USER}/SAFE/safe/gpg/[email protected]"
# gpg --import "/run/media/${LOCAL_USER}/SAFE/safe/gpg/[email protected]"
sudo touch /var/log/ansible.log
sudo chown $USER:$USER /var/log/ansible.log
# Restore ansible
ansible-pull --vault-password-file ~/.vault_key --url https://github.com/homeofficehost/dotfiles --limit "$(cat /etc/hostname).local" --checkout master