summarylogtreecommitdiffstats
path: root/ogar-git.install
blob: 85da7bd6617d299c57c506a3a337d6dfbc268126 (plain)
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
post_install() {
echo "Creating ogar user and group if they don't exist"
  if ! getent group "ogar" >/dev/null; then
    groupadd -r ogar
  fi
  if ! getent passwd "ogar" >/dev/null; then
    useradd -r -M -N -g ogar -d /usr/share/ogar -s /usr/bin/nologin -c 'Ogar Server' ogar
  fi

echo "Symlinking gameserver.ini to /etc/ogar"
ln -s /usr/share/ogar/gameserver.ini /etc/ogar

echo "Installing ws module"
rm -R /root/.npm
cd /usr/share/ogar
npm install ws

echo "Setting proper permissions"
chown -R ogar:ogar /usr/share/ogar
chmod -R 755 /usr/share/ogar
}

post_upgrade() {
echo "Creating ogar user and group if they don't exist"
  if ! getent group "ogar" >/dev/null; then
    groupadd -r ogar
  fi
  if ! getent passwd "ogar" >/dev/null; then
    useradd -r -M -N -g ogar -d /usr/share/ogar -s /usr/bin/nologin -c 'Ogar Server' ogar
  fi

echo "Symlinking gameserver.ini to /etc/ogar"
ln -s /usr/share/ogar/gameserver.ini /etc/ogar

echo "Installing ws module"
rm -R /root/.npm
cd /usr/share/ogar
npm install ws

echo "Setting proper permissions"
chown -R ogar:ogar /usr/share/ogar
chmod -R 755 /usr/share/ogar
}

pre_remove() {
  if systemctl --quiet is-active ogar; then
    systemctl stop ogar
  fi
}

post_remove() {
echo "Removing ogar user and group"
  if getent passwd "ogar" >/dev/null; then
    userdel ogar > /dev/null
  fi
  if getent group "ogar" >/dev/null; then
    groupdel ogar >/dev/null
  fi

echo "Unlinking /etc/ogar"
unlink /etc/ogar

echo "Removing ws module"
cd /usr/share/ogar
npm uninstall ws
}

# vim:set ts=2 sw=2 et: