Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
genotoul-bioinfo
ng6
Commits
727d09f4
Commit
727d09f4
authored
Oct 15, 2013
by
Penom Nom
Browse files
No commit message
No commit message
parent
24be62e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
workflows/install/__init__.py
View file @
727d09f4
...
...
@@ -14,49 +14,34 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from
subprocess
import
Popen
,
PIPE
import
tempfile
,
os
,
sys
,
re
,
logging
from
jflow.workflow
import
Workflow
import
tempfile
,
os
,
sys
,
logging
from
ng6.config_reader
import
NG6ConfigReader
from
os.path
import
expanduser
class
Install
(
Workflow
):
def
process
(
self
):
#
typo3 variables
#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
()
db_tmp_name
=
db_name
suffix_db
=
1
# TODO: a modifier ce n'est pas jolie, utilise la path du file, tu le fera en 1 ligne!!
if
"/"
.
join
(
sys
.
argv
[
0
].
split
(
"/"
)[:
-
2
])[
0
]
!=
"/"
:
ng6_path
=
str
(
os
.
getcwd
())
+
"/"
+
"/"
.
join
(
sys
.
argv
[
0
].
split
(
"/"
)[:
-
2
])
else
:
ng6_path
=
"/"
.
join
(
sys
.
argv
[
0
].
split
(
"/"
)[:
-
2
])
# TODO: utililse os.path.join !!! ca c'est sous unix ...
db_path
=
ng6_path
+
"/workflows/install/data_typo3/database.sql"
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
])
# TODO: web_dir doit etre un parametre
web_dir
=
"/var/www"
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"
unzip_binary_path
=
""
install_tool_password
=
"typo3"
# install_tool_password_hash =""
# wget
dummy_tmp
=
tempfile
.
NamedTemporaryFile
(
prefix
=
'dummy_'
,
suffix
=
'.zip'
).
name
# TODO: j'ai mis le nom dans le .properties d'application c'est une ressource
wget
=
[
"wget"
,
"--output-document"
,
dummy_tmp
,
self
.
get_resource
(
"typo3_src"
)]
p
=
Popen
(
wget
,
stdout
=
PIPE
,
stderr
=
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
# unzip
dummy_tmp_dir
=
tempfile
.
mkdtemp
(
suffix
=
'_typo3'
,
prefix
=
'dummy_'
)
unzip
=
[
"unzip"
,
dummy_tmp
,
"-d"
,
dummy_tmp_dir
]
...
...
@@ -65,33 +50,32 @@ class Install (Workflow):
#rename typo3 folder
typo3_dir
=
os
.
listdir
(
dummy_tmp_dir
)[
0
]
# TODO: c'est quoi ce ng62 ??
rename
=
[
"mv"
,
dummy_tmp_dir
+
"/"
+
typo3_dir
,
dummy_tmp_dir
+
"/ng62"
]
rename
=
[
"mv"
,
dummy_tmp_dir
+
"/"
+
typo3_dir
,
dummy_tmp_dir
+
"/ng6"
]
p
=
Popen
(
rename
,
stdout
=
PIPE
,
stderr
=
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
#link ng6 folder
# TODO: ne fait pas des links mais des cp
slink_ext
=
[
"ln"
,
"-s"
,
ng6_path
+
"/ui/nG6"
,
dummy_tmp_dir
+
"/ng62/typo3conf/ext/nG6"
]
#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
)
stdout
,
stderr
=
p
.
communicate
()
print
stderr
mkdir_templ
=
[
"mkdir"
,
dummy_tmp_dir
+
"/
ng6
2
/fileadmin/templates"
]
mkdir_templ
=
[
"mkdir"
,
os
.
path
.
join
(
dummy_tmp_dir
,
"
ng6/fileadmin/templates"
)
]
p
=
Popen
(
mkdir_templ
,
stdout
=
PIPE
,
stderr
=
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
slink_templ
=
[
"
ln
"
,
"-
s
"
,
ng6_path
+
"/
ui/nG6template"
,
dummy_tmp_dir
+
"/
ng6
2
/fileadmin/templates/nG6template"
]
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
)
stdout
,
stderr
=
p
.
communicate
()
slink_data
=
[
"
ln
"
,
"-
s
"
,
save_data_path
,
dummy_tmp_dir
+
"/
ng6
2
/fileadmin/data"
]
slink_data
=
[
"
cp
"
,
"-
rf
"
,
save_data_path
,
os
.
path
.
join
(
dummy_tmp_dir
,
"
ng6/fileadmin/data"
)
]
p
=
Popen
(
slink_data
,
stdout
=
PIPE
,
stderr
=
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
#create config file
with
open
(
dummy_tmp_dir
+
'/ng6
2
/typo3conf/localconf.php'
)
as
f
:
with
open
(
dummy_tmp_dir
+
'/ng6/typo3conf/localconf.php'
)
as
f
:
config_lines
=
''
.
join
(
f
.
readlines
()[:
-
1
])
with
open
(
dummy_tmp_dir
+
'/ng6
2
/typo3conf/localconf.php'
,
"w"
)
as
f
:
with
open
(
dummy_tmp_dir
+
'/ng6/typo3conf/localconf.php'
,
"w"
)
as
f
:
f
.
write
(
config_lines
)
#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
"
)
...
...
@@ -106,14 +90,14 @@ class Install (Workflow):
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
"
)
#
hash du
password
typo3
#
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
"
)
#
t
est
de presence
unzip binary p
uis
:
#
T
est
ing
unzip binary p
ath
:
unzip_path
=
[
"which"
,
"unzip"
]
p
=
Popen
(
unzip_path
,
stdout
=
PIPE
,
stderr
=
PIPE
)
stdout
,
stderr
=
p
.
communicate
()
...
...
@@ -121,46 +105,38 @@ class Install (Workflow):
f
.
write
(
"?>
\n
"
)
# Enable install tool
install_file
=
[
"touch"
,
dummy_tmp_dir
+
'/
ng6
2
/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
()
#Checking if database name already exists
mysql_check_db
=
[
"mysql"
,
"--host="
+
db_host
,
"--user="
+
db_user
,
"--password="
+
db_password
,
"-e"
,
"SHOW DATABASES LIKE '"
+
db_name
+
"';"
]
p_mysql_check_db
=
Popen
(
mysql_check_db
,
stdout
=
PIPE
,
stderr
=
PIPE
)
stdout
,
stderr
=
p_mysql_check_db
.
communicate
()
#Searching available name for typo3 database
while
stdout
!=
""
:
db_tmp_name
=
db_name
+
"_"
+
str
(
suffix_db
)
mysql_check_db
=
[
"mysql"
,
"--host="
+
db_host
,
"--user="
+
db_user
,
"--password="
+
db_password
,
"-e"
,
"SHOW DATABASES LIKE '"
+
db_tmp_name
+
"';"
]
p_mysql_check_db
=
Popen
(
mysql_check_db
,
stdout
=
PIPE
,
stderr
=
PIPE
)
stdout
,
stderr
=
p_mysql_check_db
.
communicate
()
# TODO: c'est quoi ce suffix_db ?
suffix_db
=
suffix_db
+
1
if
stderr
!=
""
:
logging
.
getLogger
(
"Install.process"
).
error
(
stderr
)
#Creating database typo3
db_name
=
db_tmp_name
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
)
#Inserting tables in typo3 database
mysql_tables
=
[
"mysql"
,
"--host="
+
db_host
,
"--user="
+
db_user
,
"--password="
+
db_password
,
"--default-character-set=utf8"
,
"--database="
+
db_name
]
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
)
# fix permissions typo3
chmod
=
[
"chmod"
,
"--recursive"
,
"777"
,
dummy_tmp_dir
+
'/ng6
2
/typo3conf'
,
dummy_tmp_dir
+
'/ng6
2
/fileadmin'
,
dummy_tmp_dir
+
'/ng6
2
/typo3temp'
,
dummy_tmp_dir
+
'/ng6
2
/uploads'
]
chmod
=
[
"chmod"
,
"--recursive"
,
"777"
,
dummy_tmp_dir
+
'/ng6/typo3conf'
,
dummy_tmp_dir
+
'/ng6/fileadmin'
,
dummy_tmp_dir
+
'/ng6/typo3temp'
,
dummy_tmp_dir
+
'/ng6/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
=
[
"cp"
,
"-rf"
,
"--preserve=mode"
,
dummy_tmp_dir
+
"/ng6
2
"
,
web_dir
]
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
)
workflows/install/workflow.properties
View file @
727d09f4
...
...
@@ -31,18 +31,7 @@ description = install ng6 web site
# .action [store]: the basic type of action to be taken (store|append)
#
[parameters]
#db_name.flag = --db
#db_name.default = t3
#db_name.help = Name of typo3 database for nG6 website
#
#db_user.flag = --db-user
#db_user.default = admin
#db_user.help = Username to access the databases administrator (like phpmyadmin)
#
#db_password.flag = --db-pass
#db_password.default = password
#db_password.help = Password to access the databases administrator (like phpmyadmin)
#
#db_host.flag = --db-host
#db_host.default = localhost
#
db.host.help
=
Machine hosting the database
\ No newline at end of file
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment