1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/ampache_ynh.git synced 2024-09-03 18:15:55 +02:00

update ampache to 3.8.2 and do yunohost 2.4 compatibility

This commit is contained in:
aymhce 2016-06-04 21:19:05 +02:00
parent 46af7c5eed
commit dae9885b3a
4 changed files with 46 additions and 37 deletions

View file

@ -12,6 +12,9 @@
"email": "beudbeud@beudibox.fr"
},
"multi_instance": "true",
"requirements": {
"yunohost": ">> 2.3.12.1"
},
"services" : [
"nginx",
"php5-fpm",

View file

@ -1,14 +1,18 @@
#!/bin/bash
# Retrieve arguments
app=$YNH_APP_INSTANCE_NAME
domain=$1
path=$2
admin_ampache=$3
debianversionname=$(lsb_release -a | grep Codename | awk -F' ' '{print $2}')
# Source YunoHost helpers
. /usr/share/yunohost/helpers
#debianversionname=$(lsb_release -a | grep Codename | awk -F' ' '{print $2}')
# Check domain/path availability
sudo yunohost app checkurl $domain$path -a ampache
sudo yunohost app checkurl $domain$path -a $app
if [[ ! $? -eq 0 ]]; then
exit 1
fi
@ -26,14 +30,16 @@ sudo yunohost app setting ampache admin -v $admin_ampache
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 'ampache' as database name and user
db_user=ampache
db_user=$app
# Initialize database and store mysql password for upgrade
sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e ../sources/sql/ampache.sql)
sudo yunohost app setting ampache mysqlpwd -v $db_pwd
#sudo yunohost app initdb $db_user -p $db_pwd -s $(readlink -e ../sources/sql/ampache.sql)
sudo yunohost app setting $app mysqlpwd -v $db_pwd
ynh_mysql_create_db "$app" "$db_user" "$db_pwd"
ynh_mysql_connect_as "$db_user" "$db_pwd" "$app" < "../sources/sql/ampache.sql"
# Copy files to the right place
final_path=/var/www/ampache
final_path=/var/www/$app
sudo mkdir -p $final_path/log
sudo cp -a ../sources/* $final_path
sudo cp ../conf/ampache.cfg.php $final_path/config/ampache.cfg.php
@ -55,29 +61,32 @@ sudo 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*
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/ampache.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app setting ampache skipped_uris -v "/"
sudo yunohost app setting $app skipped_uris -v "/"
sudo yunohost app ssowatconf
# Install dependency
sudo apt-get install ffmpeg -y
sudo apt-get install libav-tools -y
# Ampache installation
cd /var/www/$app
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php
sudo php composer.phar install --prefer-source --no-interaction
echo "127.0.0.1 $domain #yunoampache" | sudo tee -a /etc/hosts
sleep 1
curl -kL -X POST http://$domain${path%/}/update.php?action=update > /dev/null 2>&1
sleep 5
[ "$debianversionname" == "wheezy" ] && \
sudo sed -i 's/;transcode_cmd = "ffmpeg"/transcode_cmd = "ffmpeg"/g' /var/www/ampache/config/ampache.cfg.php && \
sudo sed -i 's/^transcode_cmd = "avconv"/;transcode_cmd = "avconv"/g' /var/www/ampache/config/ampache.cfg.php
sudo yunohost app setting ampache skipped_uris -d
sudo yunohost app setting ampache skipped_uris -v "/rest"
sudo yunohost app setting $app skipped_uris -d
sudo yunohost app setting $app skipped_uris -v "/rest"
sudo yunohost app ssowatconf
sudo sed '/yunoampache/d' /etc/hosts > /tmp/hosts.tmp
sudo cp /tmp/hosts.tmp /etc/hosts ; sudo rm -f /tmp/hosts.tmp
mysql -u $db_user -p$db_pwd $db_user < /tmp/admin.sql
ynh_mysql_connect_as "$db_user" "$db_pwd" "$app" < /tmp/admin.sql
sudo rm /tmp/admin.sql

View file

@ -1,16 +1,17 @@
#!/bin/bash
db_user=ampache
db_name=ampache
app=$YNH_APP_INSTANCE_NAME
db_user=$app
db_name=$app
root_pwd=$(sudo cat /etc/yunohost/mysql)
domain=$(sudo yunohost app setting ampache domain)
domain=$(sudo yunohost app setting $app domain)
# Drop MySQL database
mysql -u root -p$root_pwd -e "DROP DATABASE $db_name ; DROP USER $db_user@localhost ;"
# Remove sources
sudo rm -rf /var/www/ampache
sudo rm -rf /var/www/$app
# Remove Nginx configuration and reload Nginx conf
sudo rm -f /etc/nginx/conf.d/$domain.d/ampache.conf
sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
sudo service nginx reload

View file

@ -1,20 +1,18 @@
#!/bin/bash
debianversionname=$(lsb_release -a | grep Codename | awk -F' ' '{print $2}')
# Retrieve arguments
domain=$(sudo yunohost app setting ampache domain)
path=$(sudo yunohost app setting ampache path)
db_user=ampache
db_pwd=$(sudo yunohost app setting ampache mysqlpwd)
admin_ampache=$(sudo yunohost app setting ampache admin)
app=$YNH_APP_INSTANCE_NAME
domain=$(sudo yunohost app setting $app domain)
path=$(sudo yunohost app setting $app path)
db_user=$app
db_pwd=$(sudo yunohost app setting $app mysqlpwd)
admin_ampache=$(sudo yunohost app setting $app admin)
# first make a copy of the db
# mysqldump -u $db_user -p$db_pwd --add-drop-table --allow-keywords ampache > $final_path/ampache-db-backup.sql
# mysqldump -u $db_user -p$db_pwd --add-drop-table --allow-keywords $app > $final_path/ampache-db-backup.sql
# Copy files to the right place
final_path=/var/www/ampache
final_path=/var/www/$app
sudo cp -a ../sources/* $final_path
sudo cp ../conf/ampache.cfg.php $final_path/config/ampache.cfg.php
@ -32,12 +30,12 @@ sudo 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*
sed -i "s@ALIASTOCHANGE@$final_path/@g" ../conf/nginx.conf*
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/ampache.conf
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
# Reload Nginx and regenerate SSOwat conf
sudo service nginx reload
sudo yunohost app setting ampache skipped_uris -v "/"
sudo yunohost app setting $app skipped_uris -v "/"
sudo yunohost app ssowatconf
# Ampache installation
@ -45,11 +43,9 @@ echo "127.0.0.1 $domain #yunoampache" | sudo tee -a /etc/hosts
sleep 1
curl -kL -X POST http://$domain${path%/}/update.php?action=update > /dev/null 2>&1
sleep 5
[ "$debianversionname" == "wheezy" ] && \
sudo sed -i 's/;transcode_cmd = "ffmpeg"/transcode_cmd = "ffmpeg"/g' /var/www/ampache/config/ampache.cfg.php && \
sudo sed -i 's/^transcode_cmd = "avconv"/;transcode_cmd = "avconv"/g' /var/www/ampache/config/ampache.cfg.php
sudo yunohost app setting ampache skipped_uris -d
sudo yunohost app setting ampache skipped_uris -v "/rest"
sudo yunohost app setting $app skipped_uris -d
sudo yunohost app setting $app skipped_uris -v "/rest"
sudo yunohost app ssowatconf
sudo sed '/yunoampache/d' /etc/hosts > /tmp/hosts.tmp
sudo cp /tmp/hosts.tmp /etc/hosts ; sudo rm -f /tmp/hosts.tmp