1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/opensondage_ynh.git synced 2024-09-03 19:46:28 +02:00

Remove sudo

This commit is contained in:
Jean-Baptiste Holcroft 2017-10-25 14:26:24 +02:00
parent 2c9d01efe1
commit 0629397837
5 changed files with 65 additions and 66 deletions

View file

@ -8,7 +8,6 @@ exec_as() {
then
eval $@
else
# use sudo twice to be root and be allowed to use another user
sudo -u "$USER" $@
fi
}

View file

@ -42,12 +42,12 @@ ynh_app_setting_set "$app" is_public "$is_public"
ynh_app_setting_set "$app" public_site "$is_public"
# Check domain/path availability
sudo yunohost app checkurl "${domain}${path}" -a "$app" \
yunohost app checkurl "${domain}${path}" -a "$app" \
|| ynh_die "Path not available: ${domain}${path}"
# Copy files to the right place
final_path=/var/www/$app
sudo mkdir -p $final_path
mkdir -p $final_path
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -65,7 +65,7 @@ ynh_app_setting_set "$app" mysqlpwd "$dbpass"
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
config="$final_path/app/inc/config.php"
sudo cp ../conf/config.php $config
cp ../conf/config.php $config
# Change variables in configuration
ynh_replace_string "__DBUSER__" "$dbuser" $config
@ -80,39 +80,39 @@ cp ../img/logo.png $final_path/images
# Create log file
touch $final_path/admin/stdout.log
sudo chmod 700 $final_path/admin/stdout.log
chmod 700 $final_path/admin/stdout.log
# Set permissions
sudo chown -R www-data: $final_path
chown -R www-data: $final_path
init_composer "www-data" "$final_path"
sudo -u "www-data" php "$final_path/admin/migration.php"
-u "www-data" php "$final_path/admin/migration.php"
# Modify PHP-FPM pool configuration and copy it to the pool directory
sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf
sudo chmod 644 $finalphpconf
cp ../conf/php-fpm.conf $finalphpconf
chown root: $finalphpconf
chmod 644 $finalphpconf
finalphpini=/etc/php5/fpm/conf.d/20-$app.ini
sudo cp ../conf/php-fpm.ini $finalphpini
sudo chown root: $finalphpini
sudo chmod 644 $finalphpini
cp ../conf/php-fpm.ini $finalphpini
chown root: $finalphpini
chmod 644 $finalphpini
# Reload Nginx and regenerate SSOwat conf
sudo service php5-fpm restart
service php5-fpm restart
ynh_package_install php-fpdf
sudo yunohost app addaccess $app -u $admin
yunohost app addaccess $app -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
sed -i "s@YNH_APP_INSTANCE_NAME@$app@g" ../conf/nginx.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
service nginx reload
ynh_app_setting_set "$app" skipped_uris "/"
if [[ $is_public -eq 0 ]];
then
@ -120,4 +120,4 @@ then
else
ynh_app_setting_set "$app" protected_uris "/admin/index.php,/admin/logs_studs.txt,/scripts"
fi
sudo yunohost app ssowatconf
yunohost app ssowatconf

View file

@ -19,14 +19,14 @@ app=$YNH_APP_INSTANCE_NAME
domain=$(ynh_app_setting_get "$app" domain)
# Remove sources
sudo rm -rf /var/www/$app
rm -rf /var/www/$app
# Remove configuration files
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
rm -f /etc/nginx/conf.d/$domain.d/$app.conf
sudo rm -f /etc/php5/fpm/pool.d/$app.conf
sudo rm -f /etc/php5/fpm/conf.d/20-$app.ini
sudo service php5-fpm reload
rm -f /etc/php5/fpm/pool.d/$app.conf
rm -f /etc/php5/fpm/conf.d/20-$app.ini
service php5-fpm reload
# Drop MySQL database and user
dbname=$app
@ -34,4 +34,4 @@ dbuser=$app
ynh_mysql_drop_db "$dbname" || true
ynh_mysql_drop_user "$dbuser" || true
sudo service nginx reload
service nginx reload

View file

@ -37,7 +37,7 @@ public_site=$(ynh_app_setting_get "$app" public_site)
legal=$(ynh_app_setting_get "$app" legal)
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a $app \
yunohost app checkurl $domain$path -a $app \
|| ynh_die "Path not available: ${domain}${path}"
@ -74,26 +74,26 @@ ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" < ./dump.sql
# Set permissions
sudo chmod 700 $final_path/admin/logs_studs.txt
sudo chown -R www-data:www-data $final_path
chmod 700 $final_path/admin/logs_studs.txt
chown -R www-data:www-data $final_path
# Restore conf files
sudo cp -a ./nginx.conf $conf
sudo cp -a ./php-fpm.conf $phpconf
sudo chown root: $phpconf
sudo chmod 644 $phpconf
sudo cp -a ./php-fpm.ini $phpini
sudo chown root: $phpini
sudo chmod 644 $phpini
cp -a ./nginx.conf $conf
cp -a ./php-fpm.conf $phpconf
chown root: $phpconf
chmod 644 $phpconf
cp -a ./php-fpm.ini $phpini
chown root: $phpini
chmod 644 $phpini
# Set Administrator
if ynh_user_exists $admin; then
sudo yunohost app addaccess $app -u $admin
yunohost app addaccess $app -u $admin
fi
# Reload Nginx
sudo service php5-fpm restart
sudo service nginx reload
service php5-fpm restart
service nginx reload
# Set ssowat config
ynh_app_setting_set "$app" skipped_uris "/"
@ -103,4 +103,4 @@ then
else
ynh_app_setting_set "$app" protected_uris "/admin/index.php,/admin/logs_studs.txt,/scripts"
fi
sudo yunohost app ssowatconf
yunohost app ssowatconf

