summarylogtreecommitdiffstats
path: root/system76-driver.install
blob: fa41f5bfa3e1487ad28000ba2b2198b13edd3349 (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
70
71
72
73
_services="system76.service"

_stop_services() {
  /usr/bin/systemctl stop $_services >/dev/null 2>&1
}

_disable_services() {
  /usr/bin/systemctl disable $_services >/dev/null 2>&1
  /usr/bin/systemctl reset-failed $_services >/dev/null 2>&1
}

_restore_services() {
  for service in $_services; do
    if /usr/bin/systemctl -q is-enabled $service >/dev/null 2>&1; then
      /usr/bin/systemctl start $service > /dev/null 2>&1
    fi
  done
}

_remove_symlink() {
  if [ -L $1 ] && [ "$(readlink -f $1)" = "$2" ]; then
    rm $1
  fi
}

post_install() {
cat << EOF

    The System76 Driver package provides the following system services:

        system76.service             System76 airplane-mode hotkey and LED support

    (!) To use system76.service, you must add "ec_sys.write_support=1" to your kernel command line

    (!) For Clevo W740SU BIOS/Firmware users on Galago UltraPro: your will need to create /etc/system76-daemon.json
        file with following content:

        { "vendor": "System76, Inc", "model": "galu1" }

    (!) If you experience Wifi or Thunderbolt issues after resuming from suspend, consider using the
        included restart scripts:

        ln -s /usr/lib/system76-driver/system76-nm-restart /lib/systemd/system-sleep/system76-nm-restart
        ln -s /usr/lib/system76-driver/system76-thunderbolt-reload /lib/systemd/system-sleep/system76-thunderbolt-reload

EOF
}

pre_upgrade() {
  _stop_services
}

post_upgrade() {
  /usr/bin/systemctl daemon-reload >/dev/null 2>&1
  _restore_services
  post_install
}

pre_remove() {
  _stop_services
  _disable_services

  # Remove symlinks if target points to package files
  _remove_symlink /lib/systemd/system-sleep/system76-nm-restart /usr/lib/system76-driver/system76-nm-restart
  _remove_symlink /lib/systemd/system-sleep/system76-thunderbolt-reload /usr/lib/system76-driver/system76-thunderbolt-reload
}

post_remove() {
  /usr/bin/systemctl daemon-reload >/dev/null 2>&1

  # Remove leftover file if present
  rm /etc/xprofile || true
}