mirror of
https://github.com/YunoHost-Apps/galette_ynh.git
synced 2024-09-03 18:36:28 +02:00
Adding python script to use php installer
This commit is contained in:
parent
14d2dfe052
commit
2217715789
2 changed files with 64 additions and 5 deletions
55
conf/initialConf.py
Normal file
55
conf/initialConf.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
#!/usr/bin/python
|
||||
import re
|
||||
from mechanize import Browser
|
||||
|
||||
path = sys.argv[1]
|
||||
password = sys.argv[2]
|
||||
admin = sys.argv[3]
|
||||
adminPass = sys.argv[4]
|
||||
|
||||
br = Browser()
|
||||
|
||||
# Ignore robots.txt
|
||||
br.set_handle_robots( False )
|
||||
|
||||
# Set user agent as Firefox
|
||||
br.addheaders = [('User-agent', 'Firefox')]
|
||||
|
||||
# Retrieve the instlation page
|
||||
br.open( "http://"+path+"/install/installer.php" )
|
||||
|
||||
# Page 1 - requirement checks
|
||||
br.select_form(nr=0)
|
||||
br.submit()
|
||||
|
||||
# Page 2 - installation type (default is new installation)
|
||||
br.select_form(nr=0)
|
||||
br.submit()
|
||||
|
||||
# Page 3 - database configuration
|
||||
br.select_form(nr=0)
|
||||
br.form["install_dbuser"] = "galette"
|
||||
br.form["install_dbpass"] = password
|
||||
br.form["install_dbname"] = "galette"
|
||||
br.submit()
|
||||
|
||||
# Page 4 - confirmation that database correctly configured
|
||||
br.select_form(nr=0)
|
||||
br.submit()
|
||||
|
||||
# Page 5 - database / table creations
|
||||
br.select_form(nr=0)
|
||||
br.submit()
|
||||
|
||||
# Page 6 - admin user creation
|
||||
br.select_form(nr=0)
|
||||
br.form["install_adminlogin"] = admin
|
||||
br.form["install_adminpass"] = adminPass
|
||||
br.form["install_adminpass_verif"] = adminPass
|
||||
br.submit()
|
||||
|
||||
# Page 7 - confirmation
|
||||
br.select_form(nr=0)
|
||||
br.submit()
|
||||
|
||||
exit()
|
|
@ -73,12 +73,16 @@ db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]'
|
|||
sudo yunohost app initdb $db_user -p $db_pwd
|
||||
sudo yunohost app setting $app mysqlpassword -v $db_pwd
|
||||
|
||||
# Edit config file
|
||||
# Install mechanize to have a browser in a python script
|
||||
|
||||
sed -i "s/USER_DB_VALUE/$db_user/g" ../conf/config.inc.php
|
||||
sed -i "s/PWD_DB_VALUE/$db_pwd/g" ../conf/config.inc.php
|
||||
sed -i "s/NAME_DB_VALUE/$db_user/g" ../conf/config.inc.php
|
||||
sudo cp ../conf/config.inc.php $final_path/config/
|
||||
sudo pip install mechanize
|
||||
|
||||
# Then call python script to fill galette php installer with the right info
|
||||
|
||||
# todo : replace last password by user-specified pass
|
||||
sudo python ../conf/initialConf.py $domain$path $db_pwd $admin $db_pwd
|
||||
|
||||
rm -rf $final_path/install
|
||||
|
||||
####################################################
|
||||
# Nginx configuration #
|
||||
|
|
Loading…
Add table
Reference in a new issue