summaryrefslogtreecommitdiff
path: root/audio/SlimServer/doinst.sh
blob: 0af300488157b167a5f254f9c888394b21ab20b0 (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
config() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
    # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

# Keep same perms on rc.slimserver.new:
if [ -e etc/rc.d/rc.slimserver ]; then
  cp -a etc/rc.d/rc.slimserver etc/rc.d/rc.slimserver.new.incoming
  cat etc/rc.d/rc.slimserver.new > etc/rc.d/rc.slimserver.new.incoming
  mv etc/rc.d/rc.slimserver.new.incoming etc/rc.d/rc.slimserver.new
fi

config etc/rc.d/rc.slimserver.new

# Create a log file - this won't be removed when the package is uninstalled
# (this is as it should be)
touch var/log/slimserver.log

# If a slimserver.conf file exists, there's no need to install the empty one
# with a .new suffix
if [ -e etc/slimserver.conf ]; then
  rm -f etc/slimserver.conf.new
else
  mv etc/slimserver.conf.new etc/slimserver.conf
fi

# If there's no slimserver user, then bail out now.
if ! grep -q ^slimserver etc/passwd ; then 
  echo
  echo "There is no 'slimserver' user present."
  echo "Add the user and then reinstall the SlimServer package."
  echo "Exiting..."
  exit 1
fi

chroot . /bin/chown slimserver:users /etc/slimserver.conf \
  /var/log/slimserver.log /var/cache/slimserver
chroot . /bin/chown -R slimserver:users /opt/slimserver