-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
172 lines (131 loc) · 3.67 KB
/
install.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/usr/bin/env bash
# The script needs to be run with sudo
##########################################
# globals
(( step_num=0 ))
step_msg=""
(( sub_step_num=1 ))
desktop=false
user_name=""
##########################################
# functions
step() {
# print step number and info
(( step_num++ ))
step_msg="$1"
echo
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "[Step $step_num]: $step_msg"
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
(( sub_step_num=1))
}
sub_step() {
# print step.sub_step number and info
echo
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
echo "[Step $step_num.$sub_step_num]: ($step_msg) $1"
echo ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"
(( sub_step_num++ ))
}
disp_usage() {
# display script usage
echo "Usage: sudo bash install.sh \$USER headless|desktop"
echo " - headless: no GUI applications needed, e.g. guake, copyq"
echo " - desktop: GUI applications installed, too"
}
##########################################
# check for valid usage
if [ "$#" -ne 2 ] || [ "$2" != "headless" ] && [ "$2" != "desktop" ]; then
# invalid usage
disp_usage
# Ref exit codes: https://www.cyberciti.biz/faq/linux-bash-exit-status-set-exit-statusin-bash/
exit 22 # invalid argument
elif [ "$EUID" -ne 0 ]; then
disp_usage
exit 1 # operation not permitted
elif [ ! -d "/home/$1" ]; then
# first argument should be the username
disp_usage
exit 22
else
if [ "$2" = "desktop" ]; then
desktop=true
fi
user_name=$1
# verify flag set correctly
if $desktop; then
echo ">>> Starting setup for a Desktop device"
else
echo ">>> Starting setup for a Headless device"
fi
echo
fi
##########################################
step "add ppa-repositories"
sub_step "fish"
sudo apt-add-repository -y --no-update ppa:fish-shell/release-3
if $desktop; then
sub_step "copyq"
sudo add-apt-repository -y --no-update ppa:hluk/copyq
fi
# add ppa before this
##########################################
step "apt update"
sudo apt update -y
##########################################
# step "apt upgrade"
# sudo apt upgrade -y
##########################################
step "install with added ppa"
sub_step "fish"
sudo apt install -y fish
if $desktop; then
sub_step "copyq"
sudo apt install -y \
copyq
fi
##########################################
step "install apt packages"
sub_step "openssh-server"
sudo apt install -y openssh-server
sub_step "curl"
sudo apt install -y curl
sub_step "tmux"
sudo apt install -y tmux
sub_step "vim"
sudo apt install -y vim
sub_step "git git-lfs"
sudo apt install -y git git-lfs
sub_step "python3 venv"
sudo apt install -y python3-venv
if $desktop; then
sub_step "guake"
sudo apt install -y guake
fi
##########################################
#step "apt autoremove"
#sudo apt autoremove -y
##########################################
step "Install Docker via convenience script"
# https://docs.docker.com/engine/install/ubuntu/#install-using-the-convenience-script
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh
# Note: when moving files, the user matters
##########################################
step "config files"
user_home_dir="/home/$user_name"
sub_step ".inputrc"
mv .inputrc "$user_home_dir"
sub_step "vim"
mv .vimrc "$user_home_dir"
mv .vim "$user_home_dir"
sub_step "tmux"
mv .tmux.conf "$user_home_dir"
mv .tmux "$user_home_dir"
# tmux plugins
git clone https://github.com/tmux-plugins/tpm "$user_home_dir/.tmux/plugins/tpm"
# sub_step "fish"
# mkdir -p ~/.config/fish && \
# cp .config/fish/config.fish ~/.config/fish
##########################################
exit 0