Skip to content

Commit

Permalink
Add IOU support and install config in /etc
Browse files Browse the repository at this point in the history
  • Loading branch information
julien-duponchelle committed Mar 25, 2016
1 parent 3fe8016 commit c15e38c
Showing 1 changed file with 35 additions and 23 deletions.
58 changes: 35 additions & 23 deletions scripts/remote-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
function help {
echo "Usage:" >&2
echo "--with-openvpn: Install Open VPN" >&2
echo "--with-iou: Install IOU" >&2
echo "--help: This help" >&2
}

Expand All @@ -42,8 +43,9 @@ fi

# Read the options
USE_VPN=0
USE_IOU=0

TEMP=`getopt -o h --long with-openvpn,help -n 'gns3-remote-install.sh' -- "$@"`
TEMP=`getopt -o h --long with-openvpn,with-iou,help -n 'gns3-remote-install.sh' -- "$@"`
if [ $? != 0 ]
then
help
Expand All @@ -58,6 +60,10 @@ while true ; do
USE_VPN=1
shift
;;
--with-iou)
USE_IOU=1
shift
;;
-h|--help)
help
exit 1
Expand Down Expand Up @@ -107,17 +113,20 @@ fi
log "Add GNS3 to the docker group"
usermod -aG docker gns3

log "IOU setup"
#apt-get install -y gns3-iou
if [ $USE_IOU == 1 ]
then
log "IOU setup"
apt-get install -y gns3-iou

# Force the host name to gns3vm
hostnamectl set-hostname gns3vm
# Force the host name to gns3vm
hostnamectl set-hostname gns3vm

# Force hostid for IOU
dd if=/dev/zero bs=4 count=1 of=/etc/hostid
# Force hostid for IOU
dd if=/dev/zero bs=4 count=1 of=/etc/hostid

# Block iou call. The server is down
echo "127.0.0.254 xml.cisco.com" | tee --append /etc/hosts
# Block iou call. The server is down
echo "127.0.0.254 xml.cisco.com" | tee --append /etc/hosts
fi

log "Add gns3 to the kvm group"
usermod -aG kvm gns3
Expand All @@ -128,20 +137,20 @@ apt-get install -y vde2 uml-utilities

usermod -a -G vde2-net gns3

cat <<EOF > /etc/network/interfaces.d/qemu0.conf
cat <<EOFV > /etc/network/interfaces.d/qemu0.conf
# A vde network
auto qemu0
iface qemu0 inet static
address 172.16.0.1
netmask 255.255.255.0
vde2-switch -t qemu0
EOF
log "Setup GNS3 server"
EOFV

log "Setup GNS3 server"

#TODO: 1.4.5 allow /etc/gns3/gns3_server.conf it's cleaner
cat <<EOF > /opt/gns3/gns3_server.conf
mkdir -p /etc/gns3
cat <<EOFC > /etc/gns3/gns3_server.conf
[Server]
host = 0.0.0.0
port = 8000
Expand All @@ -151,9 +160,12 @@ report_errors = True
[Qemu]
enable_kvm = True
EOF
EOFC

chown -R gns3:gns3 /etc/gns3
chmod -R 700 /etc/gns3

cat <<EOF > /etc/init/gns3.conf
cat <<EOFI > /etc/init/gns3.conf
description "GNS3 server"
author "GNS3 Team"
Expand All @@ -175,7 +187,7 @@ end script
pre-stop script
echo "[`date`] GNS3 Stopping"
end script
EOF
EOFI

chown root:root /etc/init/gns3.conf
chmod 644 /etc/init/gns3.conf
Expand All @@ -193,7 +205,7 @@ if [ $USE_VPN == 1 ]
then
log "Setup VPN"

cat <<EOF > /opt/gns3/gns3_server.conf
cat <<EOFSERVER > /etc/gns3/gns3_server.conf
[Server]
host = 172.16.253.1
port = 8000
Expand All @@ -203,7 +215,7 @@ report_errors = True
[Qemu]
enable_kvm = True
EOF
EOFSERVER

log "Install packages for Open VPN"

Expand All @@ -221,7 +233,7 @@ UUID=$(uuid)

log "Update motd"

cat <<EOF > /etc/update-motd.d/70-openvpn
cat <<EOFMOTD > /etc/update-motd.d/70-openvpn
#!/bin/sh
echo ""
echo "_______________________________________________________________________________________________"
Expand All @@ -232,7 +244,7 @@ echo "And add it to your openvpn client."
echo ""
echo "apt-get remove nginx-light to disable the HTTP server."
echo "And remove this file with rm /etc/update-motd.d/70-openvpn"
EOF
EOFMOTD
chmod 755 /etc/update-motd.d/70-openvpn


Expand All @@ -250,7 +262,7 @@ chmod 600 /etc/openvpn/key.pem
[ -f /etc/openvpn/cert.pem ] || openssl x509 -req -in /etc/openvpn/csr.pem -out /etc/openvpn/cert.pem -signkey /etc/openvpn/key.pem -days 24855

log "Create client configuration"
cat <<EOF > /root/client.ovpn
cat <<EOFCLIENT > /root/client.ovpn
client
nobind
comp-lzo
Expand Down Expand Up @@ -302,7 +314,7 @@ server {
listen 8003;
root /usr/share/nginx/openvpn;
}
EOF
EOFCLIENT
[ -f /etc/nginx/sites-enabled/openvpn ] || ln -s /etc/nginx/sites-available/openvpn /etc/nginx/sites-enabled/
service nginx stop
service nginx start
Expand Down

0 comments on commit c15e38c

Please sign in to comment.