-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
executable file
·81 lines (66 loc) · 1.46 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
#!/bin/sh
muffled()
{
$@ >/dev/null 2>&1
}
have_fish_ppa()
{
muffled command -v lsb_release && [ `lsb_release -is` = "Ubuntu" ] && [ -e /etc/apt/sources.list.d/fish-shell-release-2*.list ]
}
ensure_installed()
{
if ! muffled command -v $1
then
echo "We need $1. Attempting to install..."
if [ $EUID -ne 0 ]
then
echo "...but we're not allowed. Please run me as root."
exit 1
fi
if ! muffled command -v apt
then
echo "Cannot install $1: Only 'apt'-based distributions are currently supported."
exit 1
fi
apt install $2
fi
}
while getopts "s" arg
do
case $arg in
s) simulate=1 ;;
\?) exit 1 ;;
esac
done
# we need the latest 'fish' version if we can grab it easily enough
if [ ! $simulate ] && ! have_fish_ppa
then
apt-add-repository -y ppa:fish-shell/release-2
apt update
fi
# grab our basic dependencies...
ensure_installed fish fish
ensure_installed git git
# are we in our repo?
muffled git status
if [ $? -eq 128 ]
then
# nope, actually download dotfiles
echo -n "Starting initial download... "
if [ -e dotfiles ]
then
read -p "'dotfiles' exists. Please enter a name for a directory to store the files in: " dirname
else
dirname=dotfiles
fi
if git clone "https://github.com/DrFrankenstein/dotfiles.git" $dirname
then
cd $dirname
. ./setup.sh $@
fi
exit
fi
echo -n "Updating dotfiles... "
git pull || exit
echo "Applying setup..."
fish setup.fish $@