Commit 346b0425 authored by Jerome Mariette's avatar Jerome Mariette
Browse files

make some modification

parent 0fa6fe43
......@@ -14,90 +14,100 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import sys
from subprocess import Popen, PIPE
from jflow.workflow import Workflow
import tempfile, os, sys, logging
from ng6.config_reader import NG6ConfigReader
from os.path import expanduser
from ng6.config_reader import NG6ConfigReader
class Install (Workflow):
def process(self):
#typo3 variables
# set typo3 variables
ng6conf = NG6ConfigReader()
[db_host, db_user, db_password, db_name] = ng6conf.get_typo3_db_params()
db_tmp_name=db_name
ng6_path = os.path.join(os.getcwd(), sys.argv[0])[:-2] if "/".join(sys.argv[0].split("/"))[0] != "/" else "/".join(sys.argv[0].split("/")[:-2])
[db_host, db_user, db_password, db_name] = ng6conf.get_typo3_db_params()
ng6_path = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
db_path = os.path.join(ng6_path,"workflows/install/data_typo3/database.sql")
web_dir= self.args["web_dir"]
save_data_path = NG6ConfigReader().get_save_directory()+"/data"
install_tool_password ="typo3"
# wget
# download the dummy archive
dummy_tmp = tempfile.NamedTemporaryFile(prefix = 'dummy_', suffix = '.zip').name
wget = ["wget", "--output-document", dummy_tmp, self.get_resource("typo3_src")]
p = Popen(wget, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
# unzip
# unzip the archive
dummy_tmp_dir = tempfile.mkdtemp(suffix='_typo3', prefix='dummy_')
unzip = ["unzip", dummy_tmp, "-d", dummy_tmp_dir]
p = Popen(unzip, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
#rename typo3 folder
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
# move it to the right directory
typo3_dir = os.listdir(dummy_tmp_dir)[0]
rename=["mv", dummy_tmp_dir+"/"+typo3_dir, dummy_tmp_dir+"/ng6"]
p = Popen(rename, stdout=PIPE, stderr=PIPE)
mv_install=["mv", os.path.join(dummy_tmp_dir, typo3_dir), self.args["web_dir"]]
p = Popen(mv_install, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
#cp ng6 folders
slink_ext=["cp", "-rf", os.path.join(ng6_path, "ui/nG6"), os.path.join(dummy_tmp_dir, "ng6/typo3conf/ext/nG6")]
p = Popen(slink_ext, stdout=PIPE, stderr=PIPE)
# copy ng6 plugin
plugin_copy=["cp", "-rf", os.path.join(ng6_path, "ui", "nG6"), os.path.join(self.args["web_dir"], "typo3conf", "ext", "nG6")]
p = Popen(plugin_copy, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
print stderr
mkdir_templ=["mkdir", os.path.join(dummy_tmp_dir, "ng6/fileadmin/templates")]
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
mkdir_templ=["mkdir", os.path.join(self.args["web_dir"], "fileadmin", "templates")]
p = Popen(mkdir_templ, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
slink_templ=["cp", "-rf", os.path.join(ng6_path, "ui/nG6template"), os.path.join(dummy_tmp_dir, "ng6/fileadmin/templates/nG6template")]
p = Popen(slink_templ, stdout=PIPE, stderr=PIPE)
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
copy_template=["cp", "-rf", os.path.join(ng6_path, "ui", "nG6template"), os.path.join(self.args["web_dir"], "fileadmin", "templates", "nG6template")]
p = Popen(copy_template, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
slink_data=["cp", "-rf", save_data_path, os.path.join(dummy_tmp_dir, "ng6/fileadmin/data")]
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
slink_data=["ln", "-s", os.path.join(ng6conf.get_save_directory(), "data"), os.path.join(self.args["web_dir"], "fileadmin", "data")]
p = Popen(slink_data, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
#create config file
with open(dummy_tmp_dir+'/ng6/typo3conf/localconf.php') as f:
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
# create config file
with open(os.path.join(self.args["web_dir"], 'typo3conf', 'localconf.php')) as f:
config_lines= ''.join(f.readlines()[:-1])
with open(dummy_tmp_dir+'/ng6/typo3conf/localconf.php',"w") as f:
with open(os.path.join(self.args["web_dir"], 'typo3conf', 'localconf.php'),"w") as f:
f.write(config_lines)
#Set config variables for typo3
# Set config variables for typo3
f.write("$TYPO3_CONF_VARS['EXT']['extList'] = 'extbase,css_styled_content,info,perm,func,filelist,fluid,about,version,tsconfig_help,context_help,extra_page_cm_options,impexp,sys_note,tstemplate,tstemplate_ceditor,tstemplate_info,tstemplate_objbrowser,tstemplate_analyzer,func_wizards,wizard_crpages,wizard_sortpages,lowlevel,install,belog,beuser,aboutmodules,setup,taskcenter,info_pagetsconfig,viewpage,rtehtmlarea,t3skin,t3editor,reports,felogin,form,rsaauth,saltedpasswords,nG6';\n")
f.write("$TYPO3_CONF_VARS['SYS']['compat_version'] = '4.7';\n")
f.write("$typo_db_username = '" + db_user + "';\n")
f.write("$typo_db_password = '" + db_password + "';\n")
f.write("$typo_db_host = '" + db_host + "';\n")
f.write("$typo_db = '" + db_name + "';\n") #Risque de conflit si utilisation de l'installeur typo3
# Risque de conflit si utilisation de l'installeur typo3
f.write("$typo_db = '" + db_name + "';\n")
f.write("$TYPO3_CONF_VARS['BE']['loginSecurityLevel'] = 'rsa';\n")
f.write("$TYPO3_CONF_VARS['FE']['loginSecurityLevel'] = 'rsa';\n")
f.write("$TYPO3_CONF_VARS['EXT']['extList_FE'] = 'extbase,css_styled_content,fluid,version,install,rtehtmlarea,t3skin,felogin,form,rsaauth,saltedpasswords,nG6';\n")
f.write("$TYPO3_CONF_VARS['BE']['disable_exec_function'] = '0';\n")
f.write("$TYPO3_CONF_VARS['GFX']['gdlib_png'] = '0';\n")
f.write("$TYPO3_CONF_VARS['GFX']['im_combine_filename'] = 'composite';\n")
# Typo3 password hash
p1 = Popen(["echo", "-n", install_tool_password], stdout=PIPE, stderr=PIPE)
# Typo3 password hash
p1 = Popen(["echo", "-n", "typo3"], stdout=PIPE, stderr=PIPE)
p2 = Popen(["md5sum"], stdin=p1.stdout, stdout=PIPE)
p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits.
output = p2.communicate()[0]
install_tool_password_hash = output.split(" ")[0]
f.write("$TYPO3_CONF_VARS['BE']['installToolPassword'] = '" + install_tool_password_hash + "';\n")
#Testing unzip binary path :
# Testing unzip binary path :
unzip_path=["which","unzip"]
p = Popen(unzip_path, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
......@@ -105,38 +115,38 @@ class Install (Workflow):
f.write("?>\n")
# Enable install tool
install_file = ["touch", os.path.join(dummy_tmp_dir, "ng6/typo3conf/ENABLE_INSTALL_TOOL")]
install_file = ["touch", os.path.join(self.args["web_dir"], 'typo3conf', 'ENABLE_INSTALL_TOOL')]
p = Popen(install_file, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if stderr != "":
logging.getLogger("Install.process").error(stderr)
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
#Creating database typo3
#Creating database typo3
mysql_create_db = ["mysql", "--host=" + db_host, "--user=" + db_user, "--password=" + db_password, "-e", "CREATE DATABASE " + db_name + ";"]
p = Popen(mysql_create_db, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if stderr != "":
logging.getLogger("Install.process").error(stderr)
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
#Inserting tables in typo3 database
mysql_tables = ["mysql", "--host=" + db_host, "--user=" + db_user, "--password=" + db_password, "--default-character-set=utf8", "--database=" + db_name]
db_path = os.path.join(ng6_path,"workflows", "install", "data_typo3", "database.sql")
with open(db_path) as f:
query= ''.join(f.readlines())
p = Popen(mysql_tables, stdout=PIPE, stderr=PIPE, stdin=PIPE)
stdout, stderr = p.communicate(query)
if stderr != "":
logging.getLogger("Install.process").error(stderr)
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
# fix permissions typo3
chmod = ["chmod", "--recursive", "777", dummy_tmp_dir+'/ng6/typo3conf', dummy_tmp_dir+'/ng6/fileadmin', dummy_tmp_dir+'/ng6/typo3temp', dummy_tmp_dir+'/ng6/uploads']
chmod = ["chmod", "--recursive", "777", os.path.join(self.args["web_dir"], 'typo3conf'),
os.path.join(self.args["web_dir"], 'fileadmin'), os.path.join(self.args["web_dir"], 'typo3temp'),
os.path.join(self.args["web_dir"], 'uploads')]
p = Popen(chmod, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if stderr != "":
logging.getLogger("Install.process").error(stderr)
#cp typo3 folder to web folder
cp=["sudo", "cp","-rf", "--preserve=mode", dummy_tmp_dir+"/ng6", web_dir]
p = Popen(cp, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if stderr != "":
logging.getLogger("Install.process").error(stderr)
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
......@@ -31,7 +31,7 @@ description = install ng6 web site
# .action [store]: the basic type of action to be taken (store|append)
#
[parameters]
web_dir.name = web_dir
web_dir.flag = --www-dir
web_dir.default = /var/www
web_dir.help = Web directory for nG6 website
\ No newline at end of file
web_dir.default = /var/www/ng6
web_dir.help = Web directory for nG6 website
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment