-
Notifications
You must be signed in to change notification settings - Fork 9
/
deploy-mloskot.sh
executable file
·140 lines (127 loc) · 2.96 KB
/
deploy-mloskot.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
#
# dotfiles-mloskot.sh - deploys dotfiles for non-root mloskot user
#
# Mateusz Loskot <[email protected]>
#
# The dotfiles are used in Arch Linux setup on my workstation.
#
# Configuration
DOTFILES=${PWD}/home/mloskot
OVERWRITE=1
#
# Functions
#
usage()
{
echo "archlinux-config deployment by Mateusz Loskot <[email protected]>"
echo ""
echo "Usage:"
echo "$0 TARGET"
echo " TARGET Name of target machine: browar, dog, gaja or vb"
echo ""
echo "Git repository at https://github.com/mloskot/archlinux-config"
}
function make_symlink()
{
T=${1}
L=${2}
if [ ! -f "${T}" -a ! -d "${T}" ]; then
echo "Target ${T} does not exist - skipping"
return 1
fi
if [ -f "${L}" ]; then
echo "Regular file ${L} already exists - overwriting"
[ ${OVERWRITE} -eq 1 ] && rm ${L}
elif [ -L "${L}" ]; then
echo "Symlink ${L} already exists - overwriting"
[ ${OVERWRITE} -eq 1 ] && rm ${L}
fi
ln -s ${T} ${L}
echo "Symlink ${L} created"
return $?
}
function deploy_file()
{
T=${1}
L=${2}
if [ -z "${L}" ]; then
L=${T} # target renaming or relative path
fi
LINK_TARGET=${DOTFILES}/${T}
LINK_NAME=${HOME}/${L}
echo "Deploying ${LINK_TARGET} to ${LINK_NAME}"
LINK_DIR=`dirname ${LINK_NAME}`
if [ ! -d ${LINK_DIR} ]; then
echo "Creating directory ${LINK_DIR}"
mkdir -p ${LINK_DIR}
fi
make_symlink ${LINK_TARGET} ${LINK_NAME}
if [ $? -ne 0 ]; then
echo "Something went wrong - giving up"
exit 1
fi
echo
}
# Main script
if [ ! -d "${DOTFILES}" ]; then
echo "Cannot find dotfiles location"
exit 1
fi
while true; do
case "$1" in
browar) TARGET=browar; break;;
dog) TARGET=dog; break;;
gaja) TARGET=gaja; break;;
vb) TARGET=vb; break;;
*) usage; exit 0;;
esac
shift
done
echo "Deploying '${TARGET}' dotfiles from ${DOTFILES} to ${HOME}"
echo
# ~/bin
deploy_file bin
# shell
deploy_file .profile
deploy_file .aliases
deploy_file .bash_profile
deploy_file .bashrc
deploy_file .zshenv
deploy_file .zshrc
deploy_file .zsh
# Vim
deploy_file .vim
deploy_file .vimrc
# Git
deploy_file .gitconfig
deploy_file .gitignore_global
# X
deploy_file .xinitrc.i3 .xinitrc
#deploy_file .Xresources
#deploy_file .Xresources .Xdefaults
# XDG
deploy_file .config/user-dirs.dirs
deploy_file .config/user-dirs.locale
# i3wm
deploy_file .config/i3.${TARGET} .config/i3
deploy_file .config/i3status.${TARGET} .config/i3status
# GTK+ 2.x
deploy_file .gtkrc-2.0
# ~/.config
deploy_file .config/gtk-3.0
deploy_file .config/openbox
deploy_file .config/volumeicon.${TARGET} .config/volumeicon
deploy_file .config/tint2
deploy_file .config/Terminal
# KDE
deploy_file .kde4/share/config/krusaderrc
# Misc
deploy_file .conkyrc
deploy_file .fehbg
deploy_file .gemrc
deploy_file .mcabber
deploy_file .packer.conf
deploy_file .config/pacaur
deploy_file .wallpapers
deploy_file .wgetrc
deploy_file signature.txt