summarylogtreecommitdiffstats
path: root/knobs.install
blob: 54bfde87c1aaad1346b05f3b5d247ea67a8971f4 (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
### arg 1: the new package version
#pre_install() {
#  echo pre_install $1
#}

### arg 1: the new package version
post_install() {
  echo "create symlinks to subcommands:"
  for SUBCMD in amd-pstate amdgpu cpu cpufreq drm i915 intel-pstate intel-uncore intel-rapl ryzen; do
    if [ -e /usr/bin/$SUBCMD ]; then
      echo "/usr/bin/$SUBCMD: skip (exists)"
    else
      echo "/usr/bin/$SUBCMD: create"
      ln -s /usr/bin/knobs /usr/bin/$SUBCMD
    fi
  done
  systemctl daemon-reload
}

### arg 1: the new package version
### arg 2: the old package version
#pre_upgrade() {
#  echo pre_upgrade $1 $2
#}

### arg 1: the new package version
### arg 2: the old package version
post_upgrade() {
  post_remove "$2" >/dev/null
  post_install "$1"
  systemctl daemon-reload
}

### arg 1: the old package version
#pre_remove() {
#  echo pre_remove $1
#}

### arg 1: the old package version
post_remove() {
  echo "remove symlinks to knobs subcommands:"
  for SUBCMD in amd-pstate amdgpu cpu cpufreq drm i915 intel-pstate intel-uncore intel-rapl ryzen drm-amdgpu drm-i915; do
    if [ -L /usr/bin/$SUBCMD ]; then
      TARGET=$(basename $(readlink /usr/bin/$SUBCMD))
      if [ "$TARGET" = "knobs" ]; then
        echo "/usr/bin/$SUBCMD: delete"
        rm -f /usr/bin/$SUBCMD
      else
        echo "/usr/bin/$SUBCMD: skip (not a knobs symlink)"
      fi
    else
      echo "/usr/bin/$SUBCMD: not found"
    fi
  done
  systemctl daemon-reload
}