mirror of
https://github.com/YunoHost-Apps/kanboard_ynh.git
synced 2024-09-03 19:36:17 +02:00
Remove sudo
This commit is contained in:
parent
c40b5a4697
commit
0a94ec3d6e
4 changed files with 61 additions and 61 deletions
|
@ -18,7 +18,7 @@ admin=$3
|
||||||
is_public=$4
|
is_public=$4
|
||||||
|
|
||||||
# TODO: Check domain/path availability with app helper
|
# TODO: Check domain/path availability with app helper
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||||
|| ynh_die "The path ${domain}${path} is not available for app installation."
|
|| ynh_die "The path ${domain}${path} is not available for app installation."
|
||||||
|
|
||||||
# Check user parameter
|
# Check user parameter
|
||||||
|
@ -27,7 +27,7 @@ ynh_user_exists "$admin" \
|
||||||
ynh_app_setting_set $app admin_user $admin
|
ynh_app_setting_set $app admin_user $admin
|
||||||
|
|
||||||
# Retrieve admin email
|
# Retrieve admin email
|
||||||
email=$(sudo yunohost user info $admin | grep mail: | sed "s/mail: //g")
|
email=$(yunohost user info $admin | grep mail: | sed "s/mail: //g")
|
||||||
|
|
||||||
# Check destination directory
|
# Check destination directory
|
||||||
DESTDIR="/var/www/$app"
|
DESTDIR="/var/www/$app"
|
||||||
|
@ -49,24 +49,24 @@ ynh_app_setting_set $app is_public $is_public
|
||||||
ynh_setup_source "$DESTDIR"
|
ynh_setup_source "$DESTDIR"
|
||||||
|
|
||||||
# Copy and edit config.php
|
# Copy and edit config.php
|
||||||
sudo cp ../conf/config.php ${DESTDIR}
|
cp ../conf/config.php ${DESTDIR}
|
||||||
sudo sed -i "s/yuno_dbpdw/${dbpass}/g" ${DESTDIR}/config.php
|
sed -i "s/yuno_dbpdw/${dbpass}/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/yuno_dbuser/${dbuser}/g" ${DESTDIR}/config.php
|
sed -i "s/yuno_dbuser/${dbuser}/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/yuno_admin/${admin}/g" ${DESTDIR}/config.php
|
sed -i "s/yuno_admin/${admin}/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/yuno_email/${email}/g" ${DESTDIR}/config.php
|
sed -i "s/yuno_email/${email}/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/yuno_domain/${domain}/g" ${DESTDIR}/config.php
|
sed -i "s/yuno_domain/${domain}/g" ${DESTDIR}/config.php
|
||||||
|
|
||||||
# Set permissions to kanboard and data directory
|
# Set permissions to kanboard and data directory
|
||||||
sudo chown -R root:root ${DESTDIR}
|
chown -R root:root ${DESTDIR}
|
||||||
sudo chown -R www-data ${DESTDIR}/{data,plugins}
|
chown -R www-data ${DESTDIR}/{data,plugins}
|
||||||
|
|
||||||
# Copy and set php-fpm configuration
|
# Copy and set php-fpm configuration
|
||||||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
||||||
sed -i "s@#POOLNAME#@${app}@g" ../conf/php-fpm.conf
|
sed -i "s@#POOLNAME#@${app}@g" ../conf/php-fpm.conf
|
||||||
sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf
|
sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf
|
||||||
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
cp ../conf/php-fpm.conf "$phpfpm_conf"
|
||||||
sudo chown root: $phpfpm_conf
|
chown root: $phpfpm_conf
|
||||||
sudo chmod 644 $phpfpm_conf
|
chmod 644 $phpfpm_conf
|
||||||
|
|
||||||
finalnginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
finalnginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ finalnginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
sed -i "s@NAMETOCHANGE@${app}@g" ../conf/nginx.conf*
|
sed -i "s@NAMETOCHANGE@${app}@g" ../conf/nginx.conf*
|
||||||
sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf*
|
sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf*
|
||||||
sed -i "s@ALIASTOCHANGE@${DESTDIR}/@g" ../conf/nginx.conf*
|
sed -i "s@ALIASTOCHANGE@${DESTDIR}/@g" ../conf/nginx.conf*
|
||||||
sudo cp ../conf/nginx.conf "$finalnginxconf"
|
cp ../conf/nginx.conf "$finalnginxconf"
|
||||||
|
|
||||||
if [ "$path" == "/" ]
|
if [ "$path" == "/" ]
|
||||||
then
|
then
|
||||||
|
@ -85,17 +85,17 @@ fi
|
||||||
# Make app public or private
|
# Make app public or private
|
||||||
if [[ "$is_public" -eq 1 ]];
|
if [[ "$is_public" -eq 1 ]];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting ${app} unprotected_uris -v "/"
|
yunohost app setting ${app} unprotected_uris -v "/"
|
||||||
sudo sed -i "s/define('LDAP_AUTH'.*$/define('LDAP_AUTH', true);/g" ${DESTDIR}/config.php
|
sed -i "s/define('LDAP_AUTH'.*$/define('LDAP_AUTH', true);/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/define('HIDE_LOGIN_FORM'.*$/define('HIDE_LOGIN_FORM', false);/g" ${DESTDIR}/config.php
|
sed -i "s/define('HIDE_LOGIN_FORM'.*$/define('HIDE_LOGIN_FORM', false);/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/define('REMEMBER_ME_AUTH'.*$/define('REMEMBER_ME_AUTH', true);/g" ${DESTDIR}/config.php
|
sed -i "s/define('REMEMBER_ME_AUTH'.*$/define('REMEMBER_ME_AUTH', true);/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/define('DISABLE_LOGOUT'.*$/define('DISABLE_LOGOUT', false);/g" ${DESTDIR}/config.php
|
sed -i "s/define('DISABLE_LOGOUT'.*$/define('DISABLE_LOGOUT', false);/g" ${DESTDIR}/config.php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Init database
|
# Init database
|
||||||
#sudo chmod o+x ${DESTDIR} ${DESTDIR}/app/ ${DESTDIR}/app/Schema/ ${DESTDIR}/app/Schema/Sql
|
#chmod o+x ${DESTDIR} ${DESTDIR}/app/ ${DESTDIR}/app/Schema/ ${DESTDIR}/app/Schema/Sql
|
||||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ${DESTDIR}/app/Schema/Sql/mysql.sql
|
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ${DESTDIR}/app/Schema/Sql/mysql.sql
|
||||||
|
|
||||||
# Reload services
|
# Reload services
|
||||||
sudo service php5-fpm restart || true
|
service php5-fpm restart || true
|
||||||
sudo service nginx reload || true
|
service nginx reload || true
|
||||||
|
|
|
@ -19,10 +19,10 @@ ynh_mysql_drop_user "$dbuser" 2>/dev/null || true
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
|
|
||||||
# Delete app directory and configurations
|
# Delete app directory and configurations
|
||||||
sudo rm -rf "/var/www/${app}"
|
rm -rf "/var/www/${app}"
|
||||||
sudo rm -f "/etc/php5/fpm/pool.d/${app}.conf"
|
rm -f "/etc/php5/fpm/pool.d/${app}.conf"
|
||||||
[[ -n $domain ]] && sudo rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
[[ -n $domain ]] && rm -f "/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
|
|
||||||
# Reload services
|
# Reload services
|
||||||
sudo service php5-fpm restart || true
|
service php5-fpm restart || true
|
||||||
sudo service nginx reload || true
|
service nginx reload || true
|
||||||
|
|
|
@ -21,7 +21,7 @@ path=$(ynh_app_setting_get "$app" path)
|
||||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||||
|
|
||||||
# TODO: Check domain/path availability with app helper
|
# TODO: Check domain/path availability with app helper
|
||||||
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
|
yunohost app checkurl "${domain}${path}" -a "$app" \
|
||||||
|| ynh_die "The path ${domain}${path} is not available for app installation."
|
|| ynh_die "The path ${domain}${path} is not available for app installation."
|
||||||
|
|
||||||
# Check destination directory
|
# Check destination directory
|
||||||
|
@ -41,20 +41,20 @@ phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
||||||
You should safely delete it before restoring this app."
|
You should safely delete it before restoring this app."
|
||||||
|
|
||||||
# Restore the app files
|
# Restore the app files
|
||||||
sudo cp -a ./www "$DESTDIR"
|
cp -a ./www "$DESTDIR"
|
||||||
|
|
||||||
# Create and restore the database
|
# Create and restore the database
|
||||||
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
|
||||||
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
|
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./db.sql
|
||||||
|
|
||||||
# Restore permissions
|
# Restore permissions
|
||||||
sudo chown -R root:root "$DESTDIR"
|
chown -R root:root "$DESTDIR"
|
||||||
sudo chown -R www-data ${DESTDIR}/{data,plugins}
|
chown -R www-data ${DESTDIR}/{data,plugins}
|
||||||
|
|
||||||
# Restore configuration files
|
# Restore configuration files
|
||||||
sudo cp -a ./conf/nginx.conf "$nginx_conf"
|
cp -a ./conf/nginx.conf "$nginx_conf"
|
||||||
sudo cp -a ./conf/php-fpm.conf "$phpfpm_conf"
|
cp -a ./conf/php-fpm.conf "$phpfpm_conf"
|
||||||
|
|
||||||
# Reload services
|
# Reload services
|
||||||
sudo service php5-fpm restart || true
|
service php5-fpm restart || true
|
||||||
sudo service nginx reload || true
|
service nginx reload || true
|
||||||
|
|
|
@ -22,7 +22,7 @@ source /usr/share/yunohost/helpers
|
||||||
domain=$(ynh_app_setting_get "$app" domain)
|
domain=$(ynh_app_setting_get "$app" domain)
|
||||||
path=$(ynh_app_setting_get "$app" path)
|
path=$(ynh_app_setting_get "$app" path)
|
||||||
admin=$(ynh_app_setting_get "$app" adminusername)
|
admin=$(ynh_app_setting_get "$app" adminusername)
|
||||||
email=$(sudo yunohost user info $admin | grep mail: | sed "s/mail: //g")
|
email=$(yunohost user info $admin | grep mail: | sed "s/mail: //g")
|
||||||
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||||
is_public=$(ynh_app_setting_get "$app" is_public)
|
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||||
if [ -z $is_public ]
|
if [ -z $is_public ]
|
||||||
|
@ -38,38 +38,38 @@ DESTDIR="/var/www/$app"
|
||||||
The app is not correctly installed, you should remove it first."
|
The app is not correctly installed, you should remove it first."
|
||||||
|
|
||||||
# flush php sessions before upgrade
|
# flush php sessions before upgrade
|
||||||
sudo rm -rf /var/lib/php5/session/*
|
rm -rf /var/lib/php5/session/*
|
||||||
|
|
||||||
# Move old app dir
|
# Move old app dir
|
||||||
sudo mv ${DESTDIR} ${DESTDIR}.old
|
mv ${DESTDIR} ${DESTDIR}.old
|
||||||
|
|
||||||
ynh_setup_source "$DESTDIR"
|
ynh_setup_source "$DESTDIR"
|
||||||
|
|
||||||
# restore data
|
# restore data
|
||||||
sudo cp -a ${DESTDIR}.old/data ${DESTDIR}
|
cp -a ${DESTDIR}.old/data ${DESTDIR}
|
||||||
|
|
||||||
# restore plugins
|
# restore plugins
|
||||||
if [ -e ${DESTDIR}.old/plugins ]
|
if [ -e ${DESTDIR}.old/plugins ]
|
||||||
then
|
then
|
||||||
sudo cp -a ${DESTDIR}.old/plugins ${DESTDIR}
|
cp -a ${DESTDIR}.old/plugins ${DESTDIR}
|
||||||
fi
|
fi
|
||||||
# delete temp directory
|
# delete temp directory
|
||||||
sudo rm -Rf ${DESTDIR}.old
|
rm -Rf ${DESTDIR}.old
|
||||||
|
|
||||||
# Copy and edit config.php
|
# Copy and edit config.php
|
||||||
sudo cp ../conf/config.php ${DESTDIR}
|
cp ../conf/config.php ${DESTDIR}
|
||||||
sudo sed -i "s/yuno_dbpdw/${dbpass}/g" ${DESTDIR}/config.php
|
sed -i "s/yuno_dbpdw/${dbpass}/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/yuno_dbuser/${dbuser}/g" ${DESTDIR}/config.php
|
sed -i "s/yuno_dbuser/${dbuser}/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/yuno_admin/${admin}/g" ${DESTDIR}/config.php
|
sed -i "s/yuno_admin/${admin}/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/yuno_email/${email}/g" ${DESTDIR}/config.php
|
sed -i "s/yuno_email/${email}/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/yuno_domain/${domain}/g" ${DESTDIR}/config.php
|
sed -i "s/yuno_domain/${domain}/g" ${DESTDIR}/config.php
|
||||||
|
|
||||||
# Set permissions to kanboard and data directory
|
# Set permissions to kanboard and data directory
|
||||||
sudo chown -R root:root ${DESTDIR}
|
chown -R root:root ${DESTDIR}
|
||||||
sudo chown -R www-data ${DESTDIR}/{data,plugins}
|
chown -R www-data ${DESTDIR}/{data,plugins}
|
||||||
|
|
||||||
# Launch database migration
|
# Launch database migration
|
||||||
sudo ${DESTDIR}/cli db:migrate
|
${DESTDIR}/cli db:migrate
|
||||||
|
|
||||||
# Copy and set php-fpm configuration
|
# Copy and set php-fpm configuration
|
||||||
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
phpfpm_conf="/etc/php5/fpm/pool.d/${app}.conf"
|
||||||
|
@ -77,9 +77,9 @@ sed -i "s@#USER#@${app}@g" ../conf/php-fpm.conf
|
||||||
sed -i "s@#GROUP#@${app}@g" ../conf/php-fpm.conf
|
sed -i "s@#GROUP#@${app}@g" ../conf/php-fpm.conf
|
||||||
sed -i "s@#POOLNAME#@${app}@g" ../conf/php-fpm.conf
|
sed -i "s@#POOLNAME#@${app}@g" ../conf/php-fpm.conf
|
||||||
sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf
|
sed -i "s@#DESTDIR#@${DESTDIR}/@g" ../conf/php-fpm.conf
|
||||||
sudo cp ../conf/php-fpm.conf "$phpfpm_conf"
|
cp ../conf/php-fpm.conf "$phpfpm_conf"
|
||||||
sudo chown root: $phpfpm_conf
|
chown root: $phpfpm_conf
|
||||||
sudo chmod 644 $phpfpm_conf
|
chmod 644 $phpfpm_conf
|
||||||
|
|
||||||
finalnginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
finalnginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ finalnginxconf="/etc/nginx/conf.d/${domain}.d/${app}.conf"
|
||||||
sed -i "s@NAMETOCHANGE@${app}@g" ../conf/nginx.conf*
|
sed -i "s@NAMETOCHANGE@${app}@g" ../conf/nginx.conf*
|
||||||
sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf*
|
sed -i "s@PATHTOCHANGE@${path}@g" ../conf/nginx.conf*
|
||||||
sed -i "s@ALIASTOCHANGE@${DESTDIR}/@g" ../conf/nginx.conf*
|
sed -i "s@ALIASTOCHANGE@${DESTDIR}/@g" ../conf/nginx.conf*
|
||||||
sudo cp ../conf/nginx.conf "$finalnginxconf"
|
cp ../conf/nginx.conf "$finalnginxconf"
|
||||||
|
|
||||||
if [ "$path" == "/" ]
|
if [ "$path" == "/" ]
|
||||||
then
|
then
|
||||||
|
@ -98,13 +98,13 @@ fi
|
||||||
# Make app public or private
|
# Make app public or private
|
||||||
if [[ "$is_public" -eq 1 ]];
|
if [[ "$is_public" -eq 1 ]];
|
||||||
then
|
then
|
||||||
sudo yunohost app setting ${app} unprotected_uris -v "/"
|
yunohost app setting ${app} unprotected_uris -v "/"
|
||||||
sudo sed -i "s/define('LDAP_AUTH'.*$/define('LDAP_AUTH', true);/g" ${DESTDIR}/config.php
|
sed -i "s/define('LDAP_AUTH'.*$/define('LDAP_AUTH', true);/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/define('HIDE_LOGIN_FORM'.*$/define('HIDE_LOGIN_FORM', false);/g" ${DESTDIR}/config.php
|
sed -i "s/define('HIDE_LOGIN_FORM'.*$/define('HIDE_LOGIN_FORM', false);/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/define('REMEMBER_ME_AUTH'.*$/define('REMEMBER_ME_AUTH', true);/g" ${DESTDIR}/config.php
|
sed -i "s/define('REMEMBER_ME_AUTH'.*$/define('REMEMBER_ME_AUTH', true);/g" ${DESTDIR}/config.php
|
||||||
sudo sed -i "s/define('DISABLE_LOGOUT'.*$/define('DISABLE_LOGOUT', false);/g" ${DESTDIR}/config.php
|
sed -i "s/define('DISABLE_LOGOUT'.*$/define('DISABLE_LOGOUT', false);/g" ${DESTDIR}/config.php
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Reload services
|
# Reload services
|
||||||
sudo service php5-fpm restart || true
|
service php5-fpm restart || true
|
||||||
sudo service nginx reload || true
|
service nginx reload || true
|
||||||
|
|
Loading…
Reference in a new issue