summaryrefslogtreecommitdiff
path: root/community-testing/systemd/systemd.install
blob: 259d09b9eb05dfc4cfa3cb13879ed1b62778d849 (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
#!/bin/sh

checkgroups() {
  getent group lock >/dev/null || groupadd -g 54 lock

  utmpent=$(getent group utmp)
  if [ -z $utmpent ]; then
    getent group utmp >/dev/null || groupadd -g 32 utmp
  elif [ $(echo $utmpent | cut -d: -f3) = '22' ]; then
    groupmod -g 32 utmp
  fi
}

post_install() {
  checkgroups

  [ -f /etc/machine-id ] || /bin/systemd-machine-id-setup

  # Try to read default runlevel from the old inittab if it exists
  runlevel=$(/bin/awk -F':' '$3 == "initdefault" && $1 !~ "^#" { print $2 }' /etc/inittab 2> /dev/null)
  if [ -z "$runlevel" ]; then
    target="/lib/systemd/system/graphical.target"
  else
    target="/lib/systemd/system/runlevel$runlevel.target"
  fi

  # And symlink what we found to the new-style default.target
  /bin/ln -sf "$target" /etc/systemd/system/default.target

  echo "systemd has been installed to /bin/systemd. Please ensure you append"
  echo "init=/bin/systemd to your kernel command line in your bootloader."
}

post_upgrade() {
  checkgroups

  [ -f /etc/machine-id ] || /bin/systemd-machine-id-setup
  /bin/systemctl daemon-reexec >/dev/null || :
}

pre_remove() {
  /bin/rm -f /etc/systemd/system/default.target
}

post_remove() {
  getent group lock >/dev/null && groupdel lock
  getent group utmp >/dev/null && groupdel utmp
}

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