diff options
author | Sam Chudnick <sam@chudnick.com> | 2021-12-26 16:23:54 -0500 |
---|---|---|
committer | Sam Chudnick <sam@chudnick.com> | 2021-12-26 16:23:54 -0500 |
commit | 89b4e6601fd71f151bf8076c41d1e88b42090cae (patch) | |
tree | ee48c17191881cf79887eb9c2a6330924cc24672 | |
parent | f585930413fd3a8b0beede193f42fa5f8eab5a00 (diff) |
Break deployment script into two separate scripts - run intended to run as root and the other as the standard user
-rwxr-xr-x | init.sh (renamed from install.sh) | 46 | ||||
-rwxr-xr-x | user.sh | 48 |
2 files changed, 53 insertions, 41 deletions
@@ -1,5 +1,7 @@ | |||
1 | #!/bin/bash | 1 | #!/bin/bash |
2 | 2 | ||
3 | # Script 1 - run this as root after installation | ||
4 | |||
3 | # source configuration file | 5 | # source configuration file |
4 | source deploy.conf | 6 | source deploy.conf |
5 | 7 | ||
@@ -43,45 +45,7 @@ ufw reload | |||
43 | user=$(cat /etc/passwd | grep 1000 | cut -d ':' -f 1) | 45 | user=$(cat /etc/passwd | grep 1000 | cut -d ':' -f 1) |
44 | usermod -aG sudo $user | 46 | usermod -aG sudo $user |
45 | 47 | ||
46 | # Switch to standard user and disable root password | 48 | cp user.sh deploy.conf /home/$USER/ |
47 | su $user | ||
48 | passwd -l root | ||
49 | |||
50 | # Get and deploy dotfiles | ||
51 | echo "backing up current home directory to ~/home_backup" | ||
52 | rsync -av $HOME/ $HOME/home_backup/ | ||
53 | cd $HOME | ||
54 | git clone https://git.chudnick.com/dotfiles | ||
55 | rsync --exclude .git/ --exclude LICENSE -av $HOME/dotfiles/ $HOME | ||
56 | chsh -s $(which zsh) $USER | ||
57 | |||
58 | # DWM | ||
59 | if [ ! -z $DWM ]; then | ||
60 | mkdir -p $HOME/.local/src/ | ||
61 | cd $HOME/.local/src/ | ||
62 | sudo apt install libx11-dev libx11-xcb-dev libxcb-res0-dev libxft-dev libxinerama-dev -y | ||
63 | git clone https://git.chudnick.com/dwm | ||
64 | cd dwm | ||
65 | sudo make install | ||
66 | cd $HOME | ||
67 | fi | ||
68 | |||
69 | # DWMBLOCKS | ||
70 | if [ ! -z $DWMBLOCKS ]; then | ||
71 | mkdir -p $HOME/.local/src/ | ||
72 | cd $HOME/.local/src/ | ||
73 | sudo apt install libx11-dev -y | ||
74 | git clone https://git.chudnick.com/dwmblocks | ||
75 | cd dwmblocks | ||
76 | sudo make install | ||
77 | cd $HOME | ||
78 | fi | ||
79 | |||
80 | # SSH | ||
81 | [ ! -z $CONFIG_SSH ] && ssh-keygen | ||
82 | |||
83 | # SSH SERVER | ||
84 | [ ! -z $CONFIG_SSH_SERVER ] && sudo apt install openssh-server -y && sudo ufw allow ssh | ||
85 | 49 | ||
86 | # GPG | 50 | echo "Next: run 'logout' and then log in as the standard user created during the installation" |
87 | [ ! -z $CONFIG_GPG ] && gpg --full-gen-key | 51 | echo "After loggin in run: './ user.sh'" |
@@ -0,0 +1,48 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | # Script 2 - run as standard user | ||
4 | |||
5 | # source configuration file | ||
6 | source deploy.conf | ||
7 | |||
8 | # Disable root password | ||
9 | passwd -l root | ||
10 | |||
11 | # Get and deploy dotfiles | ||
12 | echo "backing up current home directory to ~/home_backup" | ||
13 | rsync -av $HOME/ $HOME/home_backup/ | ||
14 | cd $HOME | ||
15 | git clone https://git.chudnick.com/dotfiles | ||
16 | rsync --exclude .git/ --exclude LICENSE -av $HOME/dotfiles/ $HOME | ||
17 | chsh -s $(which zsh) $USER | ||
18 | |||
19 | # DWM | ||
20 | if [ ! -z $DWM ]; then | ||
21 | mkdir -p $HOME/.local/src/ | ||
22 | cd $HOME/.local/src/ | ||
23 | sudo apt install libx11-dev libx11-xcb-dev libxcb-res0-dev libxft-dev libxinerama-dev -y | ||
24 | git clone https://git.chudnick.com/dwm | ||
25 | cd dwm | ||
26 | sudo make install | ||
27 | cd $HOME | ||
28 | fi | ||
29 | |||
30 | # DWMBLOCKS | ||
31 | if [ ! -z $DWMBLOCKS ]; then | ||
32 | mkdir -p $HOME/.local/src/ | ||
33 | cd $HOME/.local/src/ | ||
34 | sudo apt install libx11-dev -y | ||
35 | git clone https://git.chudnick.com/dwmblocks | ||
36 | cd dwmblocks | ||
37 | sudo make install | ||
38 | cd $HOME | ||
39 | fi | ||
40 | |||
41 | # SSH | ||
42 | [ ! -z $CONFIG_SSH ] && ssh-keygen | ||
43 | |||
44 | # SSH SERVER | ||
45 | [ ! -z $CONFIG_SSH_SERVER ] && sudo apt install openssh-server -y && sudo ufw allow ssh | ||
46 | |||
47 | # GPG | ||
48 | [ ! -z $CONFIG_GPG ] && gpg --full-gen-key | ||