#!/usr/bin/python

import re
import glob
import sys
import os

ces_dir = '/install/community-edition-setup'

if not os.path.exists(ces_dir):

    ces_list = glob.glob('/opt/dist/gluu/community-edition-setup*.zip')

    if not ces_list:
        print "community-edition-setup package was not found"
        dl = raw_input("Download from github? (Y/n) ")
        if not dl.strip() or dl.lower()[0]=='y':
            print "Downloading..."
            os.system('wget -nv https://github.com/GluuFederation/community-edition-setup/archive/master.zip -O /opt/dist/gluu/community-edition-setup-master.zip')
            ces_list = glob.glob('/opt/dist/gluu/community-edition-setup*.zip')
        else:
            print "Exiting..."
            sys.exit()

    ces = max(ces_list)

    if not os.path.exists('/install'):
        os.mkdir('/install')

    print "Extracting community-edition-setup package"
    os.system('unzip -q {0} -d /install'.format(ces))
    ces_dir_list = glob.glob('/install/community-edition-setup*')

    if not ces_dir_list:
        print "community-edition-setup package was not extracted properly. Exiting."

    ces_cur_dir = max(ces_dir_list)
    os.rename(ces_cur_dir, ces_dir)

os.system('/install/community-edition-setup/setup.py')

@@ -59,53 +59,708 @@
  os%0A
-%0Aces_dir = '/install/community-edition-setup'
+import argparse%0Aimport time%0A%0Arun_time = time.strftime(%22%25Y-%25m-%25d_%25H-%25M-%25S%22)%0Aces_dir = '/install/community-edition-setup'%0A%0Aparser = argparse.ArgumentParser(description=%22This script extracts community-edition-setup package and runs setup.py without arguments%22)%0Aparser.add_argument('-o', help=%22download latest package from github and override current community-edition-setup%22, action='store_true')%0Aargsp = parser.parse_args()%0A    %0Aif argsp.o:%0A    for cep in glob.glob('/opt/dist/gluu/community-edition-setup*.zip'):%0A        os.remove(cep)%0A    if os.path.exists(ces_dir):%0A        back_dir = ces_dir+'.back.'+run_time%0A        print %22Backing up%22, ces_dir, %22to%22, back_dir%0A        os.rename(ces_dir, back_dir)
 %0A%0Aif
@@ -880,24 +880,52 @@
 t ces_list:%0A
+        if not argsp.o:%0A    
         prin
@@ -982,16 +982,20 @@
         
+   
+ 
 dl = raw
@@ -1033,16 +1033,60 @@
 Y/n) %22)%0A
+        else:%0A            dl = 'y'%0A        %0A
         
@@ -1644,16 +1644,19 @@
 ('unzip 
+-o 
 -q %7B0%7D -
@@ -1745,16 +1745,112 @@
 setup*')
+%0A    %0A    for d in ces_dir_list%5B:%5D:%0A        if '.back.' in d:%0A            ces_dir_list.remove(d)
 %0A%0A    if

add -o option to install.py