#!/usr/bin/ensim-python

import sys
import ensimapplpath
import vh3.db.siteinfo as siteinfodb
import traceback

def run(argv):
    try:
        if len(argv) != 2:
            sys.stderr.write('usage: %s on|off\n' % sys.argv[0])
            sys.exit(1)
        if argv[1] == 'on':
            siteinfodb.enable_unique_siteadmins()
            sys.stdout.write('legacy turned on successfully.\n')
        elif argv[1] == 'off':
            siteinfodb.disable_unique_siteadmins()
            sys.stdout.write('legacy turned off successfully.\n')
            sys.stderr.write('please remove all legacy symlinks in /home/virtual and in the site directories\n')
        else:
            sys.stderr.write('usage: %s on|off\n' % argv[0])
            sys.exit(1)
    except SystemExit:
        sys.exit(1)
    except:
        traceback.print_exc(file=sys.stderr)
        sys.exit(1)
    sys.exit(0)

if __name__=='__main__':
    run(sys.argv)
