apikey, "Apply", "Skip") if not apikey or retcode == 1: break d.infobox("Linking TKLBAM to the TurnKey Hub...") try: getoutput("host -W 2 hub.turnkeylinux.org") except ExecError, e: d.error(CONNECTIVITY_ERROR) break try: getoutput('tklbam-init', apikey) d.msgbox('Success! Linked TKLBAM to Hub', SUCCESS_TKLBAM) initialized_tklbam = True break except ExecError, e: d.msgbox('Failure', e.output) continue if initialized_tklbam: while 1: retcode, fqdn = d.inputbox("Assign TurnKey DNS hostname", TEXT_HUBDNS, fqdn, "Apply", "Skip") if not fqdn or retcode == 1: break
domain = email.split('@')[1] try: d.infobox("Modifying ssmtp configuration files...") # modify conf file /etc/ssmtp/ssmtp.conf config_file = '/etc/ssmtp/ssmtp.conf' getoutput('sed -e "/^root=/ c root=%s" -i %s' % (email, config_file)) getoutput('sed -e "/^AuthUser=/ c AuthUser=%s" -i %s' % (email, config_file)) getoutput('sed -e "/^AuthPass=/ c AuthPass=%s" -i %s' % (passw, config_file)) getoutput('sed -e "/^rewriteDomain=/ c rewriteDomain=%s" -i %s' % (domain, config_file)) getoutput('sed -e "/^hostname=/ c hostname=%s" -i %s' % (email, config_file)) # modify conf file /etc/ssmtp/revaliases config_file = '/etc/ssmtp/revaliases' getoutput('sed -e "/^root:/ c root:%s:smtp.gmail.com:587" -i %s' % (email, config_file)) getoutput('sed -e "/^admin:/ c admin:%s:smtp.gmail.com:587" -i %s' % (email, config_file)) d.infobox("Modifying smtp drupal variables...") # modify drupal variables that are used for sending email m = MySQL() # start mysqld getoutput("/usr/lib/inithooks/bin/gmailsmtp.php '%s' '%s'" % (email, passw)) except ExecError, e: d.msgbox('Failure', e.output) if __name__ == "__main__": main()
apikey, "Apply", "Skip") if not apikey or retcode == 1: break d.infobox("Linking TKLBAM to the TurnKey Hub...") try: getoutput("host -W 2 hub.turnkeylinux.org") except ExecError, e: d.error(CONNECTIVITY_ERROR) break try: getoutput('tklbam-init %s' % apikey) d.msgbox('Success! Linked TKLBAM to Hub', SUCCESS_TKLBAM) initialized_tklbam = True break except ExecError, e: d.msgbox('Failure', e.output) continue if initialized_tklbam: while 1: retcode, fqdn = d.inputbox("Assign TurnKey DNS hostname", TEXT_HUBDNS, fqdn, "Apply", "Skip") if not fqdn or retcode == 1: break
def main(): signal.signal(signal.SIGINT, signal.SIG_IGN) try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'apikey=', 'fqdn=']) except getopt.GetoptError as e: usage(e) apikey = "" fqdn = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--apikey': apikey = val elif opt == '--fqdn': fqdn = val if apikey: system('tklbam-init', apikey) if fqdn: system('hubdns-init', apikey, fqdn) system('hubdns-update') return initialized_tklbam = False d = Dialog('TurnKey GNU/Linux - First boot configuration') while 1: retcode, apikey = d.inputbox("Initialize Hub services", TEXT_SERVICES, apikey, "Apply", "Skip") if not apikey or retcode == 1: break d.infobox("Linking TKLBAM to the TurnKey Hub...") try: check_output(["host", "-W", "2", "hub.turnkeylinux.org"]) except CalledProcessError as e: d.error(CONNECTIVITY_ERROR) break try: check_output(['tklbam-init', apikey]) d.msgbox('Success! Linked TKLBAM to Hub', SUCCESS_TKLBAM) initialized_tklbam = True break except CalledProcessError as e: d.msgbox('Failure', e.output) continue if initialized_tklbam: while 1: retcode, fqdn = d.inputbox("Assign TurnKey DNS hostname", TEXT_HUBDNS, fqdn, "Apply", "Skip") if not fqdn or retcode == 1: break d.infobox("Linking HubDNS to the TurnKey Hub...") try: check_output(['hubdns-init', apikey, fqdn]) check_output(['hubdns-update']) d.msgbox('Success! Assigned %s' % fqdn, SUCCESS_HUBDNS) break except CalledProcessError as e: d.msgbox('Failure', e.output) continue
if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Redis-commander password", "Enter password to access redis-commander UI") if not ip_bind: d = Dialog('TurnKey Linux - First boot configuration') while True: ip_bind = d.get_input("IPv4 Address to access Redis", ("Enter IPv4 Address that will be allowed " "to access the Redis instance."), DEFAULT_BIND) if validate_ip(ip_bind): break d.msgbox("Invalid IPv4 Address", "\"{}\" is not a valid IPv4 address!".format(ip_bind)) if not protected_mode: d = Dialog('TurnKey Linux - First boot configuration') protected_mode = d.yesno('Keep protected-mode enabled?', ( "In this mode Redis only replies to queries from the loopback " "interfaces. Reply to other clients connecting from other addresses " "will receive an error, noting why & how to configure Redis. " "(disabled by-default)"), 'Yes', 'No') protected_mode_string = {True: "yes", False: "no"} conf = "/etc/redis/redis.conf" redis_commander_conf = "/etc/init.d/redis-commander" system("sed -i \"s|^bind .*|bind %s|\" %s" % (ip_bind, conf)) system(""" sed -i \"s|^protected-mode .*|protected-mode %s|\" %s""" %
d = Dialog('TurnKey B-Translator - First boot configuration') if not main_lang: main_lang = d.get_input( "Main translation language of B-Translator", "Please enter the code of the main translation language of your site (something like 'sq' or 'sq_AL'):") if not other_langs: other_langs = d.get_input( "Auxiliary languages of B-Translator", "Please enter the codes of helping (auxiliary) languages, separated by space (like 'fr de it'):") config_file = '/var/www/btranslator_data/config.sh' languages = main_lang + ' ' + other_langs try: getoutput('sed -e "/languages=/d" -i %s' % config_file) getoutput('echo \'languages="%s"\' >> %s' % (languages, config_file)) m = MySQL() # start mysqld vset = "/usr/bin/drush --yes --exact vset %s %s" getoutput(vset % ('l10n_feedback_translation_lng', main_lang)) except ExecError, e: d.msgbox('Failure', e.output) try: file_inc = '/var/www/btranslator/profiles/btranslator/modules/l10n_feedback/includes/common.inc' d.msgbox('Instructions', "Please edit the file '%s' and modify the list of languages appropriately." % file_inc) system('nano --syntax=php +20,5 %s' % file_inc) except ExecError, e: d.msgbox('Failure', e.output) if __name__ == "__main__": main()