Browse Source

Merge branch 'testing' into envvar

Jérôme Lebleu 8 years ago
parent
commit
8abe2a9325
7 changed files with 26 additions and 22 deletions
  1. 2 0
      .gitignore
  2. 8 8
      manifest.json
  3. 3 4
      scripts/backup
  4. 3 2
      scripts/install
  5. 3 2
      scripts/remove
  6. 5 3
      scripts/restore
  7. 2 3
      scripts/upgrade

+ 2 - 0
.gitignore

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

+ 8 - 8
manifest.json

@@ -53,21 +53,21 @@
             },
             {
                 "name": "is_public",
+                "type": "boolean",
                 "ask": {
                     "en": "Is it a public application?",
                     "fr": "Est-ce une application publique ?"
                 },
-                "choices": ["Yes", "No"],
-                "default": "Yes"
+                "default": true
             },
             {
-    		"name": "my_boolean",
-    		"type": "boolean",
-    		"ask": {
-                    "en": "Do you want to check this boolean ?",
-                    "fr": "Tu veux cocher ce booléen ?"
+                "name": "language",
+                "ask": {
+                    "en": "Choose the application language",
+                    "fr": "Choisissez la langue de l'application"
                 },
-                "default": true
+                "choices": ["fr", "en"],
+                "default": "fr"
             }
         ]
     }

+ 3 - 4
scripts/backup

@@ -5,10 +5,9 @@ set -e
 
 app=$YNH_APP_INSTANCE_NAME
 
-# The parameter $1 is the backup directory location
-# which will be compressed afterward
-backup_dir=$1/apps/$app
-sudo mkdir -p $backup_dir
+# The first argument is the backup directory location for the app
+# from where the script is executed and which will be compressed afterward
+backup_dir=$1
 
 # Backup sources & data
 sudo cp -a /var/www/$app/. $backup_dir/sources

+ 3 - 2
scripts/install

@@ -20,10 +20,12 @@ domain=$YNH_APP_ARG_DOMAIN
 path=$YNH_APP_ARG_PATH
 admin=$YNH_APP_ARG_ADMIN
 is_public=$YNH_APP_ARG_IS_PUBLIC
+language=$YNH_APP_ARG_LANGUAGE
 
 # Save app settings
 sudo yunohost app setting $app admin -v "$admin"
 sudo yunohost app setting $app is_public -v "$is_public"
+sudo yunohost app setting $app language -v "$language"
 
 # Check domain/path availability
 sudo yunohost app checkurl $domain$path -a $app \
@@ -65,7 +67,7 @@ sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
 #sudo chmod 644 $finalphpconf
 
 # If app is public, add url to SSOWat conf as skipped_uris
-if [ "$is_public" = "Yes" ];
+if [[ $is_public -eq 1 ]];
 then
   # unprotected_uris allows SSO credentials to be passed anyway.
   sudo yunohost app setting $app unprotected_uris -v "/"
@@ -78,4 +80,3 @@ fi
 
 # Restart services
 sudo service nginx reload
-sudo yunohost app ssowatconf

+ 3 - 2
scripts/remove

@@ -1,5 +1,7 @@
 #!/bin/bash
-app=ynhexample
+
+# The last argument is the app instance name
+app=${!#}
 
 # Retrieve arguments
 domain=$(sudo yunohost app setting $app domain)
@@ -24,4 +26,3 @@ sudo rm -f /etc/nginx/conf.d/$domain.d/$app.conf
 
 # Restart services
 sudo service nginx reload
-sudo yunohost app ssowatconf

+ 5 - 3
scripts/restore

@@ -5,11 +5,13 @@ set -e
 
 app=$YNH_APP_INSTANCE_NAME
 
-# The parameter $1 is the uncompressed restore directory location
-backup_dir=$1/apps/$app
+# The first argument is the backup directory location of the app
+# from where the script is executed
+backup_dir=$1
 
 # Restore sources & data
-sudo cp -a $backup_dir/sources/. /var/www/$app
+final_path=/var/www/$app
+sudo cp -a $backup_dir/sources/. $final_path
 
 # Restore permissions to app files
 # you may need to make some file and/or directory writeable by www-data (nginx user)

+ 2 - 3
scripts/upgrade

@@ -11,6 +11,7 @@ domain=$(sudo yunohost app setting $app domain)
 path=$(sudo yunohost app setting $app path)
 admin=$(sudo yunohost app setting $app admin)
 is_public=$(sudo yunohost app setting $app is_public)
+language=$(sudo yunohost app setting $app language)
 
 # Remove trailing "/" for next commands
 path=${path%/}
@@ -43,7 +44,7 @@ sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
 #sudo chmod 644 $finalphpconf
 
 # If app is public, add url to SSOWat conf as skipped_uris
-if [ "$is_public" = "Yes" ];
+if [[ $is_public -eq 1 ]];
 then
   # See install script
   sudo yunohost app setting $app unprotected_uris -v "/"
@@ -57,5 +58,3 @@ fi
 
 # Restart services
 sudo service nginx reload
-sudo yunohost app ssowatconf
-