julien #3

Merged
julien.escario merged 4 commits from julien into master 3 years ago
  1. 1
      ssh/oxidized.pub
  2. 18
      wireguard/wgportal_peer_install.sh

1
ssh/oxidized.pub

@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDKVHiQwYh8rdWgwAqs5+aNBp6f1gqbUfh9BO+5XG7QigMEYmmawPy9LHwcSADKLuIwaFdfalMYrx90JpNzrDEmvBCep3YlyS1YLRZlLYntSS3G8q70XFPFf84HD9Uh9MAD6qHkZArvhDZ6t0fP2HhqEN8Ud2Dx1qAvn8cdDgjO5zFGNaevQUpVXEcc2lSUkJkzw6F/nH+xJQEd7/a62f8XdcYnzOafLkZwAWR5xCpCbhCIXQ0KEo8+Z5Edc7AvmSFRdc8EC1Upz/LVsR193vNnvm9yTyu5UzhCVVfhNNzNYMX+4NF0MzvG0QlsetGinqzWW0jR8YW5Kcltef2PtaF152P5Pu+mpg3mvxCE9glxjmwegoXhQu6gcxIdUpmcXar2nS9pxnL9LLoZ5kRyXHPpktRSqte2HD8dcgVBqS7AgY9J1hduko9DWkFWiAIM0C0d6702ZXYwFFmnfJcxAFeSbZbvGyjfv0K87/Y2tZNjghZifpzi8+LRgKseoAhE4+8= oxidized@oxidized

18
wireguard/wgportal_peer_install.sh

@ -1,8 +1,7 @@
#!/bin/sh #!/bin/sh
# TODO : # TODO :
# - add root user detection
# - verify curl output to prevent overwriting config file with an HTTP answer
# - add root user detection (only warn)
# - verify trailling slash existenz at the end of the URL param # - verify trailling slash existenz at the end of the URL param
VER=0.1 VER=0.1
@ -139,18 +138,23 @@ _download() {
WGPORTAL_APIURL=$WGPORTAL_URL"api/v1/provisioning/peer" WGPORTAL_APIURL=$WGPORTAL_URL"api/v1/provisioning/peer"
_debug "GET request to $WGPORTAL_APIURL" _debug "GET request to $WGPORTAL_APIURL"
HTTP_STATUS=$(curl -w "%{http_code}" -G -s -o $WG_CONFFILE --user $username:$password --data-urlencode "PublicKey=$wgpubkey" -X GET $WGPORTAL_APIURL -H "accept: text/plain")
HTTP_RESPONSE=$(curl -G -s --write-out "HTTPSTATUS:%{http_code}" --user $username:$password --data-urlencode "PublicKey=$wgpubkey" -X GET $WGPORTAL_APIURL -H "accept: text/plain")
res=$? res=$?
if [ "$res" != "0" ]; then if [ "$res" != "0" ]; then
echo "the curl command failed with: $res" echo "the curl command failed with: $res"
fi fi
if [ $HTTP_STATUS -ne 200 ]; then
printf "Curl returned HTTP code %s\n" "$HTTP_STATUS"
exit 1;
HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed -E 's/HTTPSTATUS\:[0-9]{3}$//')
HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -E 's/.*HTTPSTATUS:([0-9]{3})$/\1/')
if [ $HTTP_STATUS = "200" ]; then
echo "$HTTP_BODY" > $WG_CONFFILE
printf "WG config successfully downloaded at %s\n" "$WG_CONFFILE"
return
fi fi
printf "WG config successfully download at %s\n" "$WG_CONFFILE"
printf "Curl returned HTTP code %s\n" "$HTTP_STATUS"
exit 1;
} }
_install() { _install() {

Loading…
Cancel
Save