From cded819c74e40c2f43c155e19a1f84340c2987a2 Mon Sep 17 00:00:00 2001 From: NeodarZ Date: Thu, 6 Jul 2017 23:20:04 +0200 Subject: Initial commit --- README.md | 50 +++++++++++++++++++++++++++ client_config_archlinux.sh.sample | 71 +++++++++++++++++++++++++++++++++++++++ client_install_archlinux.sh | 4 +++ install_srv.sh | 44 ++++++++++++++++++++++++ server_create.sh | 15 +++++++++ server_install.sh.sample | 23 +++++++++++++ server_remove.sh | 25 ++++++++++++++ 7 files changed, 232 insertions(+) create mode 100644 README.md create mode 100644 client_config_archlinux.sh.sample create mode 100755 client_install_archlinux.sh create mode 100755 install_srv.sh create mode 100755 server_create.sh create mode 100755 server_install.sh.sample create mode 100755 server_remove.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..e196363 --- /dev/null +++ b/README.md @@ -0,0 +1,50 @@ +# EphermalVPN + +EphermalVPN is a simply set of scrits to manage an aphermal vpn for scaleway +provider. + +For the moment you MUST read each script to understand what each script do ! + +This set of scripts use the set of scripts of +[setup-ipsec-vpn](https://github.com/hwdsl2/setup-ipsec-vpn). + +The objectif is to automate the installation and the configuration of a VPN on +the server and on the client. For now the server and the client are configured +to use a IPsec/LTP VPN. + +# Script list + +## install_srv.sh +This script is the first script to lauch, it set the psk key, the user and the +password, create and launch a vpn server and configure the client. + +**NOTE: This script launch the script of configure the client who is on +archlinux ! If your an note on archlinux, edit the script before !** + +## server_instal.sh.sample +This script install and configure the VPN server. For now it just install the +IPsec/LTP VPN via the set of the of +[setup-ipsec-vpn](https://github.com/hwdsl2/setup-ipsec-vpn). No rule of +security is added ! + +**NOTE: The variable `VPN_IPSEC_PSK`, `VPN_USER` and `VPN_PASSWORD` are +modified by the install_srv.sh script !** + +## client_config_archlinux.sh.sample +This script configure the client. You must run `client_install_archlinux.sh` +before for install the required package. And this two script works only with +archlinux. + +## server_remove.sh +This script stop and remove a server. Only this script have some comments if +you don't used correctly. + +Usage exemple: + +```sh +sh remove_server.sh 429ab1dc +``` + +## server_create.sh +This script is an old test script for create a server. But some command are +replaced by the scaleway API. It not used for now. diff --git a/client_config_archlinux.sh.sample b/client_config_archlinux.sh.sample new file mode 100644 index 0000000..13cfe04 --- /dev/null +++ b/client_config_archlinux.sh.sample @@ -0,0 +1,71 @@ +#!/bin/sh +VPN_SERVER_IP='vpn_ip' +VPN_IPSEC_PSK='vpn_psk_key' +VPN_USER='vpn_user' +VPN_PASSWORD='vpn_pass' + +sudo cat > /etc/ipsec.conf < /etc/ipsec.secrets < /etc/xl2tpd/xl2tpd.conf < /etc/ppp/options.l2tpd.client < /root/server_install.sh && chmod +x /root/server_install.sh && sh /root/server_install.sh" + +scw ps -a > /dev/null + +SERVER_IP=$(scw inspect $SERVER_ID | jq '.[0].public_ip.address' | cut -d'"' -f2) + +rm $ROOT/client_config.sh +cp $CLIENT_CONF_FILE $ROOT/client_config.sh +sed -i "s/vpn_ip/$SERVER_IP/g" $ROOT/client_config.sh +sed -i "s/vpn_psk_key/$VPN_PSK_KEY/g" $ROOT/client_config.sh +sed -i "s/vpn_user/$VPN_USER/g" $ROOT/client_config.sh +sed -i "s/vpn_pass/$VPN_PASS/g" $ROOT/client_config.sh + +sudo sh $ROOT/client_config.sh + +rm $ROOT/server_install.sh +rm $ROOT/client_config.sh diff --git a/server_create.sh b/server_create.sh new file mode 100755 index 0000000..19ed7a1 --- /dev/null +++ b/server_create.sh @@ -0,0 +1,15 @@ +#!/bin/sh +ID=$(echo $(scw create --commercial-type=VC1S 5fc9990a-d274-49b8-afac-42af22b42a71) | cut -d'-' -f1) + +echo $ID +scw start $ID +scw attach $ID +while [[ $(scw ps -a | awk "/$ID.*(running).*/") == "" ]]; do + sleep 30 +done +echo "Runnig ! => $(scw ps -a | awk "/$ID.*(running).*/") " + +cat > ip < remove_server.sh [OPTION] SERVER_ID" + echo "The length of SERVER_ID is 1 word of 8 caractere" + echo "Option list" + echo " all Remove all server but not the server id who match with : $SERVER_LIST" +fi + + -- cgit v1.2.1