summarylogtreecommitdiffstats
path: root/skywire.install
blob: ae29ba942e10f0f3e088d0fb650a4cee7af7d169 (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
post_install() {
  #kill any instance that was running
  systemctl disable --now skywire.service
  systemctl disable --now skywire-visor.service
  #config generation writes in the current dir;
  #so we want to make anything spawned by the process appear as a subdirectory of install dir
  cd /opt/skywire/
  #try to reuse old config
  [[ -f /opt/skywire/skywire.json ]] && cp -b /opt/skywire/skywire.json /opt/skywire/skywire.json.gen
  #generate hypervisor configuration
  skywire-cli visor gen-config --is-hypervisor -p -r -o /opt/skywire/skywire.json.gen
  mv /opt/skywire/skywire.json.gen /opt/skywire/skywire.json
  skywire-tls-gen
  systemctl enable --now skywire.service
  echo "Skywire has been configured, starting now on https://127.0.0.1:8000"
  _lanip=$(ifconfig | grep inet | head -n 1)
  _lanip=${_lanip##*inet }
  _lanip=${_lanip%% *}
  echo "Access from local network at: https://${_lanip}:8000"
  _pubkey=$(cat /opt/skywire/skywire.json | grep pk\")
  _pubkey=${_pubkey#*: }
  echo "Visor Public Key: ${_pubkey}"
  echo "run keypkg-gen to generate the distributable public key package"
}

#pre-upgrade() {
#}

post_upgrade() {
post_install
}

pre-remove() {
  systemctl disable --now skywire.service
  systemctl disable --now skywire-visor.service
}

post_remove() {
rm -rf /opt/skywire
}