-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
global upgrade for yunohost package_linter and ampache 3.8.3
- Loading branch information
Showing
13 changed files
with
3,227 additions
and
306 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/bin/bash | ||
|
||
# Copy files to the right place | ||
ampache_ynh_getsources () { | ||
version=$(cat upstream_version) | ||
|
||
final_path=/var/www/$app | ||
sudo mkdir -p $final_path/log | ||
|
||
sudo wget -O ../ampache.tar.gz https://github.com/ampache/ampache/archive/$version.tar.gz > /dev/null 2>&1 | ||
sudo tar xvzf ../ampache.tar.gz -C .. > /dev/null 2>&1 | ||
sudo cp -ar ../ampache-$version/. $final_path | ||
|
||
sudo cp ../conf/ampache.cfg.php $final_path/config/ampache.cfg.php | ||
} | ||
|
||
# Change variables in Ampache configuration | ||
ampache_ynh_prepareconfig () { | ||
sudo sed -i "s/yunouser/$app/g" $final_path/config/ampache.cfg.php | ||
sudo sed -i "s/yunopass/$db_pwd/g" $final_path/config/ampache.cfg.php | ||
sudo sed -i "s/yunobase/$app/g" $final_path/config/ampache.cfg.php | ||
sudo sed -i "s@PATHTOCHANGE@${path%/}@g" $final_path/config/ampache.cfg.php | ||
sudo sed -i "s@DOMAINTOCHANGE@$domain@g" $final_path/config/ampache.cfg.php | ||
} | ||
|
||
# Modify Nginx configuration file and copy it to Nginx conf directory | ||
ampache_ynh_preparenginx () { | ||
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/$app.conf | ||
} | ||
|
||
# Ampache installation | ||
ampache_ynh_install () { | ||
ORIPATH=$(pwd) | ||
cd $final_path | ||
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 | ||
# Set permissions to ampache directory | ||
sudo chown -R www-data: $final_path | ||
cd $ORIPATH | ||
} | ||
|
||
# Reload Nginx and regenerate SSOwat conf | ||
ampache_ynh_reloadservices () { | ||
sudo service nginx reload | ||
ynh_app_setting_set $app skipped_uris "/" | ||
sudo yunohost app ssowatconf | ||
} | ||
|
||
# Pre config ampache | ||
ampache_ynh_doconfig () { | ||
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 | ||
sudo sed '/yunoampache/d' /etc/hosts > /tmp/hosts.tmp | ||
sudo cp /tmp/hosts.tmp /etc/hosts ; sudo rm -f /tmp/hosts.tmp | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
. /usr/share/yunohost/helpers | ||
|
||
app=$YNH_APP_INSTANCE_NAME | ||
|
||
domain=$(ynh_app_setting_get "$app" domain) | ||
path=$(ynh_app_setting_get "$app" path) | ||
admin=$(ynh_app_setting_get "$app" admin) | ||
|
||
ynh_backup "/var/www/$app" "sources" 1 | ||
|
||
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf" "conf/nginx.conf" | ||
|
||
ynh_mysql_dump_db "$app" > db.sql | ||
#ynh_backup "db.sql" "db.sql" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,92 +1,65 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
# Retrieve arguments | ||
app=$YNH_APP_INSTANCE_NAME | ||
domain=$1 | ||
path=$2 | ||
admin_ampache=$3 | ||
domain=$YNH_APP_ARG_DOMAIN | ||
path=$YNH_APP_ARG_PATH | ||
admin_ampache=$YNH_APP_ARG_ADMIN | ||
|
||
# Source YunoHost helpers | ||
# Source helpers | ||
. /usr/share/yunohost/helpers | ||
. _common | ||
|
||
# Check if admin exists | ||
sudo yunohost user list --json | grep -qi "\"username\": \"$admin_ampache\"" || ynh_die "wrong admin username" | ||
|
||
#debianversionname=$(lsb_release -a | grep Codename | awk -F' ' '{print $2}') | ||
ynh_app_setting_set $app admin $admin_ampache | ||
|
||
# Check domain/path availability | ||
sudo yunohost app checkurl $domain$path -a $app | ||
if [[ ! $? -eq 0 ]]; then | ||
exit 1 | ||
fi | ||
path=$(ynh_normalize_url_path $path) | ||
ynh_webpath_available $domain $path | ||
ynh_webpath_register $app $domain $path | ||
|
||
# Check if admin exists | ||
sudo yunohost user list --json | grep -qi "\"username\": \"$admin_ampache\"" | ||
if [[ ! $? -eq 0 ]]; then | ||
echo "Wrong admin" | ||
exit 1 | ||
fi | ||
# get sources and copy files to the right place | ||
ampache_ynh_getsources | ||
|
||
sudo yunohost app setting ampache admin -v $admin_ampache | ||
sudo cp ../conf/admin.sql /tmp/ | ||
|
||
# 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 'ampache' as database name and user | ||
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 $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/$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 | ||
sudo cp ../conf/admin.sql /tmp/ | ||
ynh_app_setting_set $app mysqlpwd $db_pwd | ||
ynh_mysql_setup_db "$app" "$app" "$db_pwd" | ||
ynh_mysql_connect_as "$app" "$db_pwd" "$app" < "$final_path/sql/ampache.sql" | ||
|
||
# Change variables in Ampache configuration | ||
sudo sed -i "s/yunouser/$db_user/g" $final_path/config/ampache.cfg.php | ||
sudo sed -i "s/yunopass/$db_pwd/g" $final_path/config/ampache.cfg.php | ||
sudo sed -i "s/yunobase/$db_user/g" $final_path/config/ampache.cfg.php | ||
ampache_ynh_prepareconfig | ||
|
||
sudo sed -i "s/yunoadmin/$admin_ampache/g" /tmp/admin.sql | ||
sudo sed -i "s@PATHTOCHANGE@${path%/}@g" $final_path/config/ampache.cfg.php | ||
sudo sed -i "s@DOMAINTOCHANGE@$domain@g" $final_path/config/ampache.cfg.php | ||
random_key=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') | ||
sudo sed -i "s@RANDOMKEYTOCHANGE@$random_key@g" $final_path/config/ampache.cfg.php | ||
|
||
# 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/$app.conf | ||
ampache_ynh_preparenginx | ||
|
||
# Install dependency | ||
sudo apt-get update | ||
sudo apt-get install libav-tools -y | ||
|
||
# Ampache installation | ||
cd $final_path | ||
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 | ||
|
||
# Set permissions to ampache directory | ||
sudo chown -R www-data: $final_path | ||
ampache_ynh_install | ||
|
||
# Reload Nginx and regenerate SSOwat conf | ||
sudo service nginx reload | ||
sudo yunohost app setting $app skipped_uris -v "/" | ||
sudo yunohost app ssowatconf | ||
ampache_ynh_reloadservices | ||
|
||
# Pre config ampache | ||
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 | ||
ampache_ynh_doconfig | ||
|
||
ynh_mysql_connect_as "$app" "$db_pwd" "$app" < /tmp/admin.sql | ||
|
||
# Clean install | ||
sudo sed '/yunoampache/d' /etc/hosts > /tmp/hosts.tmp | ||
sudo cp /tmp/hosts.tmp /etc/hosts ; sudo rm -f /tmp/hosts.tmp | ||
ynh_mysql_connect_as "$db_user" "$db_pwd" "$app" < /tmp/admin.sql | ||
sudo rm -rf ../ampache-$version | ||
sudo rm /tmp/admin.sql | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
. /usr/share/yunohost/helpers | ||
|
||
app=$YNH_APP_INSTANCE_NAME | ||
|
||
domain=$(ynh_app_setting_get "$app" domain) | ||
path=$(ynh_app_setting_get "$app" path) | ||
admin=$(ynh_app_setting_get "$app" admin) | ||
|
||
# Check domain/path availability | ||
test ! -d /var/www/$app \ | ||
|| ynh_die "There is already a directory: /var/www/$app " | ||
|
||
path=$(ynh_normalize_url_path $path) | ||
ynh_webpath_available $domain $path | ||
ynh_webpath_register $app $domain $path | ||
|
||
# Install dependency | ||
sudo apt-get update | ||
sudo apt-get install libav-tools -y | ||
|
||
sudo cp -a ./sources "/var/www/$app" | ||
|
||
sudo cp -a ./conf/nginx.conf "/etc/nginx/conf.d/$domain.d/$app.conf" | ||
|
||
db_pwd=$(ynh_app_setting_get $app mysqlpwd) | ||
ynh_mysql_setup_db $app $app $db_pwd | ||
ynh_mysql_connect_as $app $db_pwd $app < ./db.sql | ||
|
||
sudo service nginx reload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,37 @@ | ||
#!/bin/bash | ||
|
||
set -eu | ||
|
||
. /usr/share/yunohost/helpers | ||
. _common | ||
|
||
# Retrieve arguments | ||
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) | ||
domain=$(ynh_app_setting_get $app domain) | ||
path=$(ynh_app_setting_get $app path) | ||
db_pwd=$(ynh_app_setting_get $app mysqlpwd) | ||
admin_ampache=$(ynh_app_setting_get $app admin) | ||
|
||
# first make a copy of the db | ||
# mysqldump -u $db_user -p$db_pwd --add-drop-table --allow-keywords $app > $final_path/ampache-db-backup.sql | ||
path=$(ynh_normalize_url_path $path) | ||
|
||
# Copy files to the right place | ||
final_path=/var/www/$app | ||
sudo cp -a ../sources/* $final_path | ||
sudo cp ../conf/ampache.cfg.php $final_path/config/ampache.cfg.php | ||
# Get sources and copy files to the right place | ||
ampache_ynh_getsources | ||
|
||
# Change variables in Ampache configuration | ||
sudo sed -i "s/yunouser/$db_user/g" $final_path/config/ampache.cfg.php | ||
sudo sed -i "s/yunopass/$db_pwd/g" $final_path/config/ampache.cfg.php | ||
sudo sed -i "s/yunobase/$db_user/g" $final_path/config/ampache.cfg.php | ||
sudo sed -i "s@PATHTOCHANGE@${path%/}@g" $final_path/config/ampache.cfg.php | ||
sudo sed -i "s@DOMAINTOCHANGE@$domain@g" $final_path/config/ampache.cfg.php | ||
|
||
|
||
# Set permissions to roundcube directory | ||
sudo chown -R www-data: $final_path | ||
ampache_ynh_prepareconfig | ||
|
||
# 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/$app.conf | ||
ampache_ynh_preparenginx | ||
|
||
# Ampache installation | ||
ampache_ynh_install | ||
|
||
# Reload Nginx and regenerate SSOwat conf | ||
sudo service nginx reload | ||
sudo yunohost app setting $app skipped_uris -v "/" | ||
sudo yunohost app ssowatconf | ||
ampache_ynh_reloadservices | ||
|
||
# Ampache installation | ||
cd $final_path | ||
sudo -u www-data 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 | ||
|
||
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 | ||
# Pre config ampache | ||
ampache_ynh_doconfig | ||
|
||
# Clean install | ||
sudo rm -rf ../ampache-$version | ||
sudo rm /tmp/admin.sql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
3.8.3 |