-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSetup.sh
executable file
·215 lines (182 loc) · 4.95 KB
/
Setup.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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
#!/bin/bash
: <<'END'
Comments, requirements and userguide here.
## Description
This is a bash script template. To quickly create good and powerfull scripts.
## Requirements
You need these packages or programs for this script to work.
## Use:
* one parameter
bash_program -a
* multiple parameters without extra input.
bash_program -bac
* multiple parameters with input.
bash_program -a a-param-input -b another_input_value
## Auto install command:
wget --no-cache \
https://raw.githubusercontent.com/magnuskiro/scripts/master/Setup.sh \
&& chmod 755 ./Setup.sh && ./Setup.sh -i && rm ./Setup.sh
## TODO
- create owncloud install script.
- Update this script and documentation.
END
MinimalPackageInstall () {
packages="
git ack-grep htop vim xclip tree
"
echo "-- INFO - Installing minimal packages"
sudo apt install -y $packages
}
PackageInstall () {
MinimalPackageInstall
packages="exuberant-ctags libparse-exuberantctags-perl screen
filezilla texlive lmodern texlive-extra-utils inotify-tools openssh-server eog
vlc maven lmodern i3 i3lock xautolock pavucontrol arandr expect docker.io docker-compose feh"
echo "-- INFO - Installing extra packages"
sudo apt install -y $packages
sudo apt autoremove
}
AptUpgrade () {
echo "-- INFO -- Upgrading"
# Doing System upgrade last.
sudo apt update
#sudo apt upgrade -y
sudo apt full-upgrade -y
sudo apt autoremove
}
CreateSSHkeys () {
echo "-- INFO - SSH"
echo "!-----"
cd ~/.ssh
# if no ssh key, generate it.
if [ ! -e "./id_rsa.pub" ]; then
echo "ssh key does not exist, creating one"
ssh-keygen
echo "!-----"
fi
cd
cat ~/.ssh/id_rsa.pub
echo "!-----"
echo -n "The manual step, put ssh key into github.com then Press [ENTER] to continue...: "
read v
}
CreateFolder () {
folder=$1
if [ ! -d "$folder" ]
then
echo "Creating folder:" $folder
mkdir "$folder"
fi
}
PullAllRepos () {
echo "-- INFO - Pulling all repos"
#TODO fix.
}
CloneRepos () {
echo "-- INFO - Cloning projects"
CreateFolder ~/$repo_folder
# clone projects from git.
gitUser="magnuskiro"
repo_folder="repos"
repos=( "scripts" "configs" "ntnu" "magnuskiro.github.com" )
for repo in "${repos[@]}"
do
# if folder not exists.
if [ ! -d ~/$repo_folder/$repo ]; then
git clone [email protected]:$gitUser/$repo.git ~/$repo_folder/$repo
fi
done
}
CreateSymlinks (){
echo "-- INFO - Creating symlinks"
# linking bin to scripts folder, enabling direct cmd access to personal
# scripts.
rm ~/bin
ln -s ~/repos/scripts/ ~/bin
# Config links
conf_dir="~/repos/configs"
# awesome specifics.
#echo "Creating link: $conf_dir/awesome ~/.config/awesome"
#rm ~/.config/awesome
#eval "ln -s $conf_dir/awesome ~/.config/awesome"
# i3 config
echo "Creating link: $conf_dir/i3 ~/.config/i3"
rm ~/.config/awesome
eval "ln -s $conf_dir/i3 ~/.config/i3"
# for config in list create correct symlink
for conf_file in ".vim" ".vimrc" ".gitconfig" ".bash_aliases"
do
location=$conf_dir/$conf_file
destination=./$conf_file
echo "Creating link: $location $destination"
rm $destination
cmd="ln -s $location $destination"
eval $cmd
done
}
AppendPathVariablesToProfile (){
echo "- INFO -- pah variables are skipped"
#eval \"source ~/repos/configs/path_exports\"
#`cat ~/repos/configs/path_exports >> ~/.profile`
#echo "
#eval `source ~/repos/configs/path_exports`
#" >> ~/.profile
}
LaptopSpecifics () {
# thikpad x201 config.
sudo ln -s "~/repos/configs/20-thinkpad.conf" "/usr/share/X11/xorg.conf.d/20-thinkpad.conf"
}
# Input gathering.
# "ab:c:" is the allowed input parameters.
# 'b:' means that we have a possible -b parameter with a following variable.
# 'a' means that we have a possible parameter without a following input.
# the sequence of options matters. '-b input -a' might give faulty results.
while getopts "lisu" opt; do
# -u(pdate), -i(nstall),-s(server)
case $opt in
l) # create symlinks
CreateSymlinks
;;
# -install
i)
# Upgrade system
AptUpgrade
# install stuff.
PackageInstall
# create ssh keys so we can push to git.
CreateSSHkeys
# pull repos
CloneRepos
# create symlinks
CreateSymlinks
# set path variables to .profile
AppendPathVariablesToProfile
# reload bashrc to enable new commands.
echo "-- INFO - reloading .bashrc and .profile"
eval "source $HOME/.bashrc"
eval "source $HOME/.profile"
~/repos/scripts/install_spotify.sh
~/repos/scripts/install_chrome.sh
;;
# LaptopSpecifics, add laptop config, see method.
l)
LaptopSpecifics
;;
# -server
s)
#TODO
# install minimum for running, quite like minimal
# download configs, and setup vim, gitconfig and such.
# without scripts.
echo "arg given to b is $OPTARG"
;;
# -upgrade
u)
# and another one.
AptUpgrade
;;
# invalid options
\?) echo "Invalid option: -$OPTARG" >&2 ;;
esac
done
exit