Commit 64d62eb6 authored by Penom Nom's avatar Penom Nom
Browse files

No commit message

No commit message
parent 046aecb6
......@@ -14,100 +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 os.path import expanduser
import tempfile, os, sys, re, logging
from ng6.config_reader import NG6ConfigReader
class Install (Workflow):
def process(self):
# set typo3 variables
#set typo3 variables
ng6conf = NG6ConfigReader()
[db_host, db_user, db_password, db_name] = ng6conf.get_typo3_db_params()
[db_host, db_user, db_password, db_name] = ng6conf.get_typo3_db_params()
dummy_tmp_zipfile = tempfile.NamedTemporaryFile(prefix = 'dummy_', suffix = '.zip').name
dummy_tmp_dir = tempfile.mkdtemp(suffix='_typo3', prefix='dummy_')
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")
ng6_web_path= self.args["web_path"]
fileadmin = os.path.join(ng6_web_path, "fileadmin")
install_tool_password ="typo3"
# download the dummy archive
dummy_tmp = tempfile.NamedTemporaryFile(prefix = 'dummy_', suffix = '.zip').name
wget = ["wget", "--output-document", dummy_tmp, self.get_resource("typo3_src")]
# wget
wget = ["wget", "--output-document", dummy_tmp_zipfile, self.get_resource("typo3_src")]
p = Popen(wget, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
# unzip the archive
dummy_tmp_dir = tempfile.mkdtemp(suffix='_typo3', prefix='dummy_')
unzip = ["unzip", dummy_tmp, "-d", dummy_tmp_dir]
# unzip
unzip = ["unzip", dummy_tmp_zipfile, "-d", dummy_tmp_dir]
p = Popen(unzip, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
# move it to the right directory
#rename typo3 folder
typo3_dir = os.listdir(dummy_tmp_dir)[0]
mv_install=["mv", os.path.join(dummy_tmp_dir, typo3_dir), self.args["web_dir"]]
p = Popen(mv_install, stdout=PIPE, stderr=PIPE)
rename=["mv", os.path.join(dummy_tmp_dir, typo3_dir), os.path.join(dummy_tmp_dir,ng6_path.split("/")[-1])]
p = Popen(rename, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
# 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)
#cp ng6 folders
plugin_cp=["cp", "-rf", os.path.join(ng6_path, "ui", "nG6"), os.path.join(dummy_tmp_dir, "ng6", "typo3conf", "ext", "nG6")]
p = Popen(plugin_cp, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
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)
mkdir_template=["mkdir", os.path.join(dummy_tmp_dir, "ng6", "fileadmin", "templates")]
p = Popen(mkdir_template, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
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)
cp_template=["cp", "-rf", os.path.join(ng6_path, "ui", "nG6template"), os.path.join(dummy_tmp_dir, "ng6", "fileadmin", "templates", "nG6template")]
p = Popen(cp_template, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
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)
slink_data=["ln", "-s", os.path.join(ng6conf.get_save_directory(), "data"), os.path.join(dummy_tmp_dir, "ng6", "fileadmin", "data")]
p = Popen(cp_data, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
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:
#create config file
with open(os.path.join(dummy_tmp_dir, "ng6","typo3conf", "localconf.php")) as f:
config_lines= ''.join(f.readlines()[:-1])
with open(os.path.join(self.args["web_dir"], 'typo3conf', 'localconf.php'),"w") as f:
with open(os.path.join(dummy_tmp_dir,"ng6", "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")
# Risque de conflit si utilisation de l'installeur typo3
f.write("$typo_db = '" + db_name + "';\n")
f.write("$typo_db = '" + db_name + "';\n") #Risque de conflit si utilisation de l'installeur typo3
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", "typo3"], stdout=PIPE, stderr=PIPE)
# Typo3 password hash
p1 = Popen(["echo", "-n", install_tool_password], 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()
......@@ -115,38 +115,59 @@ class Install (Workflow):
f.write("?>\n")
# Enable install tool
install_file = ["touch", os.path.join(self.args["web_dir"], 'typo3conf', 'ENABLE_INSTALL_TOOL')]
install_file = ["touch", os.path.join(dummy_tmp_dir, "ng6", "typo3conf", "ENABLE_INSTALL_TOOL")]
p = Popen(install_file, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if stderr:
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
#Creating database typo3
#Modifying database.sql
with open(db_path,"r") as f:
database = f.readlines()
for iline in range(0, len(database)):
database[iline] = re.sub("class=\"homeitem\"><a href=\"([\w/]+)\">", "class=\"homeitem\"><a href=\"/" + ng6_web_path.split("/")[-1] + "\">",database[iline])
database[iline] = re.sub("plugin.tx_nG6_pi1.data=([\w/.-]+)", "plugin.tx_nG6_pi1.data=" + fileadmin, database[iline])
database[iline] = re.sub("plugin.tx_nG6_pi5.temp=([\w/.-]+)", "plugin.tx_nG6_pi5.temp=" + fileadmin + "/tmp", database[iline])
database[iline] = re.sub("plugin.tx_nG6_pi5.data=([\w/.-]+)", "plugin.tx_nG6_pi5.data=" + fileadmin + "/data", database[iline])
database[iline] = re.sub("plugin.tx_nG6_pi5.directory_prefix=([\w/.-]+)", "plugin.tx_nG6_pi5.directory_prefix=" + NG6ConfigReader().get_work_directory(), database[iline])
database[iline] = re.sub("plugin.tx_nG6_pi6.data=([\w/.-]+)", "plugin.tx_nG6_pi6.data=" + fileadmin, database[iline])
with open(db_path,"w") as f:
for line in database:
f.write(line)
#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:
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:
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
# fix permissions typo3
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')]
chmod = ["chmod", "--recursive", "777", os.path.join(dummy_tmp_dir, "ng6", "typo3conf"),
os.path.join(dummy_tmp_dir,"ng6","fileadmin"),
os.path.join(dummy_tmp_dir, "ng6", "typo3temp"),
os.path.join(dummy_tmp_dir,"ng6","uploads")]
p = Popen(chmod, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if stderr:
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
#cp typo3 folder to web folder
cp=["cp","-rf", "--preserve=mode", os.path.join(dummy_tmp_dir, ng6_path.split("/")[-1]), ng6_web_path]
p = Popen(cp, stdout=PIPE, stderr=PIPE)
stdout, stderr = p.communicate()
if stderr:
sys.stderr.write(stderr)
sys.exit(0)
......@@ -788,7 +788,7 @@ CREATE TABLE IF NOT EXISTS `sys_template` (
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
INSERT INTO `sys_template` (`uid`, `pid`, `t3ver_oid`, `t3ver_id`, `t3ver_wsid`, `t3ver_label`, `t3ver_state`, `t3ver_stage`, `t3ver_count`, `t3ver_tstamp`, `t3_origuid`, `tstamp`, `sorting`, `crdate`, `cruser_id`, `title`, `sitetitle`, `hidden`, `starttime`, `endtime`, `root`, `clear`, `include_static_file`, `constants`, `config`, `resources`, `nextLevel`, `description`, `basedOn`, `deleted`, `includeStaticAfterBasedOn`, `static_file_mode`, `tx_impexp_origuid`) VALUES
(1, 1, 0, 0, 0, '', 0, 0, 0, 0, 0, 1381241401, 256, 1381240575, 1, 'NEW SITE', '', 0, 0, 0, 1, 3, 'EXT:css_styled_content/static/', NULL, 'page = PAGE\r\npage.typeNum = 0\r\n\r\npage.meta.DESCRIPTION = nG6\r\npage.meta.KEYWORDS = Sequencing\r\n\r\npage.includeCSS.file1 = fileadmin/templates/nG6template/css/style.css\r\n[browser = msie] && [version = <7]\r\npage.includeCSS.file2 = fileadmin/templates/nG6template/css/ie6.css\r\n[GLOBAL]\r\n\r\ntemp.MenuRechts = HMENU\r\ntemp.MenuRechts.maxItems = 5\r\ntemp.MenuRechts {\r\n 1 = TMENU\r\n 1 {\r\n expAll = 1\r\n wrap = <ul><li class="homeitem"><a href="/typo3_47"><img alt="homeitem" src="fileadmin/templates/nG6template/images/picto-home.png"/></a></li>|</ul>\r\n noBlur = 1\r\n NO {\r\n wrapItemAndSub = <li>|</li>\r\n ATagParams = accesskey="1"||accesskey="2"||accesskey="3"||accesskey="4"||accesskey="5"||accesskey="6"||\r\n ATagTitle.field = description // title \r\n }\r\n ACT=1\r\n ACT {\r\n wrapItemAndSub = <li class="act">|</li>\r\n ATagParams = accesskey="1"||accesskey="2"||accesskey="3"||accesskey="4"||accesskey="5"||accesskey="6"||\r\n ATagTitle.field = description // title\r\n }\r\n }\r\n}\r\n\r\ntemp.MenuUnten=HMENU\r\ntemp.MenuUnten.special=directory\r\ntemp.MenuUnten.special.value=17\r\ntemp.MenuUnten.1=TMENU\r\ntemp.MenuUnten {\r\n 1 = TMENU\r\n 1 {\r\n expAll = 1\r\n wrap = <ul>|</ul>\r\n noBlur = 1\r\n NO {\r\n wrapItemAndSub = <li>|</li>|*|<li>&#124;|</li>|*||*|\r\n ATagTitle.field = description // title\r\n }\r\n ACT=1\r\n ACT {\r\n wrapItemAndSub = <li>|</li>|*|<li>&#124;|</li>|*||*|\r\n ATagTitle.field = description // title\r\n }\r\n }\r\n}\r\n\r\npage.bodyTag = <body>\r\npage.1 = TEMPLATE\r\npage.1 {\r\n template = FILE\r\n template.file = fileadmin/templates/nG6template/index.html\r\n workOnSubpart = DOCUMENT\r\n subparts.BROWSER < plugin.tx_nG6_pi4\r\n subparts.CONTENT < styles.content.get\r\n subparts.SEARCHBOX < plugin.tx_nG6_pi2\r\n subparts.MENU < temp.MenuRechts\r\n subparts.FOOTER_LINKS < temp.MenuUnten\r\n}\r\npage.config.doctype (\r\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n)\r\npage.config.htmlTag_setParams = xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"\r\n\r\n\r\n# nG6 config\r\nplugin.tx_nG6_pi1=USER_INT\r\nplugin.tx_nG6_pi1.userpidList=8\r\nplugin.tx_nG6_pi1.server_url=http://localhost:8080/\r\nplugin.tx_nG6_pi1.FromEmail=support@ng6.toulouse.inra.fr\r\nplugin.tx_nG6_pi2.result_page_id=7\r\nplugin.tx_nG6_pi2.redirection_page=3\r\nplugin.tx_nG6_pi2=USER_INT\r\nplugin.tx_nG6_pi3=USER_INT\r\nplugin.tx_nG6_pi1.data=/var/www/ng6_47/fileadmin\r\nplugin.tx_nG6_pi3.result_page_id=7\r\nplugin.tx_nG6_pi3.redirection_page=3\r\nplugin.tx_nG6_pi5.temp=/var/www/ng6_47/fileadmin/tmp\r\nplugin.tx_nG6_pi5.data=/var/www/ng6_47/fileadmin/data\r\nplugin.tx_nG6_pi5.server_name=localhost\r\nplugin.tx_nG6_pi5.directory_prefix=/home/aleleu/scratch/work/\r\nplugin.tx_nG6_pi6.data=/var/www/ng6_47/fileadmin\r\nplugin.tx_nG6_pi6.server_url=http://localhost:8080/\r\n', NULL, '', NULL, '', 0, 0, 0, 0),
(1, 1, 0, 0, 0, '', 0, 0, 0, 0, 0, 1381241401, 256, 1381240575, 1, 'NEW SITE', '', 0, 0, 0, 1, 3, 'EXT:css_styled_content/static/', NULL, 'page = PAGE\r\npage.typeNum = 0\r\n\r\npage.meta.DESCRIPTION = nG6\r\npage.meta.KEYWORDS = Sequencing\r\n\r\npage.includeCSS.file1 = fileadmin/templates/nG6template/css/style.css\r\n[browser = msie] && [version = <7]\r\npage.includeCSS.file2 = fileadmin/templates/nG6template/css/ie6.css\r\n[GLOBAL]\r\n\r\ntemp.MenuRechts = HMENU\r\ntemp.MenuRechts.maxItems = 5\r\ntemp.MenuRechts {\r\n 1 = TMENU\r\n 1 {\r\n expAll = 1\r\n wrap = <ul><li class="homeitem"><a href="/ng6"><img alt="homeitem" src="fileadmin/templates/nG6template/images/picto-home.png"/></a></li>|</ul>\r\n noBlur = 1\r\n NO {\r\n wrapItemAndSub = <li>|</li>\r\n ATagParams = accesskey="1"||accesskey="2"||accesskey="3"||accesskey="4"||accesskey="5"||accesskey="6"||\r\n ATagTitle.field = description // title \r\n }\r\n ACT=1\r\n ACT {\r\n wrapItemAndSub = <li class="act">|</li>\r\n ATagParams = accesskey="1"||accesskey="2"||accesskey="3"||accesskey="4"||accesskey="5"||accesskey="6"||\r\n ATagTitle.field = description // title\r\n }\r\n }\r\n}\r\n\r\ntemp.MenuUnten=HMENU\r\ntemp.MenuUnten.special=directory\r\ntemp.MenuUnten.special.value=17\r\ntemp.MenuUnten.1=TMENU\r\ntemp.MenuUnten {\r\n 1 = TMENU\r\n 1 {\r\n expAll = 1\r\n wrap = <ul>|</ul>\r\n noBlur = 1\r\n NO {\r\n wrapItemAndSub = <li>|</li>|*|<li>&#124;|</li>|*||*|\r\n ATagTitle.field = description // title\r\n }\r\n ACT=1\r\n ACT {\r\n wrapItemAndSub = <li>|</li>|*|<li>&#124;|</li>|*||*|\r\n ATagTitle.field = description // title\r\n }\r\n }\r\n}\r\n\r\npage.bodyTag = <body>\r\npage.1 = TEMPLATE\r\npage.1 {\r\n template = FILE\r\n template.file = fileadmin/templates/nG6template/index.html\r\n workOnSubpart = DOCUMENT\r\n subparts.BROWSER < plugin.tx_nG6_pi4\r\n subparts.CONTENT < styles.content.get\r\n subparts.SEARCHBOX < plugin.tx_nG6_pi2\r\n subparts.MENU < temp.MenuRechts\r\n subparts.FOOTER_LINKS < temp.MenuUnten\r\n}\r\npage.config.doctype (\r\n<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r\n)\r\npage.config.htmlTag_setParams = xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"\r\n\r\n\r\n# nG6 config\r\nplugin.tx_nG6_pi1=USER_INT\r\nplugin.tx_nG6_pi1.userpidList=8\r\nplugin.tx_nG6_pi1.server_url=http://localhost:8080/\r\nplugin.tx_nG6_pi1.FromEmail=support@ng6.toulouse.inra.fr\r\nplugin.tx_nG6_pi2.result_page_id=7\r\nplugin.tx_nG6_pi2.redirection_page=3\r\nplugin.tx_nG6_pi2=USER_INT\r\nplugin.tx_nG6_pi3=USER_INT\r\nplugin.tx_nG6_pi1.data=/var/www/ng6/fileadmin\r\nplugin.tx_nG6_pi3.result_page_id=7\r\nplugin.tx_nG6_pi3.redirection_page=3\r\nplugin.tx_nG6_pi5.temp=/var/www/ng6/fileadmin/tmp\r\nplugin.tx_nG6_pi5.data=/var/www/ng6/fileadmin/data\r\nplugin.tx_nG6_pi5.server_name=localhost\r\nplugin.tx_nG6_pi5.directory_prefix=/home/aleleu/scratch/work\r\nplugin.tx_nG6_pi6.data=/var/www/ng6/fileadmin\r\nplugin.tx_nG6_pi6.server_url=http://localhost:8080/\r\n', NULL, '', NULL, '', 0, 0, 0, 0),
(2, 2, 0, 0, 0, '', 0, 0, 0, 0, 0, 1381241411, 256, 1381240779, 1, '+ext', '', 0, 0, 0, 0, 0, 'EXT:css_styled_content/static/', NULL, 'plugin.tx_nG6_pi1.view = run', NULL, '', NULL, '', 0, 0, 0, 0),
(3, 3, 0, 0, 0, '', 0, 0, 0, 0, 0, 1381241424, 256, 1381240857, 1, '+ext', '', 0, 0, 0, 0, 0, 'EXT:css_styled_content/static/', NULL, NULL, NULL, '', NULL, '', 0, 0, 0, 0),
(4, 4, 0, 0, 0, '', 0, 0, 0, 0, 0, 1381241436, 256, 1381240888, 1, '+ext', '', 0, 0, 0, 0, 0, 'EXT:css_styled_content/static/', NULL, NULL, NULL, '', NULL, '', 0, 0, 0, 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.flag = --www-dir
web_dir.default = /var/www/ng6
web_dir.help = Web directory for nG6 website
web_path.name = web_path
web_path.flag = --www-path
web_path.default = /var/www/ng6
web_path.help = Web path for nG6 website
\ No newline at end of file
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