-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.zsh
executable file
·78 lines (62 loc) · 1.46 KB
/
bootstrap.zsh
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
#!/usr/bin/env zsh
set -e
set -u
puts () {
echo "\n-- [${1:-}] ${2:-}"
}
set_hostname () {
hostname="${1:-}"
if [[ -z ${hostname} ]]; then
echo 'Must give hostname as first argument.'
exit 2
fi
puts 'Setting' 'Hostname'
echo $hostname | sudo -S tee /etc/hostname
sudo -S hostname $hostname
puts 'Hostname' $hostname
}
install_config () {
puts 'Installing' 'Node modules'
sudo -S pacman -S --noconfirm rsync npm
npm install
puts 'Installed' 'Node modules'
puts 'Installing' 'Config'
sudo npm start
puts 'Installed' 'Config'
}
install_archutil () {
archutil_url='https://raw.githubusercontent.com/rxrc/archutil/v1.2.9/bin/archutil'
puts 'Installing' 'archutil requirements'
sudo -S pacman -Sy
sudo -S pacman -S --noconfirm curl python python-yaml
puts 'Installed' 'archutil requirements'
if ! [[ -e /usr/local/bin/archutil ]]; then
puts 'Installing' 'archutil'
sudo -S curl -L -o /usr/local/bin/archutil $archutil_url
fi
if [[ -e /usr/local/bin/archutil ]]; then
sudo -S chmod +x /usr/local/bin/archutil
puts 'Installed' 'archutil'
fi
}
set_locale () {
puts 'Setting' 'Locale'
sudo -S locale-gen
export $(cat /etc/locale.conf)
puts 'Set' 'Locale'
}
main () {
echo 'Preauthenticate for sudo.'
sudo -S echo
if [[ $(id -u) == 0 ]]; then
echo 'Must not run as root.'
exit 1
fi
set_hostname ${1:-}
install_config
install_archutil
set_locale
puts 'Done' ''
}
main ${1:-}
exit