summarylogtreecommitdiffstats
path: root/wireguard-ui.install
blob: 7369ceb7e7e37ca81bc7cf3c26e020eae9533778 (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
all_off="$(tput sgr0)"
bold="${all_off}$(tput bold)"
blue="${bold}$(tput setaf 4)"
yellow="${bold}$(tput setaf 3)"

noteb() {
  printf "${blue}  ->${yellow} ${bold}$1${all_off}\n"
}

note() {
  printf "${blue}  ->${yellow} $1${all_off}\n"
}

post_install() {
  sysctl -q --system
  systemctl --quiet daemon-reload
  useradd -r -U -s /usr/bin/nologin -m -d /var/lib/wireguard-ui wireguard-ui
  [ ! -f "/etc/wireguard/wg0.conf" ] && { mkdir -p /etc/wireguard/; touch /etc/wireguard/wg0.conf; }
  setfacl -m wireguard-ui:rw /etc/wireguard/wg0.conf
  echo
  noteb "Please start and enable service:"
  echo  "sudo systemctl enable --now wireguard-ui"
  echo
  note  "Then open in browser http://<ip_server>:5000"
  noteb "The default username and password are 'admin'. Please change it to secure your setup!"
  echo
  noteb "REQUIRED: Also specify in server settings PostUp and PostDown scripts:"
  echo  "PostUp:   '/usr/bin/wgiptables up'"
  echo  "PostDown: '/usr/bin/wgiptables down'"
  echo
  noteb "Then save server settings and finally start wg server:"
  echo  "sudo systemctl enable --now wgui.{service,path}"
  echo
  noteb "Optional: Also you could create /etc/wireguard-ui/environment.conf file."
  echo  "More info: https://github.com/ngoduykhanh/wireguard-ui#environment-variables"
  echo
}

post_upgrade() {
  sysctl -q --system
  systemctl --quiet daemon-reload
}

pre_remove() {
  systemctl --quiet --no-reload disable --now wireguard-ui.service
  systemctl --quiet --no-reload disable --now wgui.path
  systemctl --quiet --no-reload disable --now wgui.service
}

post_remove() {
  note "Old settings are located in /var/lib/wireguard-ui/db, skip removing."
  systemctl --quiet daemon-reload
  sysctl -q --system
}