-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·143 lines (120 loc) · 3.76 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
#!/bin/bash
# Install script for my dotfiles
# Copyright © 2016 liloman
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#version 0.1 "basic" config
#version 0.2 Added mplayer files
#version 0.3 Refactoring and bash_functions
#version 0.4 Changed to stow
#TODO
#Needs some function to "move" the files when stow fails
__ScriptVersion="0.4"
hash stow || { echo "Must install stow first"; exit 1; }
function usage ()
{
cat <<- EOT
Usage : $0 [options] [--]
Options:
-h|help Display this message
-v|version Display script version
-d|desktop Full version
-a|ask Dont ask for passwords
-s|server Server version
EOT
}
function do_symlink ()
{
local orig=$1 dest=$2
[[ ! -f $orig ]] && echo "Warning: $orig doesn't exist." || ln -sf $orig $dest
}
ask=1
while getopts ":hvdsa" opt
do
case $opt in
h|help ) usage; exit 0 ;;
v|version ) echo "$0 -- Version $__ScriptVersion"; exit 0 ;;
d|desktop ) type=desktop ; ;;
s|server ) type=server ; ;;
a|ask ) ask=0 ; ;;
\? ) echo -e "\n Option does not exist : $OPTARG\n"; usage; exit 1 ;;
: ) echo "Option -$OPTARG needs an argument"; exit 1 ;;
esac
done
shift $(($OPTIND-1))
[[ -z $type ]] && { echo "Needs arguments, execute $0 -h for help"; exit 1; }
cd ~/dotfiles
echo Lets install type:$type for $USER then!
#############
# INSTALL #
#############
echo Installing dotfiles for $type
stow -vS bash
stow -vS local-share
stow -vS vim
stow -vS home
stow -vS htop
completions=~/.local/share/bash-completion/completions
#if not a symlink
[[ -d $completions && ! -L $completions ]] && rmdir $completions
#make it a symlink
stow -vS bash_completions
#If not server
if [[ $type != server ]]; then
stow -vS X
stow -vS vimperator
stow -vS mplayer
stow -vS xdg
stow -vS lxde
stow -vS Scripts
stow -vS firejail
#symlinks
do_symlink "$HOME/Clones/mine/bash-surround/inputrc-surround" "$HOME/.inputrc-surround"
shopt -s dotglob
cp -rvuP $PWD/systemd/* $HOME && {
systemctl --user daemon-reload;
systemctl --user enable change-wallpaper.timer;
systemctl --user start change-wallpaper.timer;
systemctl --user enable timemachine.timer;
systemctl --user start timemachine.timer;
#The user services need to be enabled and WantedBy in [Install]
#otherwise they need to be started manually
systemctl --user enable on-logout.service;
}
if ((ask)); then
echo "*****START******"
echo "Let's install the root stuff"
# $USER == local user (not the root user)
su -c '
echo "Enabling sleep@$USER "
cp -v root/*.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable sleep@$USER
systemctl enable intel-popping
echo "*****END******"
'
fi
fi
#######################
# UPDATE SUBMODULES #
#######################
echo Installing submodules
git submodule init
echo Updating submodules
git submodule update --init --remote
if [[ ! -e "$HOME/.local/share/fonts/Literation Mono Powerline.ttf" ]]; then
echo "Installing powerline fonts"
./vim/.vim/bundle/powerline-fonts/install.sh
fi
echo Install script done!.