Browse Source

Add conifg questions + install works from anywhere

master
Miraty 1 month ago
parent
commit
b1a34c11dd
3 changed files with 78 additions and 42 deletions
  1. 54
    1
      manifest.json
  2. 22
    39
      scripts/install
  3. 2
    2
      scripts/remove

+ 54
- 1
manifest.json View File

@@ -37,7 +37,7 @@
37 37
                 "name": "path",
38 38
                 "type": "path",
39 39
                 "ask": {
40
-                    "en": "Choose a path for Invidious (works only with /)",
40
+                    "en": "Choose a path for Invidious (only works with /)",
41 41
                     "fr": "Choisissez un chemin pour Invidious (fonctionne seulement avec /)"
42 42
                 },
43 43
                 "example": "/",
@@ -51,6 +51,59 @@
51 51
                     "fr": "Est-ce une application publique ?"
52 52
                 },
53 53
                 "default": true
54
+            },
55
+            {
56
+                "name": "registration_enabled",
57
+                "type": "string",
58
+                "ask": {
59
+                    "en": "Allow registration?",
60
+                    "fr": "Autoriser les inscriptions ?"
61
+                },
62
+                "choices": [
63
+                    "true",
64
+                    "false"
65
+                ],
66
+                "default": "true"
67
+            },
68
+            {
69
+                "name": "dark_mode",
70
+                "type": "string",
71
+                "ask": {
72
+                    "en": "Must Invidious be in dark mode by default?",
73
+                    "fr": "Invidious doit-elle être en thème sombre par défaut ?"
74
+                },
75
+                "choices": [
76
+                    "true",
77
+                    "false"
78
+                ],
79
+                "default": "true"
80
+            },
81
+            {
82
+                "name": "lang",
83
+                "type": "string",
84
+                "ask": {
85
+                    "en": "Choose the default language",
86
+                    "fr": "Choisissez la langue par défaut"
87
+                },
88
+                "choices": [
89
+                    "ar",
90
+                    "de",
91
+                    "el",
92
+                    "en-US",
93
+                    "eo",
94
+                    "es",
95
+                    "eu",
96
+                    "fr",
97
+                    "is",
98
+                    "it",
99
+                    "nb_NO",
100
+                    "nl",
101
+                    "pl",
102
+                    "ru",
103
+                    "uk",
104
+                    "zh-CN"
105
+                ],
106
+                "example": "eo"
54 107
             }
55 108
         ]
56 109
     }

+ 22
- 39
scripts/install View File

@@ -27,6 +27,9 @@ ynh_abort_if_errors
27 27
 domain=$YNH_APP_ARG_DOMAIN
28 28
 path_url=$YNH_APP_ARG_PATH
29 29
 is_public=$YNH_APP_ARG_IS_PUBLIC
30
+registration_enabled=$YNH_APP_ARG_REGISTRATION_ENABLED
31
+dark_mode=$YNH_APP_ARG_DARK_MODE
32
+lang=$YNH_APP_ARG_LANG
30 33
 
31 34
 ### If it's a multi-instance app, meaning it can be installed several times independently
32 35
 ### The id of the app as stated in the manifest is available as $YNH_APP_ID
@@ -64,6 +67,9 @@ ynh_print_info "Storing installation settings..."
64 67
 ynh_app_setting_set $app domain $domain
65 68
 ynh_app_setting_set $app path $path_url
66 69
 ynh_app_setting_set $app is_public $is_public
70
+ynh_app_setting_set $app lang $lang
71
+ynh_app_setting_set $app dark_mode $dark_mode
72
+ynh_app_setting_set $app registration_enabled $registration_enabled
67 73
 
68 74
 #=================================================
69 75
 # STANDARD MODIFICATIONS
@@ -116,12 +122,11 @@ ynh_install_app_dependencies $pkg_dependencies
116 122
 # Download, check integrity, uncompress and patch the source from app.src
117 123
 #ynh_setup_source "$final_path"
118 124
 
119
-cd /var/www/
125
+pushd /var/www/
120 126
 git clone https://github.com/omarroth/invidious
121 127
 cd /var/www/invidious/
122 128
 git checkout tags/0.19.1
123
-cd /home/invidious_ynh/scripts/
124
-
129
+popd
125 130
 
126 131
 #=================================================
127 132
 # CREATE A MYSQL DATABASE
@@ -186,13 +191,22 @@ ynh_system_user_create $app
186 191
 # SPECIFIC SETUP
187 192
 #=================================================
188 193
 
194
+pushd /var/www/invidious/
189 195
 
190
-#sudo -i -u invidious
191
-cd /var/www/invidious/
192 196
 shards update && shards install
193 197
 crystal build src/invidious.cr --release
194
-cd /home/invidious_ynh/scripts/
195
-#exit
198
+#rm /var/www/invidious/config/config.yml
199
+#cp /home/invidious_ynh/conf/config.yml /var/www/invidious/config/
200
+
201
+# Configure Invidious
202
+ynh_replace_string --match_string="domain:" --replace_string="domain: $domain" --target_file=$final_path/config/config.yml
203
+#ynh_replace_string --match_string="domain:" --replace_string="" --target_file=$final_path/config/config.yml
204
+echo "default_user_preferences:" >> $final_path/config/config.yml
205
+echo "  dark_mode: $dark_mode" >> $final_path/config/config.yml
206
+echo "  locale: \"$lang\"" >> $final_path/config/config.yml
207
+echo "registration_enabled: $registration_enabled" >> $final_path/config/config.yml
208
+
209
+popd
196 210
 
197 211
 #=================================================
198 212
 
@@ -219,37 +233,6 @@ ynh_add_systemd_config
219 233
 ynh_systemd_action
220 234
 
221 235
 #=================================================
222
-# SETUP APPLICATION WITH CURL
223
-#=================================================
224
-
225
-### Use these lines only if the app installation needs to be finalized through
226
-### web forms. We generally don't want to ask the final user,
227
-### so we're going to use curl to automatically fill the fields and submit the
228
-### forms.
229
-
230
-# Set right permissions for curl install
231
-#chown -R $app: $final_path
232
-
233
-# Set the app as temporarily public for curl call
234
-#ynh_print_info "Configuring SSOwat..."
235
-#ynh_app_setting_set $app skipped_uris "/"
236
-# Reload SSOwat config
237
-#yunohost app ssowatconf
238
-
239
-# Reload Nginx
240
-#systemctl reload nginx
241
-
242
-# Installation with curl
243
-#ynh_print_info "Finalizing installation..."
244
-#ynh_local_curl "/INSTALL_PATH" "key1=value1" "key2=value2" "key3=value3"
245
-
246
-# Remove the public access
247
-#if [ $is_public -eq 0 ]
248
-#then
249
-#	ynh_app_setting_delete $app skipped_uris
250
-#fi
251
-
252
-#=================================================
253 236
 # MODIFY A CONFIG FILE
254 237
 #=================================================
255 238
 
@@ -267,7 +250,7 @@ ynh_systemd_action
267 250
 ### you can make a backup of this file before modifying it again if the admin had modified it.
268 251
 
269 252
 # Calculate and store the config file checksum into the app settings
270
-ynh_store_file_checksum "$final_path/CONFIG_FILE"
253
+ynh_store_file_checksum "$final_path/config/config.yml"
271 254
 
272 255
 #=================================================
273 256
 # GENERIC FINALIZATION

+ 2
- 2
scripts/remove View File

@@ -56,7 +56,7 @@ ynh_remove_systemd_config
56 56
 #=================================================
57 57
 ynh_print_info "Removing the PostgreSQL database"
58 58
 
59
-ynh_psql_remove_db --db_user=kemal --db_name=invidious
59
+ynh_psql_remove_db --db_user=kemal --db_name=$app
60 60
 
61 61
 #=================================================
62 62
 # REMOVE DEPENDENCIES
@@ -75,7 +75,7 @@ ynh_secure_remove --file=/etc/apt/sources.list.d/crystal.list
75 75
 ynh_print_info "Removing app main directory"
76 76
 
77 77
 # Remove the app directory securely
78
-ynh_secure_remove --file=/var/www/invidious
78
+ynh_secure_remove --file=/var/www/$app
79 79
 
80 80
 #=================================================
81 81
 # REMOVE NGINX CONFIGURATION

Loading…
Cancel
Save