View file

@ -44,7 +44,7 @@ fi
language=$(ynh_app_setting_get "$app" language)
if [[ "$language" = "" ]];
then
language=$(sudo grep LANGUE /var/www/$app/variables.php | grep -Po "'.*?'" | cut -d"'" -f2)
language=$(grep LANGUE /var/www/$app/variables.php | grep -Po "'.*?'" | cut -d"'" -f2)
fi
# Check if admin is not null
@ -55,7 +55,7 @@ fi
# Remove trailing "/" for next commands
path=${path%/}
root_pwd=$(sudo cat /etc/yunohost/mysql)
root_pwd=$(cat /etc/yunohost/mysql)
dbname=$app
dbpass=$(ynh_app_setting_get "$app" mysqlpwd)
dbuser=$app
@ -63,9 +63,9 @@ dbuser=$app
### Execute potential SQL statements here
# Copy files to the right place
final_path=/var/www/$app
sudo cp $final_path/admin/logs_studs.txt ../conf/
sudo rm -Rf $final_path
sudo mkdir -p $final_path
cp $final_path/admin/logs_studs.txt ../conf/
rm -Rf $final_path
mkdir -p $final_path
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
@ -75,24 +75,24 @@ ynh_app_setting_set "$app" final_path "$final_path"
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source "$final_path"
sudo cp ../conf/constants.php.template $final_path/app/inc/constants.php
cp ../conf/constants.php.template $final_path/app/inc/constants.php
# Change variables in configuration
sudo sed -i "s/yunouser/$dbuser/g" $final_path/app/inc/constants.php
sudo sed -i "s/yunopass/$dbpass/g" $final_path/app/inc/constants.php
sudo sed -i "s/yunobase/$dbname/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
sed -i "s/yunouser/$dbuser/g" $final_path/app/inc/constants.php
sed -i "s/yunopass/$dbpass/g" $final_path/app/inc/constants.php
sed -i "s/yunobase/$dbname/g" $final_path/app/inc/constants.php
sed -i "s/yunoadmin/$admin/g" $final_path/app/inc/constants.php
sed -i "s/I18NTOCHANGE/$language/g" $final_path/app/inc/constants.php
sed -i "s@yunourl@$domain$path@g" $final_path/app/inc/constants.php
sed -i "s@yunodomain@$domain@g" $final_path/app/inc/constants.php
sed -i "s@yunoabout@$legal@g" $final_path/app/inc/constants.php
# Create log file
sudo cp ../conf/logs_studs.txt $final_path/admin/
sudo chmod 700 $final_path/admin/logs_studs.txt
cp ../conf/logs_studs.txt $final_path/admin/
chmod 700 $final_path/admin/logs_studs.txt
# Set permissions to roundcube directory
sudo chown -R www-data: $final_path
chown -R www-data: $final_path
# Modify Nginx configuration file and copy it to Nginx conf directory
sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf
@ -100,24 +100,24 @@ sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf
sed -i "s@YNH_APP_INSTANCE_NAME@$app@g" ../conf/nginx.conf
if ynh_user_exists $admin; then
sudo yunohost app addaccess $app -u $admin
yunohost app addaccess $app -u $admin
fi
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
sed -i "s@NAMETOCHANGE@$app@g" ../conf/php-fpm.conf
finalphpconf=/etc/php5/fpm/pool.d/$app.conf
sudo cp ../conf/php-fpm.conf $finalphpconf
sudo chown root: $finalphpconf
sudo chmod 644 $finalphpconf
cp ../conf/php-fpm.conf $finalphpconf
chown root: $finalphpconf
chmod 644 $finalphpconf
finalphpini=/etc/php5/fpm/conf.d/20-$app.ini
sudo cp ../conf/php-fpm.ini $finalphpini
sudo chown root: $finalphpini
sudo chmod 644 $finalphpini
cp ../conf/php-fpm.ini $finalphpini
chown root: $finalphpini
chmod 644 $finalphpini
sudo service php5-fpm restart
service php5-fpm restart
# Reload Nginx
sudo service nginx reload
service nginx reload
ynh_app_setting_set "$app" skipped_uris "/"
if [ $is_public -eq 0 ];
then
@ -125,4 +125,4 @@ then
else
ynh_app_setting_set "$app" protected_uris "/admin/index.php,/admin/logs_studs.txt,/scripts"
fi
sudo yunohost app ssowatconf
yunohost app ssowatconf