## Copyright (C) 2015 Jason Mehring <nrgaway@gmail.com>
## License: GPL-2+

## On Whonix-Workstation AppVMs:
## - replaces IPs using '/usr/lib/qubes-whonix/replace-ips'
## On Whonix-Gateway:
## - does nothing. Calling 'replace-ips' is implemented in package 'anon-gw-anonymizer-config'.

[Unit]
Description=Qubes-Whonix post init
Documentation=https://github.com/Whonix/qubes-whonix

ConditionPathExists=!/run/qubes/this-is-templatevm
ConditionPathExists=/run/qubes/this-is-appvm
ConditionPathExists=/usr/share/anon-ws-base-files/workstation

## So changes to for example,
## - /usr/share/anon-apps-config/kioslaverc or
## - /home/user/.torchat/torchat.ini are applied before these start.
## Not worth it.
##
# [workstation user ~]% qubesdb-read /qubes-gateway
# > 10.137.0.8
##
# [workstation user ~]% curl.anondist-orig --proxy socks5h://10.137.0.8:9050 --output - -- https://check.torproject.org/api/ip
# > {"IsTor":true
##
# [workstation user ~]% curl.anondist-orig --proxy socks5h://10.137.5.5:9050 --output - -- https://check.torproject.org/api/ip
# {"IsTor":true
#Before=qubes-gui-agent.service
## This is thanks to Whonix-Gateway 'vif*' nftables rules.

## Same as above.
#Before=sdwdate.service

## Same as above.
## Does not run on Whonix-Workstation by default.
## Uses 127.0.0.1. Therefore does not rely on any updated IP address in any file.
#Before=canary.service

## Unnecessary. 'anon-ws-disable-stacked-tor.service' detects the IP address itself
## using 'qubesdb-read' and does not rely on any updated IP address in any file.
#Before=anon-ws-disable-stacked-tor.service

After=qubes-sysinit.service

## Probably already implicitly added.
After=local-fs.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/lib/qubes-whonix/init/qubes-whonix-postinit

[Install]
WantedBy=multi-user.target
