mirror of
https://github.com/YunoHost-Apps/opensondage_ynh.git
synced 2024-09-03 19:46:28 +02:00
[fix] upgrade script
This commit is contained in:
parent
5f5caad34b
commit
0af12d46ca
2 changed files with 105 additions and 90 deletions
|
@ -77,97 +77,12 @@ sudo chmod 644 $finalphpini
|
||||||
|
|
||||||
sudo service php5-fpm restart
|
sudo service php5-fpm restart
|
||||||
# Reload Nginx
|
# Reload Nginx
|
||||||
sudo service nginx reload#!/bin/bash
|
|
||||||
|
|
||||||
# Retrieve arguments
|
|
||||||
domain=$1
|
|
||||||
path=$2
|
|
||||||
admin=$3
|
|
||||||
language=$4
|
|
||||||
public_site=$5
|
|
||||||
legal='no'
|
|
||||||
|
|
||||||
# Check if admin exists
|
|
||||||
sudo yunohost user list --json | grep -q "\"username\": \"$admin\""
|
|
||||||
if [[ ! $? -eq 0 ]]; then
|
|
||||||
echo "Wrong admin"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
sudo yunohost app setting opensondage admin -v $admin
|
|
||||||
sudo yunohost app setting opensondage language -v $language
|
|
||||||
sudo yunohost app setting opensondage legal -v $legal
|
|
||||||
sudo yunohost app setting opensondage public_site -v $public_site
|
|
||||||
|
|
||||||
# Check domain/path availability
|
|
||||||
sudo yunohost app checkurl $domain$path -a opensondage
|
|
||||||
if [[ ! $? -eq 0 ]]; then
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Generate random password
|
|
||||||
db_pwd=$(dd if=/dev/urandom bs=1 count=200 2> /dev/null | tr -c -d '[A-Za-z0-9]' | sed -n 's/\(.\{24\}\).*/\1/p')
|
|
||||||
|
|
||||||
# Use 'opensondage' as database name and user
|
|
||||||
db_user=opensondage
|
|
||||||
|
|
||||||
# Initialize database and store mysql password for upgrade
|
|
||||||
sudo yunohost app initdb $db_user -p $db_pwd
|
|
||||||
sudo yunohost app setting opensondage mysqlpwd -v $db_pwd
|
|
||||||
|
|
||||||
# Copy files to the right place
|
|
||||||
final_path=/var/www/opensondage
|
|
||||||
sudo mkdir -p $final_path
|
|
||||||
sudo cp -a ../sources/* $final_path
|
|
||||||
sudo cp ../conf/constants.php.template $final_path/app/inc/constants.php
|
|
||||||
|
|
||||||
# Change variables in OpenSondage configuration
|
|
||||||
sudo sed -i "s/yunouser/$db_user/g" $final_path/app/inc/constants.php
|
|
||||||
sudo sed -i "s/yunopass/$db_pwd/g" $final_path/app/inc/constants.php
|
|
||||||
sudo sed -i "s/yunobase/$db_user/g" $final_path/app/inc/constants.php
|
|
||||||
sudo sed -i "s/yunoadmin/$admin/g" $final_path/app/inc/constants.php
|
|
||||||
sudo sed -i "s/I18NTOCHANGE/$language/g" $final_path/app/inc/constants.php
|
|
||||||
sudo sed -i "s@yunourl@$domain$path@g" $final_path/app/inc/constants.php
|
|
||||||
sudo sed -i "s@yunodomain@$domain@g" $final_path/app/inc/constants.php
|
|
||||||
sudo sed -i "s@yunoabout@$legal@g" $final_path/app/inc/constants.php
|
|
||||||
|
|
||||||
# Create log file
|
|
||||||
touch $final_path/admin/logs_studs.txt
|
|
||||||
chmod 700 $final_path/admin/logs_studs.txt
|
|
||||||
# Set permissions
|
|
||||||
sudo chown -R www-data: $final_path
|
|
||||||
|
|
||||||
# Db installation
|
|
||||||
mysql -u $db_user -p$db_pwd $db_user < $final_path/install.mysql.sql
|
|
||||||
|
|
||||||
|
|
||||||
sed -i "s@NAMETOCHANGE@opensondage@g" ../conf/php-fpm.conf
|
|
||||||
finalphpconf=/etc/php5/fpm/pool.d/opensondage.conf
|
|
||||||
sudo cp ../conf/php-fpm.conf $finalphpconf
|
|
||||||
sudo chown root: $finalphpconf
|
|
||||||
sudo chmod 644 $finalphpconf
|
|
||||||
|
|
||||||
finalphpini=/etc/php5/fpm/conf.d/20-opensondage.ini
|
|
||||||
sudo cp ../conf/php-fpm.ini $finalphpini
|
|
||||||
sudo chown root: $finalphpini
|
|
||||||
sudo chmod 644 $finalphpini
|
|
||||||
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
|
||||||
sudo service php5-fpm restart
|
|
||||||
|
|
||||||
sudo apt-get install php-fpdf
|
|
||||||
sudo yunohost app addaccess opensondage -u $admin
|
|
||||||
|
|
||||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
|
||||||
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
|
|
||||||
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
|
|
||||||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/opensondage.conf
|
|
||||||
# Reload Nginx and regenerate SSOwat conf
|
|
||||||
sudo service nginx reload
|
sudo service nginx reload
|
||||||
sudo yunohost app setting opensondage skipped_uris -v "/"
|
sudo yunohost app setting opensondage skipped_uris -v "/"
|
||||||
if [ $public_site = "No" ];
|
if [ $public_site = "No" ];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting opensondage protected_uris -v "/admin,/index.php,/choix_date.php,/choix_autre.php,/infos_sondage.php,/scripts"
|
sudo yunohost app setting opensondage protected_uris -v "/admin,/index.php,/choix_date.php,/choix_autre.php,/infos_sondage.php,/scripts"
|
||||||
else
|
else
|
||||||
sudo yunohost app setting opensondage protected_uris -v "/admin/index.php,/admin/logs_studs.txt,/scripts"
|
sudo yunohost app setting opensondage protected_uris -v "/admin/index.php,/admin/logs_studs.txt,/scripts"
|
||||||
fi
|
fi
|
||||||
sudo yunohost app ssowatconf
|
sudo yunohost app ssowatconf
|
||||||
|
|
100
sources/mysql
Normal file
100
sources/mysql
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
-- Base de données: `opensondage`
|
||||||
|
--
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `comments`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `comments` (
|
||||||
|
`id_comment` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`id_sondage` char(16) NOT NULL,
|
||||||
|
`comment` text NOT NULL,
|
||||||
|
`usercomment` text,
|
||||||
|
PRIMARY KEY (`id_comment`),
|
||||||
|
KEY `id_sondage` (`id_sondage`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `sondage`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `sondage` (
|
||||||
|
`id_sondage` char(16) NOT NULL,
|
||||||
|
`commentaires` text,
|
||||||
|
`mail_admin` varchar(128) DEFAULT NULL,
|
||||||
|
`nom_admin` varchar(64) DEFAULT NULL,
|
||||||
|
`titre` text,
|
||||||
|
`id_sondage_admin` char(24) DEFAULT NULL,
|
||||||
|
`date_creation` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
`date_fin` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
|
`format` varchar(2) DEFAULT NULL,
|
||||||
|
`mailsonde` tinyint(1) DEFAULT '0',
|
||||||
|
`statut` int(11) NOT NULL DEFAULT '1' COMMENT '1 = actif ; 0 = inactif ; ',
|
||||||
|
UNIQUE KEY `id_sondage` (`id_sondage`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `sujet_studs`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `sujet_studs` (
|
||||||
|
`id_sondage` char(16) NOT NULL,
|
||||||
|
`sujet` text,
|
||||||
|
KEY `id_sondage` (`id_sondage`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Structure de la table `user_studs`
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE IF NOT EXISTS `user_studs` (
|
||||||
|
`id_users` int(11) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`nom` varchar(64) NOT NULL,
|
||||||
|
`id_sondage` char(16) NOT NULL,
|
||||||
|
`reponses` text NOT NULL,
|
||||||
|
PRIMARY KEY (`id_users`),
|
||||||
|
KEY `id_sondage` (`id_sondage`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=160284 ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO `sondage`
|
||||||
|
(`id_sondage`, `commentaires`, `mail_admin`, `nom_admin`,
|
||||||
|
`titre`, `id_sondage_admin`,
|
||||||
|
`date_fin`, `format`)
|
||||||
|
VALUES
|
||||||
|
('aqg259dth55iuhwm','Repas de Noel du service','Stephanie@retaillard.com','Stephanie',
|
||||||
|
'Repas de Noel','aqg259dth55iuhwmy9d8jlwk',
|
||||||
|
FROM_UNIXTIME('1627100361'),'D+');
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Data for Name: sujet_studs; Type: TABLE DATA;
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `sujet_studs` (`id_sondage`, `sujet`) VALUES
|
||||||
|
('aqg259dth55iuhwm','1225839600@12h,1225839600@19h,1226012400@12h,1226012400@19h,1226876400@12h,1226876400@19h,1227049200@12h,1227049200@19h,1227826800@12h,1227826800@19h');
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Data for Name: user_studs; Type: TABLE DATA;
|
||||||
|
--
|
||||||
|
|
||||||
|
INSERT INTO `user_studs` (`nom`, `id_sondage`, `reponses`, `id_users`) VALUES
|
||||||
|
('marcel','aqg259dth55iuhwm','0110111101','933'),
|
||||||
|
('paul','aqg259dth55iuhwm','1011010111','935'),
|
||||||
|
('sophie','aqg259dth55iuhwm','1110110000','945'),
|
||||||
|
('barack','aqg259dth55iuhwm','0110000','948'),
|
||||||
|
('takashi','aqg259dth55iuhwm','0000110100','951'),
|
||||||
|
('albert','aqg259dth55iuhwm','1010110','975'),
|
||||||
|
('alfred','aqg259dth55iuhwm','0110010','1135'),
|
||||||
|
('marcs','aqg259dth55iuhwm','0100001010','1143'),
|
||||||
|
('laure','aqg259dth55iuhwm','0011000','1347'),
|
||||||
|
('benda','aqg259dth55iuhwm','1101101100','1667'),
|
||||||
|
('Albert','aqg259dth55iuhwm','1111110011','1668');
|
Loading…
Add table
Reference in a new issue