-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupMachine.sh
executable file
·148 lines (127 loc) · 3.25 KB
/
setupMachine.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
#!/bin/bash
echo "Setting up machine..."
if [[ $UID -ne 0 ]]; then
sudo -p 'Restarting as root, password: ' bash $0 "$@"
exit $?
fi
NOGUI=""
BRANCH="master"
while [ ! -z "$1" ]; do
case "$1" in
-nogui|-n)
shift
echo "(no GUI requested)"
NOGUI="-NoGUI"
;;
-branch|-b)
shift
BRANCH="$1"
shift
;;
esac
shift
done
echo "Selected branch: $BRANCH"
if [ "$NOGUI" == "" ]; then
if [ ! -f "$(which dconf)" ]; then
echo "(dconf does not exist, so I'm going to assume you want -nogui)"
NOGUI="-NoGUI"
fi
fi
pushd ~ > /dev/null
apt-get update
if [ -f "$(which lsb_release)" ]; then
lsb_release -a
else
apt-get install -y lsb-release
lsb_release -a
fi
if [ -f "$(which wget)" ]; then
echo "(wget already installed)"
else
echo ""
echo "Installing wget"
echo ""
apt-get install -y wget
fi
if [ -f "$(which curl)" ]; then
echo "(curl already installed)"
else
echo ""
echo "Installing curl"
echo ""
apt-get install -y curl
fi
if [ -f "$(which git)" ]; then
echo "(git already installed)"
else
echo ""
echo "Installing git"
echo ""
apt-get install -y git
fi
if [ -f "$(which vim)" ]; then
echo "(vim already installed)"
else
echo ""
echo "Installing vim"
echo ""
apt-get install -y vim
fi
if [ "$NOGUI" == "" ]; then
if [ -f "$(which gvim)" ]; then
echo "(gvim already installed)"
else
echo ""
echo "Installing gvim"
echo ""
apt-get install -y vim-gtk3
fi
fi
if [ -f "$(which pwsh)" ]; then
echo "(pwsh already installed)"
else
echo ""
echo "Installing pwsh"
echo ""
#wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
#dpkg -i packages-microsoft-prod.deb
#apt-get update
#apt-get install -y powershell
# This way should be a little more version-independent, and also includes the VS Code
# IDE.
# I can't seem to get this way to work:
#bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh) -includeide
# But this does:
if [ $NOGUI == "" ]; then
INCLUDE_IDE_ARG="includeide"
fi
wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh | bash -s $INCLUDE_IDE_ARG
fi
if [ -f "$(which dconf)" ]; then
# Tweak double-click word boundaries in terminal:
dconf write /org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9/word-char-exceptions '@ms "-#%&+,./:=?@_~"'
fi
if [ ! -d ./nixSetup ]; then
echo ""
echo "Cloning personal stuff"
echo ""
# sudo back to the calling user so that you won't have to use sudo to do things
# like "git pull" in this dir:
sudo -u $SUDO_USER git clone --branch $BRANCH https://github.com/jazzdelightsme/nixSetup.git
cd ./nixSetup
pwsh -ExecutionPolicy Bypass -NoProfile ./moreSetup.ps1 $NOGUI
# Reload profile in case env. vars were added.
. ~/.profile
else
echo ""
echo "The nixSetup directory already exists. If you want to re-run the setup,"
echo "do something like:"
echo ""
echo " cd ~/nixSetup"
echo " git pull"
echo " sudo pwsh -ExecutionPolicy Bypass -NoProfile ./moreSetup.ps1"
echo " . ~/.profile"
echo ""
fi
popd > /dev/null