1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/lxd-dashboard_ynh.git synced 2024-09-03 19:36:18 +02:00

[autopatch] Automatic patch attempt for helpers 2.1

This commit is contained in:
Yunohost-Bot 2024-08-31 01:03:24 +02:00 committed by Alexandre Aubin
parent 5cc4b9a956
commit 7ec58246d9
14 changed files with 59 additions and 568 deletions

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
*~
*.sw[op]
.DS_Store

View file

@ -1,4 +0,0 @@
; Additional php.ini defines, specific to this pool of workers.
php_admin_value[upload_max_filesize] = 50M
php_admin_value[post_max_size] = 50M

View file

@ -12,7 +12,7 @@ location __PATH__/ {
try_files $uri $uri/ index.php;
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+?\.php)(/.*)$;
fastcgi_pass unix:/var/run/php/php__PHPVERSION__-fpm-__NAME__.sock;
fastcgi_pass unix:/var/run/php/php__PHP_VERSION__-fpm-__APP__.sock;
fastcgi_index index.php;
include fastcgi_params;

View file

@ -15,7 +15,8 @@ website = "https://lxdware.com"
code = "https://github.com/lxdware/lxd-dashboard"
[integration]
yunohost = ">= 11.2"
yunohost = ">= 11.2.18"
helpers_version = "2.1"
architectures = "all"
multi_instance = true
@ -54,6 +55,7 @@ ram.runtime = "50M"
[resources.system_user]
[resources.install_dir]
group = "www-data:r-x"
[resources.data_dir]
subdirs = ["backups", "data/lxd"]

View file

@ -1,17 +1,5 @@
#!/bin/bash
#=================================================
# COMMON VARIABLES
#=================================================
#=================================================
# PERSONAL HELPERS
#=================================================
#=================================================
# EXPERIMENTAL HELPERS
#=================================================
#=================================================
# FUTURE OFFICIAL HELPERS
# COMMON VARIABLES AND CUSTOM HELPERS
#=================================================

View file

@ -1,55 +1,46 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
#=================================================
# DECLARE DATA AND CONF FILES TO BACKUP
#=================================================
ynh_print_info --message="Declaring files to be backed up..."
ynh_print_info "Declaring files to be backed up..."
#=================================================
# BACKUP THE APP MAIN DIR
#=================================================
ynh_backup --src_path="$install_dir"
ynh_backup "$install_dir"
#=================================================
# BACKUP THE DATA DIR
#=================================================
ynh_backup --src_path="$data_dir"
ynh_backup "$data_dir"
#=================================================
# BACKUP THE NGINX CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_backup "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# BACKUP THE PHP-FPM CONFIGURATION
#=================================================
ynh_backup --src_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_backup "/etc/php/$php_version/fpm/pool.d/$app.conf"
#=================================================
# SPECIFIC BACKUP
#=================================================
# BACKUP THE MYSQL DATABASE
#=================================================
ynh_print_info --message="Backing up the MySQL database..."
ynh_print_info "Backing up the MySQL database..."
ynh_mysql_dump_db --database="$db_name" > db.sql
ynh_mysql_dump_db > db.sql
#=================================================
# END OF SCRIPT
#=================================================
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
ynh_print_info "Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."

View file

@ -1,25 +1,17 @@
#!/bin/bash
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# STANDARD MODIFICATIONS
#=================================================
# MODIFY URL IN NGINX CONF
#=================================================
ynh_script_progression --message="Updating NGINX web server configuration..."
ynh_script_progression "Updating NGINX web server configuration..."
ynh_change_url_nginx_config
ynh_config_change_url_nginx
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Change of URL completed for $app"
ynh_script_progression "Change of URL completed for $app"

View file

