post_install() { systemctl disable --now skywire-hypervisor.service systemctl disable --now skywire-visor.service skywire-halt skywire-cli visor gen-config -ro /etc/skywire-visor.json if pacman -Qi hypervisorconfig > /dev/null ; then local hvisorkey=$(cat /usr/lib/skycoin/skywire/hypervisor.txt) echo "Setting hypervisor key to $hvisorkey" else skywire-hypervisor gen-config -ro /etc/skywire-hypervisor.json local hvisorkey=$(cat /etc/skywire-hypervisor.json | grep "public_key" | awk '{print substr($2,2,66)}') echo "Setting hypervisor key to $hvisorkey" #setting key and cert in hypervisor config file sed -i 's+"enable_tls": false,+"enable_tls": true,+g' /etc/skywire-hypervisor.json sed -i 's+"tls_cert_file": "",+"tls_cert_file": "/etc/skywire-hypervisor/cert.pem",+g' /etc/skywire-hypervisor.json sed -i 's+"tls_key_file": ""+"tls_key_file": "/etc/skywire-hypervisor/key.pem"+g' /etc/skywire-hypervisor.json echo "Starting hypervisor on 127.0.0.1:8000" systemctl enable --now skywire-hypervisor.service fi sed -i 's/"hypervisors".*/"hypervisors": [{"public_key": "'"${hvisorkey}"'"}],/' /etc/skywire-visor.json ISO_USER="$(cat /etc/passwd | grep "/home" |cut -d: -f1 |head -1)" su -c "rm -rf ~/.cache/yay/hypervisorconfig/" $ISO_USER su -c "mkdir -p ~/.cache/yay/hypervisorconfig" $ISO_USER su -c "cp -b /usr/lib/skycoin/skywire/hypervisorconfig/PKGBUILD ~/.cache/yay/hypervisorconfig/PKGBUILD" $ISO_USER su -c "echo $hvisorkey > ~/.cache/yay/hypervisorconfig/hypervisor.txt" $ISO_USER su -c "cd ~/.cache/yay/hypervisorconfig/ && makepkg -f" $ISO_USER cp -b /home/$ISO_USER/.cache/yay/hypervisorconfig/*.pkg.tar.* /usr/lib/skycoin/skywire/ echo "Starting visor" systemctl enable --now skywire-visor.service #if pacman -Qi readonly-cache > /dev/null ; then # systemctl enable --now readonly-cache.service #fi } pre-upgrade() { systemctl disable --now skywire-hypervisor.service systemctl disable --now skywire-visor.service skywire-halt } post_upgrade() { post_install } pre-remove() { systemctl disable --now skywire-hypervisor.service systemctl disable --now skywire-visor.service skywire-halt } post_remove() { rm -rf /etc/skywire-hypervisor.json /etc/skywire-visor.json /usr/lib/skycoin/skywire }