Merge branch '1.5' into 2.0

This commit is contained in:
Julien Duponchelle committed 2016-04-08 17:40:27 +02:00
commit 9e8fcab65c
34 files changed
+895 -188

No files matched your search

+60 -41
View File
@@ -24,6 +24,8 @@
function help {
echo "Usage:" >&2
echo "--with-openvpn: Install Open VPN" >&2
echo "--with-iou: Install IOU" >&2
echo "--with-i386-repository: Add i386 repositories require by IOU if they are not available on the system. Warning this will replace your source.list in order to use official ubuntu mirror" >&2
echo "--help: This help" >&2
}
@@ -42,8 +44,10 @@ fi
# Read the options
USE_VPN=0
USE_IOU=0
I386_REPO=0
TEMP=`getopt -o h --long with-openvpn,help -n 'gns3-remote-install.sh' -- "$@"`
TEMP=`getopt -o h --long with-openvpn,with-iou,with-i386-repository,help -n 'gns3-remote-install.sh' -- "$@"`
if [ $? != 0 ]
then
help
@@ -58,6 +62,14 @@ while true ; do
USE_VPN=1
shift
;;
--with-iou)
USE_IOU=1
shift
;;
--with-i386-repository)
I386_REPO=1
shift
;;
-h|--help)
help
exit 1
@@ -73,17 +85,31 @@ set -e
export DEBIAN_FRONTEND="noninteractive"
log "Add GNS3 repository"
cat > /etc/apt/sources.list.d/gns3.list << EOF
cat <<EOFLIST > /etc/apt/sources.list.d/gns3.list
deb http://ppa.launchpad.net/gns3/ppa/ubuntu trusty main
deb-src http://ppa.launchpad.net/gns3/ppa/ubuntu trusty main
deb http://ppa.launchpad.net/gns3/qemu/ubuntu trusty main
deb-src http://ppa.launchpad.net/gns3/qemu/ubuntu trusty main
EOF
EOFLIST
if [ $I386_REPO == 1 ]
then
cat <<EOFLIST2 >> /etc/apt/sources.list
###### Ubuntu Main Repos
deb http://archive.ubuntu.com/ubuntu/ trusty main universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty main universe multiverse
###### Ubuntu Update Repos
deb http://archive.ubuntu.com/ubuntu/ trusty-security main universe multiverse
deb http://archive.ubuntu.com/ubuntu/ trusty-updates main universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-security main universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ trusty-updates main universe multiverse
EOFLIST2
fi
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A2E3EF7B
log "Update system packages"
dpkg --add-architecture i386
apt-get update
log "Upgrade packages"
@@ -107,53 +133,46 @@ 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"
dpkg --add-architecture i386
apt-get update
# Force the host name to gns3vm
hostnamectl set-hostname gns3vm
apt-get install -y gns3-iou
# Force hostid for IOU
dd if=/dev/zero bs=4 count=1 of=/etc/hostid
# Force the host name to gns3vm
hostnamectl set-hostname gns3vm
# Block iou call. The server is down
echo "127.0.0.254 xml.cisco.com" | tee --append /etc/hosts
# 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
fi
log "Add gns3 to the kvm group"
usermod -aG kvm gns3
log "Setup VDE network"
apt-get install -y vde2 uml-utilities
usermod -a -G vde2-net gns3
cat <<EOF > /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"
#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
port = 3080
images_path = /opt/gns3/images
projects_path = /opt/gns3/projects
report_errors = True
[Qemu]
enable_kvm = True
EOF
EOFC
cat <<EOF > /etc/init/gns3.conf
chown -R gns3:gns3 /etc/gns3
chmod -R 700 /etc/gns3
cat <<EOFI > /etc/init/gns3.conf
description "GNS3 server"
author "GNS3 Team"
@@ -175,7 +194,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
@@ -193,17 +212,17 @@ 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
port = 3080
images_path = /opt/gns3/images
projects_path = /opt/gns3/projects
report_errors = True
[Qemu]
enable_kvm = True
EOF
EOFSERVER
log "Install packages for Open VPN"
@@ -221,7 +240,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 "_______________________________________________________________________________________________"
@@ -232,7 +251,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
@@ -250,7 +269,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
@@ -302,7 +321,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