@ -1,102 +0,0 @@
#!/bin/bash
# In simple cases, you don't need a config script.
# With a simple config_panel.toml, you can write in the app settings, in the
# upstream config file or replace complete files (logo ...) and restart services.
# The config scripts allows you to go further, to handle specific cases
# (validation of several interdependent fields, specific getter/setter for a value,
# display dynamic informations or choices, pre-loading of config type .cube... ).
#=================================================
# GENERIC STARTING
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source /usr/share/yunohost/helpers
ynh_abort_if_errors
#=================================================
# RETRIEVE ARGUMENTS
#=================================================
final_path=$(ynh_app_setting_get $app final_path)
#=================================================
# SPECIFIC GETTERS FOR TOML SHORT KEY
#=================================================
get__amount() {
# Here we can imagine to have an API call to stripe to know the amount of donation during a month
local amount = 200
# It's possible to change some properties of the question by overriding it:
if [ $amount -gt 100 ]
then
cat << EOF
style: success
value: $amount
ask:
en: A lot of donation this month: **$amount €**
EOF
else
cat << EOF
style: danger
value: $amount
ask:
en: Not so much donation this month: $amount €
EOF
fi
}
get__prices() {
local prices = "$(grep "DONATION\['" "$final_path/settings.py" | sed -r "s@^DONATION\['([^']*)'\]\['([^']*)'\] = '([^']*)'@\1/\2/\3@g" | sed -z 's/\n/,/g;s/,$/\n/')"
if [ "$prices" == "," ];
then
# Return YNH_NULL if you prefer to not return a value at all.
echo YNH_NULL
else
echo $prices
fi
}
#=================================================
# SPECIFIC VALIDATORS FOR TOML SHORT KEYS
#=================================================
validate__publishable_key() {
# We can imagine here we test if the key is really a publisheable key
(is_secret_key $publishable_key) &&
echo 'This key seems to be a secret key'
}
#=================================================
# SPECIFIC SETTERS FOR TOML SHORT KEYS
#=================================================
set__prices() {
#---------------------------------------------
# IMPORTANT: setter are trigger only if a change is detected
#---------------------------------------------
for price in $(echo $prices | sed "s/,/ /"); do
frequency=$(echo $price | cut -d/ -f1)
currency=$(echo $price | cut -d/ -f2)
price_id=$(echo $price | cut -d/ -f3)
sed "d/DONATION\['$frequency'\]\['$currency'\]" "$final_path/settings.py"
echo "DONATION['$frequency']['$currency'] = '$price_id'" >> "$final_path/settings.py"
done
#---------------------------------------------
# IMPORTANT: to be able to upgrade properly, you have to saved the value in settings too
#---------------------------------------------
ynh_app_setting_set $app prices $prices
}
#=================================================
# GENERIC FINALIZATION
#=================================================
ynh_app_config_run $1

View file

@ -1,43 +1,36 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
ynh_script_progression --message="Setting up source files..."
ynh_script_progression "Setting up source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Configuring PHP-FPM..."
ynh_script_progression "Configuring PHP-FPM..."
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
ynh_config_add_phpfpm
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
#=================================================
# SETUP APPLICATION WITH CURL
#=================================================
ynh_script_progression --message="Setuping application with CURL..."
ynh_script_progression "Setuping application with CURL..."
# Installation with curl
ynh_script_progression --message="Finalizing installation..."
ynh_script_progression "Finalizing installation..."
ynh_local_curl "/backend/config/login.php?database_type=mysql&database_host=localhost&database_name=$db_name&database_user=$db_user&action=writeDatabaseConfig" "database_password=$db_pwd"
ynh_local_curl "/backend/admin/settings.php?action=createUser" "username=$admin" "password=$password"
ynh_local_curl "/backend/admin/settings.php?action=createUser" "email=$(ynh_user_get_info --username=$admin --key=mail)" "first_name=$(ynh_user_get_info --username=$admin --key=firstname)" "last_name=$(ynh_user_get_info --username=$admin --key=lastname)" "password=$password" "username=$admin"
@ -49,4 +42,4 @@ chown -R $app: "$data_dir"
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Installation of $app completed"
ynh_script_progression "Installation of $app completed"

View file

@ -1,29 +1,23 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# REMOVE NGINX CONFIGURATION
#=================================================
ynh_script_progression --message="Removing NGINX web server configuration..."
ynh_script_progression "Removing NGINX web server configuration..."
# Remove the dedicated NGINX config
ynh_remove_nginx_config
ynh_config_remove_nginx
# Remove the dedicated PHP-FPM config
ynh_remove_fpm_config
ynh_config_remove_phpfpm
ynh_secure_remove --file="$data_dir"
ynh_safe_rm "$data_dir"
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Removal of $app completed"
ynh_script_progression "Removal of $app completed"

View file

@ -1,11 +1,5 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts
source ../settings/scripts/_common.sh
source /usr/share/yunohost/helpers
@ -13,19 +7,18 @@ source /usr/share/yunohost/helpers
#=================================================
# RESTORE THE APP MAIN DIR
#=================================================
ynh_script_progression --message="Restoring the app main directory..."
ynh_script_progression "Restoring the app main directory..."
ynh_restore_file --origin_path="$install_dir"
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
ynh_restore "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#=================================================
# RESTORE THE DATA DIRECTORY
#=================================================
ynh_script_progression --message="Restoring the data directory..."
ynh_script_progression "Restoring the data directory..."
ynh_restore_file --origin_path="$data_dir"
ynh_restore "$data_dir"
chmod -R o-rwx "$data_dir"
chown -R $app: "$data_dir"
@ -33,31 +26,29 @@ chown -R $app: "$data_dir"
#=================================================
# RESTORE THE MYSQL DATABASE
#=================================================
ynh_script_progression --message="Restoring the MySQL database..."
ynh_script_progression "Restoring the MySQL database..."
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
ynh_mysql_db_shell < ./db.sql
#=================================================
# RESTORE THE PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Restoring the PHP-FPM configuration..."
ynh_script_progression "Restoring the PHP-FPM configuration..."
ynh_restore_file --origin_path="/etc/php/$phpversion/fpm/pool.d/$app.conf"
ynh_restore "/etc/php/$php_version/fpm/pool.d/$app.conf"
ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf"
ynh_restore "/etc/nginx/conf.d/$domain.d/$app.conf"
#=================================================
# GENERIC FINALIZATION
#=================================================
# RELOAD NGINX AND PHP-FPM
#=================================================
ynh_script_progression --message="Reloading NGINX web server and PHP-FPM..."
ynh_script_progression "Reloading NGINX web server and PHP-FPM..."
ynh_systemd_action --service_name=php$phpversion-fpm --action=reload
ynh_systemd_action --service_name=nginx --action=reload
ynh_systemctl --service=php$php_version-fpm --action=reload
ynh_systemctl --service=nginx --action=reload
#=================================================
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Restoration completed for $app"
ynh_script_progression "Restoration completed for $app"

View file

@ -1,57 +1,43 @@
#!/bin/bash
#=================================================
# GENERIC START
#=================================================
# IMPORT GENERIC HELPERS
#=================================================
source _common.sh
source /usr/share/yunohost/helpers
#=================================================
# CHECK VERSION
#=================================================
upgrade_type=$(ynh_check_app_version_changed)
#=================================================
# DOWNLOAD, CHECK AND UNPACK SOURCE
#=================================================
if [ "$upgrade_type" == "UPGRADE_APP" ]
# FIXME: this is still supported but the recommendation is now to *always* re-setup the app sources wether or not the upstream sources changed
if ynh_app_upstream_version_changed
then
ynh_script_progression --message="Upgrading source files..."
ynh_script_progression "Upgrading source files..."
# Download, check integrity, uncompress and patch the source from app.src
ynh_setup_source --dest_dir="$install_dir"
fi
chmod -R o-rwx "$install_dir"
chown -R $app:www-data "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod -R o-rwx "$install_dir"
#REMOVEME? Assuming the install dir is setup using ynh_setup_source, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown -R $app:www-data "$install_dir"
#=================================================
# PHP-FPM CONFIGURATION
#=================================================
ynh_script_progression --message="Upgrading PHP-FPM configuration..."
ynh_script_progression "Upgrading PHP-FPM configuration..."
# Create a dedicated PHP-FPM config
ynh_add_fpm_config
ynh_config_add_phpfpm
# Create a dedicated NGINX config
ynh_add_nginx_config
ynh_config_add_nginx
#=================================================
# SPECIFIC UPGRADE
#=================================================
# UPDATE A CONFIG FILE
#=================================================
ynh_script_progression --message="Updating a configuration file..."
ynh_script_progression "Updating configuration..."
ynh_add_config --template="db_config.php" --destination="$data_dir/data/db_config.php"
ynh_config_add --template="db_config.php" --destination="$data_dir/data/db_config.php"
chmod 400 "$data_dir/data/db_config.php"
chown $app:$app "$data_dir/data/db_config.php"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chmod 400 "$data_dir/data/db_config.php"
#REMOVEME? Assuming the file is setup using ynh_config_add, the proper chmod/chowns are now already applied and it shouldn't be necessary to tweak perms | chown $app:$app "$data_dir/data/db_config.php"
chmod -R o-rwx "$data_dir"
chown -R $app: "$data_dir"
@ -60,4 +46,4 @@ chown -R $app: "$data_dir"
# END OF SCRIPT
#=================================================
ynh_script_progression --message="Upgrade of $app completed"
ynh_script_progression "Upgrade of $app completed"

View file

@ -1,6 +0,0 @@
- download and extract sources, navigate to the dir then:
- `git init`
- `git add *`
- `find ./ \( -type d -name .git -prune \) -o -type f -print0 | xargs -0 sed -i 's/\/var\/lxdware/\/home\/yunohost.app\/lxd-dashboard/g'`
- `git diff > main-replace_data_dir.patch`

View file

@ -1,335 +0,0 @@
diff --git a/lxd-dashboard/backend/config/about.php b/lxd-dashboard/backend/config/about.php
index 268ac7b..6476c11 100644
--- a/lxd-dashboard/backend/config/about.php
+++ b/lxd-dashboard/backend/config/about.php
@@ -26,7 +26,7 @@ if (!isset($_SESSION)) {
if (isset($_SESSION['username'])) {
//Include db_config.php file
- include_once('/var/lxdware/data/db_config.php');
+ include_once('/home/yunohost.app/lxd-dashboard/data/db_config.php');
switch (DB_TYPE) {
case "sqlite":
diff --git a/lxd-dashboard/backend/config/cert.php b/lxd-dashboard/backend/config/cert.php
index e2b3799..3c234f3 100644
--- a/lxd-dashboard/backend/config/cert.php
+++ b/lxd-dashboard/backend/config/cert.php
@@ -24,7 +24,7 @@ if (!isset($_SESSION)) {
function createCertificate($certificateFilename, $numberofDays = 3650){
//Only create the certificate if it does not already exist
- if (!file_exists('/var/lxdware/data/lxd/'.$certificateFilename.'.crt')){
+ if (!file_exists('/home/yunohost.app/lxd-dashboard/data/lxd/'.$certificateFilename.'.crt')){
$subject = array(
"commonName" => "LXDWARE",
);
@@ -40,11 +40,11 @@ function createCertificate($certificateFilename, $numberofDays = 3650){
//Generate self-signed EC cert
$x509 = openssl_csr_sign($csr, null, $private_key, $numberofDays);
- openssl_x509_export_to_file($x509, '/var/lxdware/data/lxd/'.$certificateFilename.'.crt');
- openssl_pkey_export_to_file($private_key, '/var/lxdware/data/lxd/'.$certificateFilename.'.key');
+ openssl_x509_export_to_file($x509, '/home/yunohost.app/lxd-dashboard/data/lxd/'.$certificateFilename.'.crt');
+ openssl_pkey_export_to_file($private_key, '/home/yunohost.app/lxd-dashboard/data/lxd/'.$certificateFilename.'.key');
//Change permissions to lock down private key
- chmod('/var/lxdware/data/lxd/'.$certificateFilename.'.key',0600);
+ chmod('/home/yunohost.app/lxd-dashboard/data/lxd/'.$certificateFilename.'.key',0600);
}
}
@@ -65,9 +65,9 @@ if (isset($_SESSION['username'])) {
case "createCertificateFiles":
if (validateAuthorization($action)) {
if (!empty($name)){
- if (!file_exists('/var/lxdware/data/lxd/'.$name.'.crt')){
+ if (!file_exists('/home/yunohost.app/lxd-dashboard/data/lxd/'.$name.'.crt')){
createCertificate($name, $days);
- if (file_exists('/var/lxdware/data/lxd/'.$name.'.crt') && file_exists('/var/lxdware/data/lxd/'.$name.'.key'))
+ if (file_exists('/home/yunohost.app/lxd-dashboard/data/lxd/'.$name.'.crt') && file_exists('/home/yunohost.app/lxd-dashboard/data/lxd/'.$name.'.key'))
echo '{"status": "Ok", "status_code": 200, "metadata": {"status": "Certificate files created"}}';
else
echo '{"status": "Bad Request", "status_code": 400, "metadata": {"error": "Unable to create all certificate files"}}';
@@ -85,11 +85,11 @@ if (isset($_SESSION['username'])) {
case "deleteCertificateFiles":
if (validateAuthorization($action)) {
if (!empty($name)){
- unlink('/var/lxdware/data/lxd/'.$name.'.crt');
- unlink('/var/lxdware/data/lxd/'.$name.'.key');
+ unlink('/home/yunohost.app/lxd-dashboard/data/lxd/'.$name.'.crt');
+ unlink('/home/yunohost.app/lxd-dashboard/data/lxd/'.$name.'.key');
}
- if (file_exists('/var/lxdware/data/lxd/'.$name.'.crt') || file_exists('/var/lxdware/data/lxd/'.$name.'.key'))
+ if (file_exists('/home/yunohost.app/lxd-dashboard/data/lxd/'.$name.'.crt') || file_exists('/home/yunohost.app/lxd-dashboard/data/lxd/'.$name.'.key'))
echo '{"status": "Bad Request", "status_code": 400, "metadata": {"error": "Unable to remove all certificate files"}}';
else
echo '{"status": "Ok", "status_code": 200, "metadata": {"status": "Certificate files removed"}}';
@@ -105,7 +105,7 @@ if (isset($_SESSION['username'])) {
$i = 0;
echo '{ "data": [';
- foreach (glob("/var/lxdware/data/lxd/*.crt") as $filename) {
+ foreach (glob("/home/yunohost.app/lxd-dashboard/data/lxd/*.crt") as $filename) {
$data = openssl_x509_parse(file_get_contents($filename));
$validFrom = date('Y-m-d H:i:s', $data['validFrom_time_t']);
@@ -138,7 +138,7 @@ if (isset($_SESSION['username'])) {
case "viewCertificate":
if (validateAuthorization($action)) {
- $results = shell_exec("cat /var/lxdware/data/lxd/client.crt");
+ $results = shell_exec("cat /home/yunohost.app/lxd-dashboard/data/lxd/client.crt");
echo htmlentities($results);
}
else {
diff --git a/lxd-dashboard/backend/config/curl.php b/lxd-dashboard/backend/config/curl.php
index 7753f63..9642189 100644
--- a/lxd-dashboard/backend/config/curl.php
+++ b/lxd-dashboard/backend/config/curl.php
@@ -31,8 +31,8 @@ require_once('../config/db.php');
function sendCurlRequest($request_action, $request_type, $request_url, $request_data = "{}"){
- $cert = "/var/lxdware/data/lxd/client.crt";
- $key = "/var/lxdware/data/lxd/client.key";
+ $cert = "/home/yunohost.app/lxd-dashboard/data/lxd/client.crt";
+ $key = "/home/yunohost.app/lxd-dashboard/data/lxd/client.key";
//Set required variables
$get_connection_timeout = (isset($_SESSION['get_connection_timeout'])) ? $_SESSION['get_connection_timeout'] : 3;
diff --git a/lxd-dashboard/backend/config/db.php b/lxd-dashboard/backend/config/db.php
index e911499..68802eb 100644
--- a/lxd-dashboard/backend/config/db.php
+++ b/lxd-dashboard/backend/config/db.php
@@ -34,12 +34,12 @@ function in_array_r($needle, $haystacks){
function establishDatabaseConnection(){
//Require db_config.php file
- require_once('/var/lxdware/data/db_config.php');
+ require_once('/home/yunohost.app/lxd-dashboard/data/db_config.php');
switch (DB_TYPE) {
case "sqlite":
$_SESSION['db_type'] = "SQLite";
- $conn = new PDO('sqlite:/var/lxdware/data/sqlite/lxdware.sqlite');
+ $conn = new PDO('sqlite:/home/yunohost.app/lxd-dashboard/data/sqlite/lxdware.sqlite');
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); //needed for catch backward compatability with PHP 7
break;
case "mysql":
diff --git a/lxd-dashboard/backend/config/login.php b/lxd-dashboard/backend/config/login.php
index bb30ef6..4b283b1 100644
--- a/lxd-dashboard/backend/config/login.php
+++ b/lxd-dashboard/backend/config/login.php
@@ -34,7 +34,7 @@ switch ($action) {
case "loadLoginForm":
$showRegistrationForm = false;
- if (!file_exists('/var/lxdware/data/db_config.php')){
+ if (!file_exists('/home/yunohost.app/lxd-dashboard/data/db_config.php')){
$showRegistrationForm = true;
}
else {
@@ -127,10 +127,10 @@ switch ($action) {
case "writeDatabaseConfig":
- if (!file_exists('/var/lxdware/data/db_config.php')){
+ if (!file_exists('/home/yunohost.app/lxd-dashboard/data/db_config.php')){
if ($database_type == 'sqlite'){
try {
- $conn = new PDO('sqlite:/var/lxdware/data/sqlite/lxdware.sqlite');
+ $conn = new PDO('sqlite:/home/yunohost.app/lxd-dashboard/data/sqlite/lxdware.sqlite');
$db = null;
}
catch (PDOException $e){
@@ -138,7 +138,7 @@ switch ($action) {
break;
}
- $file = fopen("/var/lxdware/data/db_config.php", "w") or die('{"status": "Bad Request", "status_code": 400, "metadata": {"error": "Unable to write database configuration file"}}');
+ $file = fopen("/home/yunohost.app/lxd-dashboard/data/db_config.php", "w") or die('{"status": "Bad Request", "status_code": 400, "metadata": {"error": "Unable to write database configuration file"}}');
$txt = "<?php\n";
$txt .= "define( 'DB_TYPE', 'sqlite' );\n";
$txt .= "define( 'DB_NAME', '' );\n";
@@ -148,7 +148,7 @@ switch ($action) {
$txt .= "?>";
fwrite($file, $txt);
fclose($file);
- chmod('/var/lxdware/data/db_config.php',0600);
+ chmod('/home/yunohost.app/lxd-dashboard/data/db_config.php',0600);
}
if ($database_type == 'mysql'){
@@ -162,7 +162,7 @@ switch ($action) {
break;
}
- $file = fopen("/var/lxdware/data/db_config.php", "w") or die('{"status": "Bad Request", "status_code": 400, "metadata": {"error": "Unable to write database configuration file"}}');
+ $file = fopen("/home/yunohost.app/lxd-dashboard/data/db_config.php", "w") or die('{"status": "Bad Request", "status_code": 400, "metadata": {"error": "Unable to write database configuration file"}}');
$txt = "<?php\n";
$txt .= "define( 'DB_TYPE', 'mysql' );\n";
$txt .= "define( 'DB_NAME', '$database_name' );\n";
@@ -172,13 +172,13 @@ switch ($action) {
$txt .= "?>";
fwrite($file, $txt);
fclose($file);
- chmod('/var/lxdware/data/db_config.php',0600);
+ chmod('/home/yunohost.app/lxd-dashboard/data/db_config.php',0600);
}
echo '{"status": "Ok", "status_code": 200, "metadata": "{}"}';
}
else {
- echo '{"status": "Bad Request", "status_code": 400, "metadata": {"error": "Database config file \'/var/lxdware/data/db_config.php\' already exists"}}';
+ echo '{"status": "Bad Request", "status_code": 400, "metadata": {"error": "Database config file \'/home/yunohost.app/lxd-dashboard/data/db_config.php\' already exists"}}';
}
break;
diff --git a/lxd-dashboard/backend/lxd/containers-single.php b/lxd-dashboard/backend/lxd/containers-single.php
index 7cbcc4c..13656b2 100644
--- a/lxd-dashboard/backend/lxd/containers-single.php
+++ b/lxd-dashboard/backend/lxd/containers-single.php
@@ -704,7 +704,7 @@ if (isset($_SESSION['username'])) {
$instance_only = ($instance_backup['instance_only'])?"true":"false";
$optimized_storage = ($instance_backup['optimized_storage'])?"true":"false";
$hostname = retrieveHostName($remote);
- $file = '/var/lxdware/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $instance_backup['name'];
+ $file = '/home/yunohost.app/lxd-dashboard/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $instance_backup['name'];
$file_exists = false;
$file_size = "";
$unit_size = "";
diff --git a/lxd-dashboard/backend/lxd/containers.php b/lxd-dashboard/backend/lxd/containers.php
index 0ccf4b8..d3ca545 100644
--- a/lxd-dashboard/backend/lxd/containers.php
+++ b/lxd-dashboard/backend/lxd/containers.php
@@ -398,7 +398,7 @@ if (isset($_SESSION['username'])) {
case "deleteInstanceBackup":
$hostname = retrieveHostName($remote);
- $file = '/var/lxdware/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $name;
+ $file = '/home/yunohost.app/lxd-dashboard/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $name;
unlink($file);
$url = $base_url . "/1.0/containers/" . $instance . "/backups/" . $name . "?project=" . $project;
$results = sendCurlRequest($action, "DELETE", $url);
@@ -477,7 +477,7 @@ if (isset($_SESSION['username'])) {
case "downloadInstanceExportFile":
$hostname = retrieveHostName($remote);
- $file = '/var/lxdware/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $name;
+ $file = '/home/yunohost.app/lxd-dashboard/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $name;
$file_name = basename($file);
$file_size = filesize($file);
@@ -513,14 +513,14 @@ if (isset($_SESSION['username'])) {
case "exportInstanceBackup":
if (validateAuthorization($action)) {
- $cert = "/var/lxdware/data/lxd/client.crt";
- $key = "/var/lxdware/data/lxd/client.key";
+ $cert = "/home/yunohost.app/lxd-dashboard/data/lxd/client.crt";
+ $key = "/home/yunohost.app/lxd-dashboard/data/lxd/client.key";
$hostname = retrieveHostName($remote);
- $file = '/var/lxdware/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $name;
+ $file = '/home/yunohost.app/lxd-dashboard/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $name;
if (!file_exists($file)){
//If there is no directory yet for the host to store backups, create it
- if (!file_exists('/var/lxdware/backups/' . $hostname . '/' . $project . '/' . $instance)){
- mkdir('/var/lxdware/backups/'.$hostname . '/' . $project . '/' . $instance, 0777, true);
+ if (!file_exists('/home/yunohost.app/lxd-dashboard/backups/' . $hostname . '/' . $project . '/' . $instance)){
+ mkdir('/home/yunohost.app/lxd-dashboard/backups/'.$hostname . '/' . $project . '/' . $instance, 0777, true);
}
$url = $base_url . "/1.0/containers/" . $instance . "/backups/" . $name . "/export?project=" . $project;
diff --git a/lxd-dashboard/backend/lxd/virtual-machines-single.php b/lxd-dashboard/backend/lxd/virtual-machines-single.php
index 17d573b..0673d87 100644
--- a/lxd-dashboard/backend/lxd/virtual-machines-single.php
+++ b/lxd-dashboard/backend/lxd/virtual-machines-single.php
@@ -653,7 +653,7 @@ if (isset($_SESSION['username'])) {
$instance_only = ($instance_backup['instance_only'])?"true":"false";
$optimized_storage = ($instance_backup['optimized_storage'])?"true":"false";
$hostname = retrieveHostName($remote);
- $file = '/var/lxdware/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $instance_backup['name'];
+ $file = '/home/yunohost.app/lxd-dashboard/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $instance_backup['name'];
$file_exists = false;
$file_size = "";
$unit_size = "";
diff --git a/lxd-dashboard/backend/lxd/virtual-machines.php b/lxd-dashboard/backend/lxd/virtual-machines.php
index a01ce7d..df11017 100644
--- a/lxd-dashboard/backend/lxd/virtual-machines.php
+++ b/lxd-dashboard/backend/lxd/virtual-machines.php
@@ -318,7 +318,7 @@ if (isset($_SESSION['username'])) {
case "deleteInstanceBackup":
$hostname = retrieveHostName($remote);
- $file = '/var/lxdware/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $name;
+ $file = '/home/yunohost.app/lxd-dashboard/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $name;
unlink($file);
$url = $base_url . "/1.0/instances/" . $instance . "/backups/" . $name . "?project=" . $project;
$results = sendCurlRequest($action, "DELETE", $url);
@@ -397,7 +397,7 @@ if (isset($_SESSION['username'])) {
case "downloadInstanceExportFile":
$hostname = retrieveHostName($remote);
- $file = '/var/lxdware/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $name;
+ $file = '/home/yunohost.app/lxd-dashboard/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $name;
$file_name = basename($file);
$file_size = filesize($file);
@@ -433,14 +433,14 @@ if (isset($_SESSION['username'])) {
case "exportInstanceBackup":
if (validateAuthorization($action)) {
- $cert = "/var/lxdware/data/lxd/client.crt";
- $key = "/var/lxdware/data/lxd/client.key";
+ $cert = "/home/yunohost.app/lxd-dashboard/data/lxd/client.crt";
+ $key = "/home/yunohost.app/lxd-dashboard/data/lxd/client.key";
$hostname = retrieveHostName($remote);
- $file = '/var/lxdware/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $name;
+ $file = '/home/yunohost.app/lxd-dashboard/backups/' . $hostname . '/' . $project . '/' . $instance . '/' . $name;
if (!file_exists($file)){
//If there is no directory yet for the host to store backups, create it
- if (!file_exists('/var/lxdware/backups/' . $hostname . '/' . $project . '/' . $instance)){
- mkdir('/var/lxdware/backups/'.$hostname . '/' . $project . '/' . $instance, 0777, true);
+ if (!file_exists('/home/yunohost.app/lxd-dashboard/backups/' . $hostname . '/' . $project . '/' . $instance)){
+ mkdir('/home/yunohost.app/lxd-dashboard/backups/'.$hostname . '/' . $project . '/' . $instance, 0777, true);
}
$url = $base_url . "/1.0/instances/" . $instance . "/backups/" . $name . "/export?project=" . $project;
diff --git a/startup.sh b/startup.sh
index 48aa2fe..90f6179 100644
--- a/startup.sh
+++ b/startup.sh
@@ -1,24 +1,24 @@
#!/bin/bash
#Setup LXD data directory
-if [ ! -d /var/lxdware/data/lxd ]
+if [ ! -d /home/yunohost.app/lxd-dashboard/data/lxd ]
then
- mkdir -p /var/lxdware/data/lxd
+ mkdir -p /home/yunohost.app/lxd-dashboard/data/lxd
fi
#Create backups directory if needed
-if [ ! -d /var/lxdware/backups ]
+if [ ! -d /home/yunohost.app/lxd-dashboard/backups ]
then
- mkdir -p /var/lxdware/backups
+ mkdir -p /home/yunohost.app/lxd-dashboard/backups
fi
#Create SQLite database directory if needed
-if [ ! -d /var/lxdware/data/sqlite ]
+if [ ! -d /home/yunohost.app/lxd-dashboard/data/sqlite ]
then
- mkdir -p /var/lxdware/data/sqlite
+ mkdir -p /home/yunohost.app/lxd-dashboard/data/sqlite
fi
-chown -R www-data:www-data /var/lxdware/
+chown -R www-data:www-data /home/yunohost.app/lxd-dashboard/
#Start PHP for NGINX
service php7.4-fpm start