Commit 55fd4d00 authored by Penom Nom's avatar Penom Nom
Browse files

No commit message

No commit message
parent 269e2e81
......@@ -16,7 +16,8 @@
#
from subprocess import Popen, PIPE
from jflow.workflow import Workflow
import tempfile, os, sys, re, logging
import tempfile, os, sys, re, hashlib, urllib, zipfile
import distutils.dir_util as dirutil
from ng6.config_reader import NG6ConfigReader
class Install (Workflow):
......@@ -37,51 +38,29 @@ class Install (Workflow):
fileadmin = os.path.join(ng6_web_path, "fileadmin")
install_tool_password ="typo3"
# 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
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)
#rename typo3 folder
#Downloading typo3 package
urllib.urlretrieve(self.get_resource("typo3_src"), dummy_tmp_zipfile)
#Testing and Unzipping typo3 package
with zipfile.ZipFile(dummy_tmp_zipfile, 'r') as zipf:
if zipf.testzip() is None:
zipf.extractall(dummy_tmp_dir)
#Rename typo3 folder
typo3_dir = os.listdir(dummy_tmp_dir)[0]
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)
os.rename(os.path.join(dummy_tmp_dir, typo3_dir), os.path.join(dummy_tmp_dir,ng6_web_path.split("/")[-1]))
#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_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)
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(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)
dirutil.copy_tree(os.path.join(ng6_path, "ui", "nG6"), os.path.join(dummy_tmp_dir, "ng6", "typo3conf", "ext", "nG6"))
os.mkdir(os.path.join(dummy_tmp_dir, "ng6", "fileadmin", "templates"))
dirutil.copy_tree(os.path.join(ng6_path, "ui", "nG6template"),
os.path.join(dummy_tmp_dir, "ng6", "fileadmin", "templates", "nG6template"))
os.symlink(os.path.join(ng6conf.get_save_directory(), "data"),
os.path.join(dummy_tmp_dir, "ng6", "fileadmin", "data"))
#create config file
with open(os.path.join(dummy_tmp_dir, "ng6","typo3conf", "localconf.php")) as f:
config_lines= ''.join(f.readlines()[:-1])
......@@ -101,11 +80,7 @@ class Install (Workflow):
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)
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]
install_tool_password_hash = hashlib.md5(install_tool_password).hexdigest()
f.write("$TYPO3_CONF_VARS['BE']['installToolPassword'] = '" + install_tool_password_hash + "';\n")
#Testing unzip binary path :
unzip_path=["which","unzip"]
......@@ -115,12 +90,8 @@ class Install (Workflow):
f.write("?>\n")
# 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:
sys.stderr.write(stderr)
sys.exit(0)
with open(os.path.join(dummy_tmp_dir, "ng6", "typo3conf", "ENABLE_INSTALL_TOOL"), 'a'):
os.utime(os.path.join(dummy_tmp_dir, "ng6", "typo3conf", "ENABLE_INSTALL_TOOL"), None)
#Modifying database.sql
with open(db_path,"r") as f:
......@@ -154,20 +125,11 @@ class Install (Workflow):
sys.exit(0)
# fix permissions typo3
chmod = ["chmod", "--recursive", "777", os.path.join(dummy_tmp_dir, "ng6", "typo3conf"),
for dir in [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:
sys.stderr.write(stderr)
sys.exit(0)
os.path.join(dummy_tmp_dir,"ng6","uploads")]:
os.chmod(dir, 0o777)
#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)
dirutil.copy_tree(os.path.join(dummy_tmp_dir, ng6_path.split("/")[-1]), ng6_web_path, preserve_mode=1)
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