2017-02-03 19:24:02 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2017-05-23 16:26:01 +00:00
|
|
|
set -ex
|
2017-02-03 19:24:02 +00:00
|
|
|
|
2019-05-17 12:49:29 +00:00
|
|
|
USER_ARGS="{ 'server': '10.0.8.100', 'users': ['desktop', 'user1', 'user2'], 'local_service_ip': '172.16.0.1' }"
|
2017-02-03 19:24:02 +00:00
|
|
|
|
2019-04-26 15:48:28 +00:00
|
|
|
if [ "${DEPLOY}" == "docker" ]
|
2018-03-16 20:38:53 +00:00
|
|
|
then
|
2020-01-13 16:20:40 +00:00
|
|
|
docker run -i -v $(pwd)/config.cfg:/algo/config.cfg -v ~/.ssh:/root/.ssh -v $(pwd)/configs:/algo/configs -e "USER_ARGS=${USER_ARGS}" local/algo /bin/sh -c "chown -R root: /root/.ssh && chmod -R 600 /root/.ssh && source .env/bin/activate && ansible-playbook users.yml -e \"${USER_ARGS}\" -t update-users --skip-tags debug -vvvvv"
|
2018-03-16 20:38:53 +00:00
|
|
|
else
|
2018-08-27 14:05:45 +00:00
|
|
|
ansible-playbook users.yml -e "${USER_ARGS}" -t update-users
|
2018-03-16 20:38:53 +00:00
|
|
|
fi
|
2017-02-03 19:24:02 +00:00
|
|
|
|
2019-03-10 17:16:34 +00:00
|
|
|
#
|
|
|
|
# IPsec
|
|
|
|
#
|
|
|
|
|
2019-04-26 15:48:28 +00:00
|
|
|
if sudo openssl crl -inform pem -noout -text -in configs/10.0.8.100/ipsec/.pki/crl/phone.crt | grep CRL
|
2017-02-03 19:24:02 +00:00
|
|
|
then
|
|
|
|
echo "The CRL check passed"
|
|
|
|
else
|
|
|
|
echo "The CRL check failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-01-13 16:20:40 +00:00
|
|
|
if sudo openssl x509 -inform pem -noout -text -in configs/10.0.8.100/ipsec/.pki/certs/user1.crt | grep -E "CN(=|\s+=\s+)user1"
|
2017-02-03 19:24:02 +00:00
|
|
|
then
|
2017-05-23 16:26:48 +00:00
|
|
|
echo "The new user exists"
|
2017-02-03 19:24:02 +00:00
|
|
|
else
|
|
|
|
echo "The new user does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-03-10 17:16:34 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# WireGuard
|
|
|
|
#
|
|
|
|
|
2019-04-26 15:48:28 +00:00
|
|
|
if sudo test -f configs/10.0.8.100/wireguard/user1.conf
|
2019-03-10 17:16:34 +00:00
|
|
|
then
|
|
|
|
echo "WireGuard: The new user exists"
|
|
|
|
else
|
|
|
|
echo "WireGuard: The new user does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# SSH tunneling
|
|
|
|
#
|
|
|
|
|
2019-04-26 15:48:28 +00:00
|
|
|
if sudo test -f configs/10.0.8.100/ssh-tunnel/user1.ssh_config
|
2019-03-10 17:16:34 +00:00
|
|
|
then
|
|
|
|
echo "SSH Tunneling: The new user exists"
|
|
|
|
else
|
|
|
|
echo "SSH Tunneling: The new user does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|