def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=', 'domain=']) except getopt.GetoptError as e: usage(e) password = "" email = "" domain = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Foswiki Password", "Enter new password for the Foswiki 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Foswiki Email", "Enter email address for the Foswiki 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) if not domain: if 'd' not in locals(): d = Dialog('Turnkey Linux - First boot configuration') domain = d.get_input("Foswiki Domain", "Enter the domain to serve Foswiki.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) if not (domain.startswith('http://') or domain.startswith('https://')): domain = 'https://' + domain check_output([ 'perl', '-CA', '/var/www/foswiki/tools/configure', '-save', '-set', '{Password}=%s' % password, '-set', '{WebMasterEmail}=%s' % email, '-set', '{DefaultUrlHost}=%s' % domain ])
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=', 'domain=']) except getopt.GetoptError as e: usage(e) email = "" domain = "" password = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "PHPlist Password", "Enter new password for the PHPlist 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "PHPlist Email", "Enter email address for the PHPlist 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input( "PHPlist Domain", "Enter the domain to serve PHPlist.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) m = MySQL() m.execute('UPDATE phplist.admin SET password=%s WHERE loginname=\"admin\";', (password,)) m.execute('UPDATE phplist.admin SET email=%s WHERE loginname=\"admin\";', (email,)) m.execute('UPDATE phplist.config SET value=%s WHERE item=\"website\";', (domain,))
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=']) except getopt.GetoptError as e: usage(e) password = "" email = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Foodsoft Password", "Enter new password for the Foodsoft 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Foodsoft Email", "Enter email address for the Foodsoft 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) print("Please wait ...") # need mysql running for these updates popen('service mysql status >/dev/null || service mysql start').wait() # initialize admin account from Rails console runner_script = """ " u = User.where(id: 1).first; u.password = '******'; u.email = '%s'; u.save! " """ % (password, email) popen("bundle exec rails r %s" % runner_script).wait() # running as root may have cached classes popen('chown -R www-data:www-data tmp/').wait() popen('systemctl restart apache2')
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=']) except getopt.GetoptError as e: usage(e) password = "" email = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Redmine Password", "Enter new password for the Redmine 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Redmine Email", "Enter email address for the Redmine 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) salt = "".join(random.choice(string.ascii_letters) for line in range(16)) pw_with_salt = salt + hashlib.sha1(password.encode('utf-8')).hexdigest() hashpass = hashlib.sha1(pw_with_salt.encode('utf-8')).hexdigest() user_id = 1 m = MySQL() m.execute( 'UPDATE redmine_production.email_addresses SET address=\"%s\" WHERE user_id=%i;' % (email, user_id)) m.execute( 'UPDATE redmine_production.users SET salt=\"%s\" WHERE login=\"admin\" AND id=%i;' % (salt, user_id)) m.execute( 'UPDATE redmine_production.users SET hashed_password=\"%s\" WHERE login=\"admin\" AND id = %i;' % (hashpass, user_id))
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=']) except getopt.GetoptError as e: usage(e) password = "" email = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Joomla Password", "Enter new password for the Joomla 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Joomla Email", "Enter email address for the Joomla 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) salt_chars = string.ascii_letters + string.digits salt = "".join(random.choice(salt_chars) for c in range(32)) cryptpass = "******" % (hashlib.md5( (password + salt).encode('utf8')).hexdigest(), salt) m = MySQL() m.execute('UPDATE joomla.jos_users SET email=%s WHERE username=\"admin\";', (email, )) m.execute( 'UPDATE joomla.jos_users SET password=%s WHERE username=\"admin\";', (cryptpass, ))
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=']) except getopt.GetoptError as e: usage(e) email = "" password = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "GNU social Password", "Enter new password for the GNU Social 'administrator' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "GNU social Email", "Please enter email address for the GNU Social 'administrator' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) hashpass = crypt.crypt(password, crypt.METHOD_SHA512) m = MySQL() m.execute( 'UPDATE gnusocial.user SET email=%s WHERE nickname=\"administrator\";', (email, )) m.execute( 'UPDATE gnusocial.user SET password=%s WHERE nickname=\"administrator\";', (hashpass, ))
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=']) except getopt.GetoptError as e: usage(e) email = "" password = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Bagisto Password", "Enter new password for the Bagisto 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Bagisto Email", "Enter email address for the Bagisto 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) salt = bcrypt.gensalt() hashpass = bcrypt.hashpw(password.encode('utf8'), salt).decode('utf8') m = MySQL() m.execute('UPDATE bagisto.admins SET password=%s WHERE id=1;', (hashpass, )) m.execute('UPDATE bagisto.admins SET email=%s WHERE id=1;', (email, ))
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=']) except getopt.GetoptError as e: usage(e) password = "" email = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Wordpress Password", "Enter new password for the Wordpress 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Wordpress Email", "Please enter email address for the Wordpress 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) hashpass = hashlib.md5(password.encode('utf8')).hexdigest() m = MySQL() m.execute('UPDATE wordpress.wp_users SET user_email=\"%s\" WHERE user_nicename=\"admin\";' % email) m.execute('UPDATE wordpress.wp_users SET user_pass=\"%s\" WHERE user_nicename=\"admin\";' % hashpass)
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'domain=']) except getopt.GetoptError as e: usage(e) domain = "" password = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "OpenLDAP Password", "Enter new password for the OpenLDAP 'admin' account.") if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input("OpenLDAP Domain", "Enter the OpenLDAP domain.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) script = os.path.join(os.path.dirname(__file__), 'openldap-reinit.sh') subprocess.check_output([script, domain, password])
elif opt == "--email": email = val elif opt == "--domain": domain = val if not password: d = Dialog("TurnKey Linux - First boot configuration") password = d.get_password("GitLab Password", "Enter new password for the GitLab 'admin' account.") if not email: if "d" not in locals(): d = Dialog("TurnKey Linux - First boot configuration") email = d.get_email("GitLab Email", "Enter email address for the GitLab 'admin' account.", "*****@*****.**") inithooks_cache.write("APP_EMAIL", email) if not domain: if "d" not in locals(): d = Dialog("TurnKey Linux - First boot configuration") domain = d.get_input("GitLab Domain", "Enter the domain to serve GitLab.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write("APP_DOMAIN", domain) system_gitlab( """echo '\ conf.return_format = ""; \
email = "" for opt, val in opts: if opt in ("-h", "--help"): usage() elif opt == "--pass": password = val elif opt == "--email": email = val if not email: d = Dialog("TurnKey Linux - First boot configuration") email = d.get_email( "Bugzilla Email", "Enter email address for the Bugzilla 'admin' account.", "*****@*****.**" ) inithooks_cache.write("APP_EMAIL", email) if not password: if "d" not in locals(): d = Dialog("TurnKey Linux - First boot configuration") password = d.get_password("Bugzilla Password", "Enter new password for the Bugzilla '%s' account." % email) command = [join(dirname(__file__), "bz_crypt.pl"), password] p = subprocess.Popen(command, stdin=PIPE, stdout=PIPE, shell=False) stdout, stderr = p.communicate() if stderr: fatal(stderr) cryptpass = stdout.strip()
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=', 'domain=']) except getopt.GetoptError as e: usage(e) email = "" domain = "" password = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Canvas Password", "Enter new password for the Canvas 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Canvas Email", "Enter email address for the Canvas 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input("Canvas Domain", "Enter the domain to serve Canvas.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) salt = "".join(random.choice(string.ascii_letters) for line in range(20)) hash = password + salt for i in range(20): hash = hashlib.sha512(hash.encode('utf-8')).hexdigest() access_token = "".join( random.choice(string.ascii_letters) for line in range(20)) conn = psycopg2.connect("dbname=canvas_production user=root") c = conn.cursor() c.execute('UPDATE users SET name=%s, sortable_name=%s WHERE id=1;', (email, email)) c.execute( 'UPDATE pseudonyms SET unique_id=%s, crypted_password=%s, password_salt=%s, single_access_token=%s WHERE user_id=1;', (email, hash, salt, access_token)) c.execute('UPDATE communication_channels SET path=%s WHERE id=1;', (email, )) conn.commit() c.close() conn.close() config = "/var/www/canvas/config/outgoing_mail.yml" subprocess.run( ["sed", "-ri", 's|domain:.*|domain: "%s"|' % domain, config]) subprocess.run([ "sed", "-ri", 's|outgoing_address:.*|outgoing_address: "%s"|' % email, config ]) config = "/var/www/canvas/config/dynamic_settings.yml" subprocess.run( ["sed", "-ri", 's|app-host:.*|app-host: "%s:3000"|' % domain, config]) config = "/var/www/canvas/config/domain.yml" subprocess.run( ["sed", "-ri", 's|domain:.*|domain: "%s"|' % domain, config]) config = "/var/www/canvas/config/initializers/outgoing_mail.rb" subprocess.run( ["sed", "-ri", 's|:domain => .*|:domain => "%s",|' % domain, config]) print("Restarting services; please wait...") for service in ['canvas_init', 'apache2']: subprocess.run(['systemctl', 'restart', service])
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=', 'domain=']) except getopt.GetoptError as e: usage(e) password = "" email = "" domain = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "AVideo Password", "Enter new password for the AVideo 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "AVideo Email", "Please enter email address for the AVideo 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input( "AVideo Domain", "Please enter the Domain or IP address for AVideo.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) apache_conf = "/etc/apache2/sites-available/avideo.conf" subprocess.run(["sed", "-i", "0,\|RewriteRule|! {\|RewriteRule|s|https://.*|https://%s/\$1 [R,L]|}" % domain, apache_conf]) subprocess.run(["sed", "-i", "\|RewriteCond|s|!^.*|!^%s$|" % domain, apache_conf]) hashpass = hashlib.md5(password.encode('utf8')).hexdigest() m = MySQL() m.execute('UPDATE avideo.configurations SET contactEmail=%s WHERE users_id="1";', (email,)) m.execute('UPDATE avideo.users SET email=%s WHERE user="******";', (email,)) m.execute('UPDATE avideo.users SET password=%s WHERE user="******";', (hashpass,)) """Set password details in AVideo-Encoder Database (Clear and Encrypted)""" m.execute('UPDATE avideo_encoder.streamers SET pass=%s WHERE id=1;', (password,)) m.execute('UPDATE avideo_encoder.streamers SET pass=%s WHERE id=2;', (hashpass,)) domain = domain + '/' url = 'https://' + domain enc = url + 'encoder/' """Set Streamer Site Configuration in Encoder""" m.execute('UPDATE avideo_encoder.streamers SET siteURL=%s WHERE id=1;', (url,)) m.execute('UPDATE avideo_encoder.streamers SET siteURL=%s WHERE id=2;', (url,)) """Configure AVideo To Use Local Encoder""" m.execute('UPDATE avideo.configurations SET encoderURL=%s WHERE id=1;', (enc,)) """Lock Down Encoder To Specified Streamer Domain""" m.execute('UPDATE avideo_encoder.configurations SET allowedStreamersURL=%s WHERE id=1;', (url,)) """Replace URL in Config Files""" conf_path = '/var/www/{}/videos/configuration.php' for _config, _url in ( (conf_path.format('avideo'), url), (conf_path.format('avideo-encoder'), enc)): with open(_config, 'r') as fob: lines = [] for line in fob.readlines(): if "$global['webSiteRootURL'] = 'http" in line: line = line.split('=') url_prt = line[1].split("'") url_prt[1] = _url line[1] = "'".join(url_prt) line = '='.join(line) lines.append(line) with open(_config, 'w') as fob: fob.writelines(lines) """Restart Apache""" subprocess.run(['systemctl', 'restart', 'apache2.service']) """Restart nginx""" subprocess.run(['systemctl', 'restart', 'nginx.service'])
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=', 'domain=']) except getopt.GetoptError as e: usage(e) email = "" domain = "" password = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val elif opt == '--domain': domain = val elif opt == '--schema': schema = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "GitLab Password", "Enter new password for the GitLab 'root' account.", pass_req=8) if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "GitLab Email", "Enter email address for the GitLab 'root' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input("GitLab Domain", "Enter the domain to serve GitLab.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) print("Reconfiguring GitLab. This might take a while. Please wait.") config = "/etc/gitlab/gitlab.rb" domain = "http://%s" % domain subprocess.run( ["sed", "-i", "/^external_url/ s|'.*|'%s'|" % domain, config]) subprocess.run([ "sed", "-i", "/^gitlab_rails\['gitlab_email_from'\]/ s|=.*|= '%s'|" % email, config ]) subprocess.run(["gitlab-ctl", "reconfigure"]) print( "Setting GitLab 'root' user password and email in database. This might take a while too. Please wait (again)." ) tmp_dir = '/run/user/0' tmp_file = '.gitlab-init.rb' if not os.path.exists(tmp_dir): os.makedirs(tmp_dir) tmp_path = '/'.join([tmp_dir, tmp_file]) # include token resetting here now (just before 'exit'); should fix #1315/#1342 for good! tmp_contents = """ ActiveRecord::Base.logger.level = 1 u = User.where(id: 1).first u.password = u.password_confirmation = '{}' u.email = '{}' u.skip_reconfirmation! u.save! ApplicationSetting.current.reset_runners_registration_token! exit """ flags = os.O_WRONLY | os.O_CREAT with os.fdopen(os.open(tmp_path, flags, 0o600), 'w') as fob: fob.write(tmp_contents.format(password, email)) uid = pwd.getpwnam('git').pw_uid os.chown(tmp_path, uid, 0) try: subprocess.run( ["gitlab-rails", "runner", "-e", "production", tmp_path]) print("Done.") finally: os.remove(tmp_path)
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=', 'domain=']) except getopt.GetoptError as e: usage(e) password = "" email = "" domain = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Mattermost Admin Password", "Enter new password for Mattermost 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Mattermost Administrator's Email", "Enter email address for Mattermost 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input("Mattermost domain", "Enter domain to serve Mattermost", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) if not domain.startswith('https://') and not domain.startswith('http://'): domain = 'https://' + domain subprocess.run([ 'sed', '-i', "/SiteURL/ s|\":.*|\": \\\"%s\\\",|" % domain, '/opt/mattermost/config/config.json' ]) salt = bcrypt.gensalt() hashpass = bcrypt.hashpw(password.encode('utf8'), salt).decode('utf8') p = PostgreSQL(database='mattermost') p.execute( ("UPDATE users SET password='******', email='%s' WHERE username='******';" % (hashpass, email)).encode('utf8'))
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=', 'domain=']) except getopt.GetoptError as e: usage(e) password = "" email = "" domain = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "OpenCart Password", "Enter new password for the OpenCart 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "OpenCart Email", "Enter email address for the OpenCart 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input( "OpenCart domain", "Enter domain to serve OpenCart", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) def php_uniqid(prefix=''): return prefix + hex(int(time.time()))[2:10] + hex(int(time.time() * 1000000) % 0x100000)[2:7] subprocess.run(["sed", "-ri", "s|('HTTP(S?)_SERVER',) '.*'|\\1 'http\\L\\2://%s/'|g" % domain, "/var/www/opencart/config.php"]) subprocess.run(["sed", "-ri", "s|('HTTP(S?)_SERVER',) '.*'|\\1 'http\\L\\2://%s/admin/'|g" % domain, "/var/www/opencart/admin/config.php"]) subprocess.run(["sed", "-ri", "s|('HTTP(S?)_CATALOG',) '.*'|\\1 'http\\L\\2://%s/'|g" % domain, "/var/www/opencart/admin/config.php"]) salt = hashlib.md5(php_uniqid(str(randint(100000000, 999999999))).encode('utf8')).hexdigest()[:9] apache_conf = "/etc/apache2/sites-available/opencart.conf" subprocess.run(["sed", "-i", "\|RewriteRule|s|https://.*|https://%s/\$1 [R,L]|" % domain, apache_conf]) subprocess.run(["sed", "-i", "\|RewriteCond|s|!^.*|!^%s$|" % domain, apache_conf]) subprocess.run(["service", "apache2", "restart"]) password_hash = hashlib.sha1(password.encode('utf8')).hexdigest() password_hash = hashlib.sha1((salt + password_hash).encode('utf8')).hexdigest() password_hash = hashlib.sha1((salt + password_hash).encode('utf8')).hexdigest() m = MySQL() m.execute('UPDATE opencart.oc_user SET email=%s WHERE username="******"', (email,)) m.execute('UPDATE opencart.oc_user SET password=%s WHERE username="******"', (password_hash,)) m.execute('UPDATE opencart.oc_user SET salt=%s WHERE username="******"', (salt,))
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'domain=']) except getopt.GetoptError as e: usage(e) domain = '' password = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--domain': domain = val if not password: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "EspoCRM password", "Enter new password for the EspoCRM 'admin' account.") if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input("EspoCRM Domain", "Enter the domain to serve EspoCRM.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) conf = "/var/www/espocrm/data/config.php" lines = [] with open(conf, 'r') as fob: for line in fob: match = re.search("'passwordSalt' => '([^']*)',", line) if match != None: normSalt = ('$6$%s$' % match.group(1)) hashed = crypt.crypt( hashlib.md5(password.encode('utf8')).hexdigest(), normSalt).replace(normSalt, '') m = MySQL() m.execute( 'UPDATE espocrm.user SET password=%s WHERE user_name=\"admin\"', (hashed)) if 'siteUrl' in line: line = re.sub("=> '([^']*)'", f"=> 'https://{domain}'", line) lines.append(line) with open(conf, 'w') as fob: fob.writelines(lines)
password = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "OpenLDAP Password", "Enter new password for the OpenLDAP 'admin' account.") if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input( "OpenLDAP Domain", "Enter the OpenLDAP domain.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) script = os.path.join(os.path.dirname(__file__), 'openldap-reinit.sh') system(script, domain, password) if __name__ == "__main__": main()
def save_domain(domain): ''' Saves domain configuration ''' inithooks_cache.write('APP_DOMAIN', domain)
usage() elif opt == '--pass': password = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "OpenLDAP Password", "Enter new password for the OpenLDAP 'admin' account.") if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input("OpenLDAP Domain", "Enter the OpenLDAP domain.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) script = os.path.join(os.path.dirname(__file__), 'openldap-reinit.sh') system(script, domain, password) if __name__ == "__main__": main()
if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "TomatoCart Password", "Enter new password for the 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email("TomatoCart Email", "Enter email address for the 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) salt = ''.join( (random.choice(string.letters + string.digits) for x in range(2))) hash = ':'.join([hashlib.md5(salt + password).hexdigest(), salt]) m = MySQL() m.execute( 'UPDATE tomatocart.administrators SET user_password=\"%s\",email_address=\"%s\" WHERE user_name=\"admin\";' % (hash, email)) m.execute( 'UPDATE tomatocart.configuration SET configuration_value=\"%s\" WHERE configuration_key=\"STORE_OWNER_EMAIL_ADDRESS\";' % email) m.execute(
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=', 'domain=']) except getopt.GetoptError as e: usage(e) email = "" domain = "" password = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Elgg Password", "Enter new password for the Elgg 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Elgg Email", "Enter email address for the Elgg 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input( "Elgg Domain", "Enter the domain to serve Elgg. Note: Elgg does not support http without further configuration, domain will default to https.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN fqdn = re.compile(r"https?://") fqdn = fqdn.sub('', domain).strip('/') domain = ("https://%s/" % fqdn) inithooks_cache.write('APP_DOMAIN', fqdn) salt = bcrypt.gensalt(10) hashpass = bcrypt.hashpw(password.encode('utf8'), salt) m = MySQL() try: with m.connection.cursor() as cursor: cursor.execute( 'SELECT guid FROM elgg.elgg_entities WHERE type="user" AND owner_guid="0"' ) admin_guid = cursor.fetchone()['guid'] cursor.execute( 'SELECT name FROM elgg.elgg_metadata WHERE entity_guid=%s', (admin_guid, )) assert (cursor.fetchone()['name']) # sanity check, if this fails, look at the database. You'll probably need to update # all of this database stuff cursor.execute( 'UPDATE elgg.elgg_metadata SET value=%s WHERE entity_guid=%s AND name="password_hash"', ( hashpass, admin_guid, )) cursor.execute( 'UPDATE elgg.elgg_metadata SET value=%s WHERE entity_guid=%s AND name="email"', ( email, admin_guid, )) cursor.execute( 'UPDATE elgg.elgg_metadata SET value=%s WHERE entity_guid=1 AND name="email"', (email, )) m.connection.commit() finally: m.connection.close() with open('/etc/cron.d/elgg', 'r') as fob: contents = fob.read() contents = re.sub("ELGG='.*'", "ELGG='%s'" % domain, contents) with open('/etc/cron.d/elgg', 'w') as fob: fob.write(contents) elgg_conf = "/var/www/elgg/elgg-config/settings.php" subprocess.run([ "sed", "-i", '\|^\$CONFIG->wwwroot|s|=.*|= "%s";|' % domain.strip('/'), elgg_conf ]) apache_conf = "/etc/apache2/sites-available/elgg.conf" subprocess.run([ "sed", "-i", "\|RewriteRule|s|https://.*|https://%s/\$1 [R,L]|" % fqdn, apache_conf ]) subprocess.run( ["sed", "-i", "\|RewriteCond|s|!^.*|!^%s$|" % fqdn, apache_conf]) subprocess.run(["service", "apache2", "restart"])
def seed_apply(iface, addr, nmask, gateway, nservers): inithooks_cache.write('APP_STATIC_IP', json.dumps({'interface':iface, 'address':addr, 'netmask':nmask, 'gateway':gateway, 'nameservers':nservers}))
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=', 'domain=']) except getopt.GetoptError as e: usage(e) email = "" domain = "" password = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Gitea Password", "Enter new password for the Gitea 'admin' account.", pass_req=8, min_complexity=4) if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Gitea Email", "Enter email address for the Gitea 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input("Gitea Domain", "Enter the domain to serve Gitea.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) config = "/etc/gitea/app.ini" subprocess.run([ "su", "git", "-c", "cd /home/git && ./gitea admin change-password -u gitea -p %s" % password ]) subprocess.run(['sed', '-i', "\|DOMAIN|s|=.*|= %s|" % domain, config]) subprocess.run( ['sed', '-i', "\|ROOT_URL|s|=.*|= https://%s/|" % domain, config]) subprocess.run(['sed', '-i', "\|FROM|s|=.*|= %s|" % email, config]) m = MySQL() m.execute("UPDATE gitea.user SET email='%s' WHERE id=1;" % (email, )) subprocess.run(["systemctl", "restart", "gitea"])
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", [ 'help', 'profile=', 'key-email=', 'public-address=', 'virtual-subnet=', 'private-subnet=' ]) except getopt.GetoptError as e: usage(e) profile = "" key_email = "" public_address = "" virtual_subnet = "" private_subnet = "" redirect_client_gateway = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--profile': profile = val elif opt == '--key-email': key_email = val elif opt == '--public-address': public_address = val elif opt == '--virtual-subnet': virtual_subnet = val elif opt == '--private-subnet': private_subnet = val dialog = Dialog('TurnKey Linux - First boot configuration') if not profile: profile = dialog.menu( "OpenVPN Profile", "Choose a profile for this server.\n\n* Gateway: clients will be configured to route all\n their traffic through the VPN.", [('server', 'Accept VPN connections from clients'), ('gateway', 'Accept VPN connections from clients*'), ('client', 'Initiate VPN connections to a server')]) if not profile in ('server', 'gateway', 'client'): fatal('invalid profile: %s' % profile) if profile == "client": return if not key_email: key_email = dialog.get_email( "OpenVPN Email", "Enter email address for the OpenVPN server key.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', key_email) if not public_address: public_address = dialog.get_input( "OpenVPN Public Address", "Enter FQDN or IP address of server reachable by clients", "vpn.example.com") auto_virtual_subnet = "10.%d.%d.0/24" % (r(2, 254), r(2, 254)) if not virtual_subnet: virtual_subnet = dialog.get_input( "OpenVPN Virtual Subnet", "Enter CIDR subnet address pool to allocate to clients. This server will be configured with x.x.x.1. The CIDR must not be in-use on your network.", auto_virtual_subnet) if virtual_subnet.upper() == "AUTO": virtual_subnet = auto_virtual_subnet if profile == "server": if not private_subnet: retcode, private_subnet = dialog.inputbox( "OpenVPN Private Subnet", "Enter CIDR subnet behind server for clients to reach.", "10.0.1.0/24", "Apply", "Skip") if private_subnet.upper() == "SKIP": private_subnet = "" cmd = os.path.join(os.path.dirname(__file__), 'openvpn-server-init.sh') subprocess.run([cmd, key_email, public_address, virtual_subnet]) if profile == "gateway": fh = open("/etc/openvpn/server.conf", "a") fh.write( "# configure clients to route all their traffic through the vpn\n") fh.write("push \"redirect-gateway def1 bypass-dhcp\"\n\n") fh.close() if private_subnet: fh = open("/etc/openvpn/server.conf", "a") fh.write( "# push routes to clients to allow them to reach private subnets\n" ) for _private_subnet in private_subnet.split(','): fh.write("push \"route %s\"\n" % expand_cidr(_private_subnet)) fh.close() subprocess.run(['systemctl', 'start', 'openvpn@server'])
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=', 'domain=']) except getopt.GetoptError as e: usage(e) email = "" domain = "" password = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Snipe-IT Password", "Enter new password for the Snipe-IT 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Snipe-IT Email", "Enter email address for the Snipe-IT 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input( "Snipe-IT Domain", "Enter the domain to serve Snipe-IT.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) CONF = '/var/www/snipe-it/.env' # read .env lines with open(CONF, 'r') as fob: conf_lines = fob.readlines() # find APP_URL and set it to domain for i in range(len(conf_lines)): line = conf_lines[i].strip() if '=' not in line: continue key, value = line.split('=', 1) if key == 'APP_URL': line = f'APP_URL={domain}' conf_lines[i] = line + '\n' # write .env lines with open(CONF, 'w') as fob: fob.writelines(conf_lines) salt = bcrypt.gensalt() hashpass = bcrypt.hashpw(password.encode('utf8'), salt).decode('utf8') m = MySQL() m.execute('UPDATE snipeit.users SET password=%s WHERE id=1;', (hashpass,)) m.execute('UPDATE snipeit.users SET email=%s WHERE id=1;', (email,))
def main(): try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", ['help', 'pass='******'email=', 'domain=']) except getopt.GetoptError as e: usage(e) password = "" email = "" domain = "" for opt, val in opts: if opt in ('-h', '--help'): usage() elif opt == '--pass': password = val elif opt == '--email': email = val elif opt == '--domain': domain = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Drupal9 Password", "Enter new password for the Drupal9 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Drupal9 Email", "Enter email address for the Drupal9 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input("Drupal9 Domain", "Enter the domain to serve Drupal9.", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN inithooks_cache.write('APP_DOMAIN', domain) print("Progress...") m = MySQL() m.execute( 'UPDATE drupal9.users_field_data SET mail=%s WHERE name=\"admin\";', (email, )) m.execute( 'UPDATE drupal9.users_field_data SET init=%s WHERE name=\"admin\";', (email, )) domain = domain.replace('.', '\\\\\.') subprocess.run([ '/usr/lib/inithooks/bin/drupalconf.sh', '-e', email, '-p', password, '-d', domain ])
usage() elif opt == '--pass': password = val elif opt == '--email': email = val elif opt == '--domain': domain = val if not email: d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "PrestaShop Email", "Enter email address for the PrestaShop 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) if not password: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "PrestaShop Password", "Enter new password for the PrestaShop '%s' account." % email, pass_req=8) if not domain: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input(
if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') domain = d.get_input( "MediaWiki Domain", "Enter the domain to serve MediaWiki", DEFAULT_DOMAIN) if domain == "DEFAULT": domain = DEFAULT_DOMAIN fqdn = re.compile(r"https?://") fqdn = fqdn.sub('', domain).strip('/') domain = "https://%s/" % fqdn inithooks_cache.write("APP_DOMAIN", domain) hashpass = hashlib.md5(password).hexdigest() hashpass = hashlib.md5("1-" + hashpass).hexdigest() # userid 1 m = MySQL() m.execute('UPDATE mediawiki.user SET user_password=\"%s\" WHERE user_id=\"1\";' % hashpass) subprocess.call(['sed', '-i', '\|^\$wgServer|s|=.*|= "https://%s";|' % fqdn, '/var/www/mediawiki/LocalSettings.php']) subprocess.call(['sed', '-i', '\|RewriteRule|s|https://.*|https://%s/\$1 [R,L]|' % fqdn, '/etc/apache2/sites-available/mediawiki.conf']) subprocess.call(['service', 'apache2', 'restart'])
elif opt == '--email': email = val if not password: d = Dialog('TurnKey Linux - First boot configuration') password = d.get_password( "Kliqqi Password", "Enter new password for the Kliqqi 'admin' account.") if not email: if 'd' not in locals(): d = Dialog('TurnKey Linux - First boot configuration') email = d.get_email( "Kliqqi Email", "Enter email address for the Kliqqi 'admin' account.", "*****@*****.**") inithooks_cache.write('APP_EMAIL', email) salt = ''.join((random.choice(string.letters+string.digits) for x in range(9))) hash = salt + hashlib.sha1(salt + password).hexdigest() m = MySQL() m.execute('UPDATE kliqqi.users SET user_pass=\"%s\" WHERE user_login=\"admin\";' % hash) m.execute('UPDATE kliqqi.users SET user_email=\"%s\" WHERE user_login=\"admin\";' % email) if __name__ == "__main__": main()
def _apply(interface, address, netmask, gateway, nameservers): set_static(interface, address, netmask, gateway, nameservers) inithooks_cache.write('APP_STATIC_IP', '')