-
Notifications
You must be signed in to change notification settings - Fork 4
/
freebsd_install.sh
79 lines (60 loc) · 1.48 KB
/
freebsd_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
#!/bin/sh
OPENADMS_PATH=/usr/local/sbin/openadms
OPENADMS_CONFIG_PATH=/usr/local/etc/openadms
OPENADMS_USER="openadms"
create_user() {
if pw group show $OPENADMS_USER | grep -qv "^$OPENADMS_USER" ; then
pw groupadd $OPENADMS_USER -g 5000
fi
if pw user show $OPENADMS_USER | grep -qv "^$OPENADMS_USER" ; then
pw useradd -n $OPENADMS_USER -c OpenADMS Owner -g $OPENADMS_USER -s /usr/sbin/nologin -d /nonexistent
fi
}
create_dirs() {
mkdir -p $OPENADMS_PATH
mkdir -p $OPENADMS_CONFIG_PATH
}
copy_files() {
cp -r . $OPENADMS_PATH
rm -r $OPENADMS_PATH/config
rm -r $OPENADMS_PATH/data
chown -R $OPENADMS_USER $OPENADMS_PATH
cp -r ./config/ $OPENADMS_CONFIG_PATH
chown -R $OPENADMS_USER $OPENADMS_CONFIG_PATH
}
install_pipenv() {
pkg install devel/py-pipenv
}
install_modules() {
pipenv lock
pipenv sync
}
copy_rc() {
cp services/openadms.freebsd /usr/local/etc/rc.d/openadms
}
install() {
echo
echo "Creating user ..."
create_user
echo "Creating directories ..."
create_dirs
echo "Copying files ..."
copy_files
echo "Installing pipenv ..."
install_pipenv
echo "Syncing dependencies ..."
install_modules
echo "Installing rc.d script ..."
copy_rc
echo ; echo "Add the following line to /etc/rc.conf:" ; echo
echo " openadms_enable=\"YES\"" ; echo
}
if uname | grep -qv "FreeBSD" ; then
echo "You are not running FreeBSD"
exit
fi
echo -n "Install OpenADMS? [y/n] "
read answer
if echo "$answer" | grep -iq "^y" ; then
install
fi