1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/diaspora_ynh.git synced 2024-09-03 18:26:13 +02:00

Add new helpers

This commit is contained in:
Rafi59 2017-06-09 13:06:41 +02:00 committed by GitHub
parent bcd1fd3a37
commit 79a613531c

View file

@ -1,18 +1,23 @@
#!/bin/bash #!/bin/bash
# Exit on command errors and treat unset variables as an error
set -eu
# Retrieve arguments # Retrieve arguments
domain=$1 domain=$YUNOHOST_APP_ARG_DOMAIN
is_public=$2 is_public=$YUNOHOST_APP_ARG_IS_PUBLIC
# Save app settings
ynh_app_setting_set "$app" is_public "$is_public"
# Source YunoHost helpers # Source YunoHost helpers
. /usr/share/yunohost/helpers . /usr/share/yunohost/helpers
# Check domain/path availability # Check domain/path availability
sudo yunohost app checkurl $domain -a diaspora sudo yunohost app checkurl $domain -a "$app" \
if [[ ! $? -eq 0 ]] || ynh_die "Domain not available: ${domain}${path_url}"
then
exit 1
fi
ori_path=$(pwd) ori_path=$(pwd)
final_path=/var/www/diaspora final_path=/var/www/diaspora
@ -28,7 +33,7 @@ sudo apt-get install -y -- \
libmagickwand-dev nodejs-legacy npm redis-server libmagickwand-dev nodejs-legacy npm redis-server
# Get source code # Get source code
git clone -b master git://github.com/diaspora/diaspora.git git clone -b master https://github.com/diaspora/diaspora
echo $(pwd) echo $(pwd)
@ -37,15 +42,21 @@ tar -cf source.tar.gz diaspora/
mv source.tar.gz diaspora/public/source.tar.gz mv source.tar.gz diaspora/public/source.tar.gz
sudo cp -ar diaspora $final_path/../. sudo cp -ar diaspora $final_path/../.
# Generate random password ### MySQL ###
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') # If your app use a MySQL database you can use these lines to bootstrap
# a database, an associated user and save the password in app settings.
# Use 'diaspora' as database name and user # Generate MySQL password and create database
db_user=diaspora dbuser=$app
dbname=$app
dbpass=$(ynh_string_random 12)
ynh_app_setting_set "$app" mysqlpwd "$dbpass"
ynh_mysql_create_db "$dbname" "$dbuser" "$dbpass"
# Initialize database and store mysql password for upgrade # Load initial SQL into the new database
sudo yunohost app setting diaspora mysqlpwd -v "$db_pwd" ynh_mysql_connect_as "$dbuser" "$dbpass" "$dbname" \
ynh_mysql_create_db diaspora_production "$db_user" "$db_pwd" # < "../sources/sql/mysql.init.sql"
### MySQL end ###
# prepare and copy diaspora config file # prepare and copy diaspora config file
sed -i "s@FULLURLTOCHANGE@$full_url@g" ../conf/diaspora.yml sed -i "s@FULLURLTOCHANGE@$full_url@g" ../conf/diaspora.yml