summarylogtreecommitdiffstats
path: root/nordvpn-bin.install
blob: 0b33f48128a0b2fbbd3209d420af9a37ffe8a72f (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
post_install() {
  echo ':: In order to enable nordvpn you have to start the following service:'
  echo '     sudo systemctl enable --now nordvpnd'
  echo ':: You have to add yourself to the nordvpn group:'
  echo "     sudo gpasswd -a USERNAME nordvpn"
  echo ':: You then have to restart for the group to be created:'
  echo "     reboot"
  # Add logic to avoid interposing with sqlite library if it already exists
  for lib in /usr/lib/nordvpn/*.so ; do
    if [[ -f $lib ]] ; then
      if [[ ! -f "/usr/lib/$(printf '%s' $lib | cut -d '/' -f 5)" ]] ; then
        ln -s $lib /usr/lib/
      fi
    fi
  done
  ## Temporary fix
  if [[ ! -e /usr/lib/libxml2.so.2 ]] ; then
    ln -s /usr/lib/nordvpn/libxml2.so.2 /usr/lib/
  fi
}

post_upgrade() {
  # Add logic to avoid interposing with sqlite library if it already exists
  for lib in /usr/lib/nordvpn/*.so ; do
    if [[ -f $lib ]] ; then
      if [[ $(readlink -- /usr/lib/$(printf '%s' $lib | cut -d '/' -f 5)) == $lib ]] ; then
        unlink /usr/lib/$(printf '%s' $lib | cut -d '/' -f 5)
      fi
      if [[ ! -f "/usr/lib/$(printf '%s' $lib | cut -d '/' -f 5)" ]] ; then
        ln -s $lib /usr/lib/
      fi
    fi
  done
  ## Temporary fix
  if [[ ! -e /usr/lib/libxml2.so.2 ]] ; then
    ln -s /usr/lib/nordvpn/libxml2.so.2 /usr/lib/
  fi
}

pre_install() {
  if [ -d /var/lib/nordvpn/data/ ]; then
  	chattr -i /var/lib/nordvpn/data/*
  fi
}

pre_upgrade() {
  chattr -i /var/lib/nordvpn/data/*
}

pre_remove() {
  chattr -i /var/lib/nordvpn/data/*
  # Add logic to avoid interposing with sqlite library if it already exists
  for lib in /usr/lib/nordvpn/*.so ; do
    if [[ -f $lib ]] ; then
      if [[ $(readlink -- /usr/lib/$(printf '%s' $lib | cut -d '/' -f 5)) == $lib ]] ; then
        unlink /usr/lib/$(printf '%s' $lib | cut -d '/' -f 5)
      fi
    fi
  done
  ## Temporary fix
  if [[ $(readlink -- /usr/lib/libxml2.so.2) == /usr/lib/nordvpn/libxml2.so.2 ]]; then
    unlink /usr/lib/libxml2.so.2
  fi
}