<commit_before>#!/usr/bin/env python

# $Header: /cvsroot/tikiwiki/tiki/doc/devtools/add1tiki2multi.py,v 1.3 2004-04-24 05:30:40 ggeller Exp $

# Copyright (c) 2004 <NAME>
# All Rights Reserved. See copyright.txt for details and a complete list of au\thors.
# Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for de\tails.

# invoke as sudo ./clikitiki.py <mysql-root-password> <new-tiki-url>

# NOTICE:
# 1. This script is intended to be run as root.
# 2. A lot of optional features must be set to particular values before this script can work.
#    For background material see:
#     http://tikiwiki.org/tiki-index.php?page=RecipeMultiTiki
#     http://tikiwiki.org/tiki-index.php?page=RecipeMultiTiki2
# 3. You must edit this script before it can run (see below).

import os
import sys
import re


# YOU MUST COMMENT OUT THE FOLLOWING LINE FOR THIS SCRIPT TO FUNCTION!!!!
# THIS SCRIPT IS DISABLED BY DEFAULT TO MINIMIZE THE SECURITY RISK FOR NAIVE TIKI ADMINS!
# sys.exit(0)

# Invoke as something like: ./newTiki.py password new.wikiplanet.com

sMySQLPassword = sys.argv[1]

sNewDomain = sys.argv[2]
sNewDomain = sNewDomain.lower()

# This script must be run as root
if os.getuid():
    print sys.argv[0], "must be run as root."
    sys.exit(-1)

# sNewDomain has to look like new.wikiplanet.com
# check for two "."
if sNewDomain.count(".") != 2:
    print sys.argv[0]+":", "Your new domain name must contain two \".\" characters. Exiting."
    sys.exit(-1)

# check for length
if len(sNewDomain) > 80:
    print sys.argv[0]+":", "Your new domain name is too long. Exiting."
    sys.exit(-1)

# check for illegal characters
if re.search(r'[^-.a-z0-9]',sNewDomain):
    print sys.argv[0]+":", "Your new domain name has illegal characters. Exiting."
    sys.exit(-1)

# must start with a letter
if not re.search(r'^[a-z].+',sNewDomain):
    print sys.argv[0]+":", "Your new domain name must start a letter. Exiting."
    sys.exit(-1)

# must end with a letter<commit_msg>Optionally prompt for mysql root password, correct typos.<commit_after>#!/usr/bin/env python

# $Header: /cvsroot/tikiwiki/tiki/doc/devtools/add1tiki2multi.py,v 1.4 2004-04-25 15:11:24 ggeller Exp $

# Copyright (c) 2004 <NAME>
# All Rights Reserved. See copyright.txt for details and a complete list of au\thors.
# Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for de\tails.

# invoke as sudo ./clikitiki.py <mysql-root-password> <new-tiki-url>

# NOTICE:
# 1. This script is intended to be run as root.
# 2. A lot of optional features must be set to particular values before this script can work.
#    For background material see:
#     http://tikiwiki.org/tiki-index.php?page=RecipeMultiTiki
#     http://tikiwiki.org/tiki-index.php?page=RecipeMultiTiki2
# 3. You must edit this script before it can run (see below).

import os
import sys
import re


# YOU MUST COMMENT OUT THE FOLLOWING LINE FOR THIS SCRIPT TO FUNCTION!!!!
# THIS SCRIPT IS DISABLED BY DEFAULT TO MINIMIZE THE SECURITY RISK FOR NAIVE TIKI ADMINS!
# sys.exit(0)

# Invoke as something like: ./add1tiki2multi.py.py password new.wikiplanet.com

def usage():
    print sys.argv[0], "[-p <mysql-root-password>] <new-tiki-domainname>"

if len(sys.argv) == 4:
    if sys.argv[1] == "-p":
        sMySQLPassword = sys.argv[2]
        sNewDomain = sys.argv[3]
    else:
        usage()
        sys.exit(-1)
elif len(sys.argv) == 2:
    sNewDomain = sys.argv[1]
    os.system("stty -echo")
    sMySQLPassword = raw_input("mysql root password:")
    os.system("stty echo")
    print ""
else:
    usage()
    sys.exit(-1);

sNewDomain = sNewDomain.lower()

# This script must be run as root
if os.getuid():
    print sys.argv[0], "must be run as root."
    sys.exit(-1)

# sNewDomain has to look like new.wikiplanet.com
# check for two "."
if sNewDomain.count(".") != 2:
    print sys.argv[0]+":", "Your new domain name must contain two \".\" characters. Exiting."
    sys.exit(-1)

# check for length
if len(sNewDomain) > 80:
    print sys.argv[0]+":", "Your new domain name is too long. Exiting."
    sys.exit(-1)

# check for illegal characters
if re.search(r'[^-.a-z0-9]',sNewDomain):
    print sys.argv[0]+":", "Your new domain name has illegal characters. Exiting."
    sys.exit(-1)

# must start with a letter
if not re.search(r'^[a-z].+',sNewDomain):
    print sys.argv[0]+":", "Your new domain name must start a letter. Exiting."
    sys.exit(-1)

# must end with a letter
{'fraction_non_alphanumeric': 0.13186813186813187, 'fraction_numerical': 0.021753756447634, 'mean_word_length': 3.46, 'pattern_counts': {'":': 9, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3804934', 'n_tokens_mistral': 1621, 'n_tokens_neox': 1540, 'n_words': 513}