mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Compare commits
36 commits
debian/11.
...
dev
Author | SHA1 | Date | |
---|---|---|---|
|
a5049a8a13 | ||
|
6e84e3532a | ||
|
917cf251fb | ||
|
8a5f2808a1 | ||
68f35831e7 | |||
b91e9dd8f4 | |||
38b39ebaea | |||
ef17082768 | |||
e3ddb1dc4d | |||
|
5b37936d11 | ||
|
e82d20aa7b | ||
|
aff885e6b7 | ||
|
7a04462ccd | ||
|
606e246ec4 | ||
|
e3e8b903c7 | ||
|
488f563b45 | ||
|
3d4804be68 | ||
|
d4f774ad72 | ||
|
d8ab3e68a9 | ||
|
71b50549f5 | ||
|
a40874c305 | ||
|
9223d30a83 | ||
|
5ad9962757 | ||
|
4dfcc13a3f | ||
|
e11b61f49e | ||
|
243a34d2d5 | ||
|
ca2572d00b | ||
|
518c3bbbe2 | ||
|
9517b26c63 | ||
|
a6785d34bc | ||
|
7c79060467 | ||
|
007c13ce42 | ||
|
2102242a61 | ||
|
c409888a4b | ||
|
c14ebc8be4 | ||
|
9b0553580b |
78 changed files with 1628 additions and 1645 deletions
|
@ -1,28 +1,28 @@
|
||||||
VirtualHost "{{ domain }}"
|
VirtualHost "{{ domain }}"
|
||||||
enable = true
|
enable = true
|
||||||
ssl = {
|
ssl = {
|
||||||
key = "/etc/yunohost/certs/{{ domain }}/key.pem";
|
key = "/etc/yunohost/certs/{{ domain }}/key.pem";
|
||||||
certificate = "/etc/yunohost/certs/{{ domain }}/crt.pem";
|
certificate = "/etc/yunohost/certs/{{ domain }}/crt.pem";
|
||||||
}
|
}
|
||||||
authentication = "ldap2"
|
authentication = "ldap2"
|
||||||
ldap = {
|
ldap = {
|
||||||
hostname = "localhost",
|
hostname = "localhost",
|
||||||
user = {
|
user = {
|
||||||
basedn = "ou=users,dc=yunohost,dc=org",
|
basedn = "ou=users,dc=yunohost,dc=org",
|
||||||
filter = "(&(objectClass=posixAccount)(mail=*@{{ domain }})(permission=cn=xmpp.main,ou=permission,dc=yunohost,dc=org))",
|
filter = "(&(objectClass=posixAccount)(mail=*@{{ domain }})(permission=cn=xmpp.main,ou=permission,dc=yunohost,dc=org))",
|
||||||
usernamefield = "mail",
|
usernamefield = "mail",
|
||||||
namefield = "cn",
|
namefield = "cn",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
-- Discovery items
|
-- Discovery items
|
||||||
disco_items = {
|
disco_items = {
|
||||||
{ "muc.{{ domain }}" },
|
{ "muc.{{ domain }}" },
|
||||||
{ "pubsub.{{ domain }}" },
|
{ "pubsub.{{ domain }}" },
|
||||||
{ "jabber.{{ domain }}" },
|
{ "jabber.{{ domain }}" },
|
||||||
{ "vjud.{{ domain }}" },
|
{ "vjud.{{ domain }}" },
|
||||||
{ "xmpp-upload.{{ domain }}" },
|
{ "xmpp-upload.{{ domain }}" },
|
||||||
};
|
};
|
||||||
|
|
||||||
-- contact_info = {
|
-- contact_info = {
|
||||||
-- abuse = { "mailto:abuse@{{ domain }}", "xmpp:admin@{{ domain }}" };
|
-- abuse = { "mailto:abuse@{{ domain }}", "xmpp:admin@{{ domain }}" };
|
||||||
|
@ -35,41 +35,41 @@ VirtualHost "{{ domain }}"
|
||||||
|
|
||||||
---Set up a MUC (multi-user chat) room server
|
---Set up a MUC (multi-user chat) room server
|
||||||
Component "muc.{{ domain }}" "muc"
|
Component "muc.{{ domain }}" "muc"
|
||||||
name = "{{ domain }} Chatrooms"
|
name = "{{ domain }} Chatrooms"
|
||||||
|
|
||||||
modules_enabled = {
|
modules_enabled = {
|
||||||
"muc_limits";
|
"muc_limits";
|
||||||
"muc_log";
|
"muc_log";
|
||||||
"muc_log_mam";
|
"muc_log_mam";
|
||||||
"muc_log_http";
|
"muc_log_http";
|
||||||
"muc_vcard";
|
"muc_vcard";
|
||||||
}
|
}
|
||||||
|
|
||||||
muc_event_rate = 0.5
|
muc_event_rate = 0.5
|
||||||
muc_burst_factor = 10
|
muc_burst_factor = 10
|
||||||
room_default_config = {
|
room_default_config = {
|
||||||
logging = true,
|
logging = true,
|
||||||
persistent = true
|
persistent = true
|
||||||
};
|
};
|
||||||
|
|
||||||
---Set up a PubSub server
|
---Set up a PubSub server
|
||||||
Component "pubsub.{{ domain }}" "pubsub"
|
Component "pubsub.{{ domain }}" "pubsub"
|
||||||
name = "{{ domain }} Publish/Subscribe"
|
name = "{{ domain }} Publish/Subscribe"
|
||||||
|
|
||||||
unrestricted_node_creation = true -- Anyone can create a PubSub node (from any server)
|
unrestricted_node_creation = true -- Anyone can create a PubSub node (from any server)
|
||||||
|
|
||||||
---Set up a HTTP Upload service
|
---Set up a HTTP Upload service
|
||||||
Component "xmpp-upload.{{ domain }}" "http_upload"
|
Component "xmpp-upload.{{ domain }}" "http_upload"
|
||||||
name = "{{ domain }} Sharing Service"
|
name = "{{ domain }} Sharing Service"
|
||||||
|
|
||||||
http_file_path = "/var/xmpp-upload/{{ domain }}/upload"
|
http_file_path = "/var/xmpp-upload/{{ domain }}/upload"
|
||||||
http_external_url = "https://xmpp-upload.{{ domain }}:443"
|
http_external_url = "https://xmpp-upload.{{ domain }}:443"
|
||||||
http_file_base_path = "/upload"
|
http_file_base_path = "/upload"
|
||||||
http_file_size_limit = 6*1024*1024
|
http_file_size_limit = 6*1024*1024
|
||||||
http_file_quota = 60*1024*1024
|
http_file_quota = 60*1024*1024
|
||||||
http_upload_file_size_limit = 100 * 1024 * 1024 -- bytes
|
http_upload_file_size_limit = 100 * 1024 * 1024 -- bytes
|
||||||
http_upload_quota = 10 * 1024 * 1024 * 1024 -- bytes
|
http_upload_quota = 10 * 1024 * 1024 * 1024 -- bytes
|
||||||
|
|
||||||
---Set up a VJUD service
|
---Set up a VJUD service
|
||||||
Component "vjud.{{ domain }}" "vjud"
|
Component "vjud.{{ domain }}" "vjud"
|
||||||
vjud_disco_name = "{{ domain }} User Directory"
|
vjud_disco_name = "{{ domain }} User Directory"
|
||||||
|
|
|
@ -1,72 +1,72 @@
|
||||||
-- ** Metronome's config file example **
|
-- ** Metronome's config file example **
|
||||||
--
|
--
|
||||||
-- The format is exactly equal to Prosody's:
|
-- The format is exactly equal to Prosody's:
|
||||||
--
|
--
|
||||||
-- Lists are written { "like", "this", "one" }
|
-- Lists are written { "like", "this", "one" }
|
||||||
-- Lists can also be of { 1, 2, 3 } numbers, etc.
|
-- Lists can also be of { 1, 2, 3 } numbers, etc.
|
||||||
-- Either commas, or semi-colons; may be used as seperators.
|
-- Either commas, or semi-colons; may be used as seperators.
|
||||||
--
|
--
|
||||||
-- A table is a list of values, except each value has a name. An
|
-- A table is a list of values, except each value has a name. An
|
||||||
-- example would be:
|
-- example would be:
|
||||||
--
|
--
|
||||||
-- ssl = { key = "keyfile.key", certificate = "certificate.cert" }
|
-- ssl = { key = "keyfile.key", certificate = "certificate.cert" }
|
||||||
--
|
--
|
||||||
-- Tip: You can check that the syntax of this file is correct when you have finished
|
-- Tip: You can check that the syntax of this file is correct when you have finished
|
||||||
-- by running: luac -p metronome.cfg.lua
|
-- by running: luac -p metronome.cfg.lua
|
||||||
-- If there are any errors, it will let you know what and where they are, otherwise it
|
-- If there are any errors, it will let you know what and where they are, otherwise it
|
||||||
-- will keep quiet.
|
-- will keep quiet.
|
||||||
|
|
||||||
-- Global settings go in this section
|
-- Global settings go in this section
|
||||||
|
|
||||||
-- This is the list of modules Metronome will load on startup.
|
-- This is the list of modules Metronome will load on startup.
|
||||||
-- It looks for mod_modulename.lua in the plugins folder, so make sure that exists too.
|
-- It looks for mod_modulename.lua in the plugins folder, so make sure that exists too.
|
||||||
|
|
||||||
modules_enabled = {
|
modules_enabled = {
|
||||||
-- Generally required
|
-- Generally required
|
||||||
"roster"; -- Allow users to have a roster. Recommended.
|
"roster"; -- Allow users to have a roster. Recommended.
|
||||||
"saslauth"; -- Authentication for clients. Recommended if you want to log in.
|
"saslauth"; -- Authentication for clients. Recommended if you want to log in.
|
||||||
"tls"; -- Add support for secure TLS on c2s/s2s connections
|
"tls"; -- Add support for secure TLS on c2s/s2s connections
|
||||||
"disco"; -- Service discovery
|
"disco"; -- Service discovery
|
||||||
|
|
||||||
-- Not essential, but recommended
|
|
||||||
"private"; -- Private XML storage (for room bookmarks, etc.)
|
|
||||||
"vcard"; -- Allow users to set vCards
|
|
||||||
"pep"; -- Allows setting of mood, tune, etc.
|
|
||||||
"pubsub"; -- Publish-subscribe XEP-0060
|
|
||||||
"posix"; -- POSIX functionality, sends server to background, enables syslog, etc.
|
|
||||||
"bidi"; -- Enables Bidirectional Server-to-Server Streams.
|
|
||||||
|
|
||||||
-- Nice to have
|
|
||||||
"version"; -- Replies to server version requests
|
|
||||||
"uptime"; -- Report how long server has been running
|
|
||||||
"time"; -- Let others know the time here on this server
|
|
||||||
"ping"; -- Replies to XMPP pings with pongs
|
|
||||||
"register"; -- Allow users to register on this server using a client and change passwords
|
|
||||||
"stream_management"; -- Allows clients and servers to use Stream Management
|
|
||||||
"stanza_optimizations"; -- Allows clients to use Client State Indication and SIFT
|
|
||||||
"message_carbons"; -- Allows clients to enable carbon copies of messages
|
|
||||||
"mam"; -- Enable server-side message archives using Message Archive Management
|
|
||||||
"push"; -- Enable Push Notifications via PubSub using XEP-0357
|
|
||||||
"lastactivity"; -- Enables clients to know the last presence status of an user
|
|
||||||
"adhoc_cm"; -- Allow to set client certificates to login through SASL External via adhoc
|
|
||||||
"admin_adhoc"; -- administration adhoc commands
|
|
||||||
"bookmarks"; -- XEP-0048 Bookmarks synchronization between PEP and Private Storage
|
|
||||||
"sec_labels"; -- Allows to use a simplified version XEP-0258 Security Labels and related ACDFs.
|
|
||||||
"privacy"; -- Add privacy lists and simple blocking command support
|
|
||||||
|
|
||||||
-- Other specific functionality
|
-- Not essential, but recommended
|
||||||
--"admin_telnet"; -- administration console, telnet to port 5582
|
"private"; -- Private XML storage (for room bookmarks, etc.)
|
||||||
--"admin_web"; -- administration web interface
|
"vcard"; -- Allow users to set vCards
|
||||||
"bosh"; -- Enable support for BOSH clients, aka "XMPP over Bidirectional Streams over Synchronous HTTP"
|
"pep"; -- Allows setting of mood, tune, etc.
|
||||||
--"compression"; -- Allow clients to enable Stream Compression
|
"pubsub"; -- Publish-subscribe XEP-0060
|
||||||
--"spim_block"; -- Require authorization via OOB form for messages from non-contacts and block unsollicited messages
|
"posix"; -- POSIX functionality, sends server to background, enables syslog, etc.
|
||||||
--"gate_guard"; -- Enable config-based blacklisting and hit-based auto-banning features
|
"bidi"; -- Enables Bidirectional Server-to-Server Streams.
|
||||||
--"incidents_handling"; -- Enable Incidents Handling support (can be administered via adhoc commands)
|
|
||||||
--"server_presence"; -- Enables Server Buddies extension support
|
-- Nice to have
|
||||||
--"service_directory"; -- Enables Service Directories extension support
|
"version"; -- Replies to server version requests
|
||||||
--"public_service"; -- Enables Server vCard support for public services in directories and advertises in features
|
"uptime"; -- Report how long server has been running
|
||||||
--"register_api"; -- Provides secure API for both Out-Of-Band and In-Band registration for E-Mail verification
|
"time"; -- Let others know the time here on this server
|
||||||
"websocket"; -- Enable support for WebSocket clients, aka "XMPP over WebSockets"
|
"ping"; -- Replies to XMPP pings with pongs
|
||||||
|
"register"; -- Allow users to register on this server using a client and change passwords
|
||||||
|
"stream_management"; -- Allows clients and servers to use Stream Management
|
||||||
|
"stanza_optimizations"; -- Allows clients to use Client State Indication and SIFT
|
||||||
|
"message_carbons"; -- Allows clients to enable carbon copies of messages
|
||||||
|
"mam"; -- Enable server-side message archives using Message Archive Management
|
||||||
|
"push"; -- Enable Push Notifications via PubSub using XEP-0357
|
||||||
|
"lastactivity"; -- Enables clients to know the last presence status of an user
|
||||||
|
"adhoc_cm"; -- Allow to set client certificates to login through SASL External via adhoc
|
||||||
|
"admin_adhoc"; -- administration adhoc commands
|
||||||
|
"bookmarks"; -- XEP-0048 Bookmarks synchronization between PEP and Private Storage
|
||||||
|
"sec_labels"; -- Allows to use a simplified version XEP-0258 Security Labels and related ACDFs.
|
||||||
|
"privacy"; -- Add privacy lists and simple blocking command support
|
||||||
|
|
||||||
|
-- Other specific functionality
|
||||||
|
--"admin_telnet"; -- administration console, telnet to port 5582
|
||||||
|
--"admin_web"; -- administration web interface
|
||||||
|
"bosh"; -- Enable support for BOSH clients, aka "XMPP over Bidirectional Streams over Synchronous HTTP"
|
||||||
|
--"compression"; -- Allow clients to enable Stream Compression
|
||||||
|
--"spim_block"; -- Require authorization via OOB form for messages from non-contacts and block unsollicited messages
|
||||||
|
--"gate_guard"; -- Enable config-based blacklisting and hit-based auto-banning features
|
||||||
|
--"incidents_handling"; -- Enable Incidents Handling support (can be administered via adhoc commands)
|
||||||
|
--"server_presence"; -- Enables Server Buddies extension support
|
||||||
|
--"service_directory"; -- Enables Service Directories extension support
|
||||||
|
--"public_service"; -- Enables Server vCard support for public services in directories and advertises in features
|
||||||
|
--"register_api"; -- Provides secure API for both Out-Of-Band and In-Band registration for E-Mail verification
|
||||||
|
"websocket"; -- Enable support for WebSocket clients, aka "XMPP over WebSockets"
|
||||||
};
|
};
|
||||||
|
|
||||||
-- Server PID
|
-- Server PID
|
||||||
|
@ -102,10 +102,10 @@ csi_config_queue_all_muc_messages_but_mentions = false;
|
||||||
|
|
||||||
-- Logging configuration
|
-- Logging configuration
|
||||||
log = {
|
log = {
|
||||||
info = "/var/log/metronome/metronome.log"; -- Change 'info' to 'debug' for verbose logging
|
info = "/var/log/metronome/metronome.log"; -- Change 'info' to 'debug' for verbose logging
|
||||||
error = "/var/log/metronome/metronome.err";
|
error = "/var/log/metronome/metronome.err";
|
||||||
-- "*syslog"; -- Uncomment this for logging to syslog
|
-- "*syslog"; -- Uncomment this for logging to syslog
|
||||||
-- "*console"; -- Log to the console, useful for debugging with daemonize=false
|
-- "*console"; -- Log to the console, useful for debugging with daemonize=false
|
||||||
}
|
}
|
||||||
|
|
||||||
------ Components ------
|
------ Components ------
|
||||||
|
@ -114,7 +114,7 @@ log = {
|
||||||
|
|
||||||
---Set up a local BOSH service
|
---Set up a local BOSH service
|
||||||
Component "localhost" "http"
|
Component "localhost" "http"
|
||||||
modules_enabled = { "bosh" }
|
modules_enabled = { "bosh" }
|
||||||
|
|
||||||
----------- Virtual hosts -----------
|
----------- Virtual hosts -----------
|
||||||
-- You need to add a VirtualHost entry for each domain you wish Metronome to serve.
|
-- You need to add a VirtualHost entry for each domain you wish Metronome to serve.
|
||||||
|
|
|
@ -23,68 +23,68 @@ if not ldap then
|
||||||
end
|
end
|
||||||
|
|
||||||
function new_default_provider(host)
|
function new_default_provider(host)
|
||||||
local provider = { name = "ldap2" };
|
local provider = { name = "ldap2" };
|
||||||
log("debug", "initializing ldap2 authentication provider for host '%s'", host);
|
log("debug", "initializing ldap2 authentication provider for host '%s'", host);
|
||||||
|
|
||||||
function provider.test_password(username, password)
|
function provider.test_password(username, password)
|
||||||
return ldap.bind(username, password);
|
return ldap.bind(username, password);
|
||||||
end
|
end
|
||||||
|
|
||||||
function provider.user_exists(username)
|
function provider.user_exists(username)
|
||||||
local params = ldap.getparams()
|
local params = ldap.getparams()
|
||||||
|
|
||||||
local filter = ldap.filter.combine_and(params.user.filter, params.user.usernamefield .. '=' .. username);
|
local filter = ldap.filter.combine_and(params.user.filter, params.user.usernamefield .. '=' .. username);
|
||||||
if params.user.usernamefield == 'mail' then
|
if params.user.usernamefield == 'mail' then
|
||||||
filter = ldap.filter.combine_and(params.user.filter, 'mail=' .. username .. '@*');
|
filter = ldap.filter.combine_and(params.user.filter, 'mail=' .. username .. '@*');
|
||||||
end
|
end
|
||||||
|
|
||||||
return ldap.singlematch {
|
return ldap.singlematch {
|
||||||
base = params.user.basedn,
|
base = params.user.basedn,
|
||||||
filter = filter,
|
filter = filter,
|
||||||
};
|
};
|
||||||
end
|
end
|
||||||
|
|
||||||
function provider.get_password(username)
|
function provider.get_password(username)
|
||||||
return nil, "Passwords unavailable for LDAP.";
|
return nil, "Passwords unavailable for LDAP.";
|
||||||
end
|
end
|
||||||
|
|
||||||
function provider.set_password(username, password)
|
function provider.set_password(username, password)
|
||||||
return nil, "Passwords unavailable for LDAP.";
|
return nil, "Passwords unavailable for LDAP.";
|
||||||
end
|
end
|
||||||
|
|
||||||
function provider.create_user(username, password)
|
function provider.create_user(username, password)
|
||||||
return nil, "Account creation/modification not available with LDAP.";
|
return nil, "Account creation/modification not available with LDAP.";
|
||||||
end
|
end
|
||||||
|
|
||||||
function provider.get_sasl_handler(session)
|
function provider.get_sasl_handler(session)
|
||||||
local testpass_authentication_profile = {
|
local testpass_authentication_profile = {
|
||||||
session = session,
|
session = session,
|
||||||
plain_test = function(sasl, username, password, realm)
|
plain_test = function(sasl, username, password, realm)
|
||||||
return provider.test_password(username, password), true;
|
return provider.test_password(username, password), true;
|
||||||
end,
|
end,
|
||||||
order = { "plain_test" },
|
order = { "plain_test" },
|
||||||
};
|
};
|
||||||
return new_sasl(module.host, testpass_authentication_profile);
|
return new_sasl(module.host, testpass_authentication_profile);
|
||||||
end
|
end
|
||||||
|
|
||||||
function provider.is_admin(jid)
|
function provider.is_admin(jid)
|
||||||
local admin_config = ldap.getparams().admin;
|
local admin_config = ldap.getparams().admin;
|
||||||
|
|
||||||
if not admin_config then
|
if not admin_config then
|
||||||
return;
|
return;
|
||||||
end
|
end
|
||||||
|
|
||||||
local ld = ldap:getconnection();
|
local ld = ldap:getconnection();
|
||||||
local username = jsplit(jid);
|
local username = jsplit(jid);
|
||||||
local filter = ldap.filter.combine_and(admin_config.filter, admin_config.namefield .. '=' .. username);
|
local filter = ldap.filter.combine_and(admin_config.filter, admin_config.namefield .. '=' .. username);
|
||||||
|
|
||||||
return ldap.singlematch {
|
return ldap.singlematch {
|
||||||
base = admin_config.basedn,
|
base = admin_config.basedn,
|
||||||
filter = filter,
|
filter = filter,
|
||||||
};
|
};
|
||||||
end
|
end
|
||||||
|
|
||||||
return provider;
|
return provider;
|
||||||
end
|
end
|
||||||
|
|
||||||
module:add_item("auth-provider", new_default_provider(module.host));
|
module:add_item("auth-provider", new_default_provider(module.host));
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
-- Prosody IM
|
-- Prosody IM
|
||||||
-- Copyright (C) 2008-2010 Matthew Wild
|
-- Copyright (C) 2008-2010 Matthew Wild
|
||||||
-- Copyright (C) 2008-2010 Waqas Hussain
|
-- Copyright (C) 2008-2010 Waqas Hussain
|
||||||
--
|
--
|
||||||
-- This project is MIT/X11 licensed. Please see the
|
-- This project is MIT/X11 licensed. Please see the
|
||||||
-- COPYING file in the source package for more information.
|
-- COPYING file in the source package for more information.
|
||||||
--
|
--
|
||||||
|
@ -12,8 +12,8 @@ local st = require "util.stanza";
|
||||||
local t_concat = table.concat;
|
local t_concat = table.concat;
|
||||||
|
|
||||||
local secure_auth_only = module:get_option("c2s_require_encryption")
|
local secure_auth_only = module:get_option("c2s_require_encryption")
|
||||||
or module:get_option("require_encryption")
|
or module:get_option("require_encryption")
|
||||||
or not(module:get_option("allow_unencrypted_plain_auth"));
|
or not(module:get_option("allow_unencrypted_plain_auth"));
|
||||||
|
|
||||||
local sessionmanager = require "core.sessionmanager";
|
local sessionmanager = require "core.sessionmanager";
|
||||||
local usermanager = require "core.usermanager";
|
local usermanager = require "core.usermanager";
|
||||||
|
@ -22,66 +22,65 @@ local resourceprep = require "util.encodings".stringprep.resourceprep;
|
||||||
|
|
||||||
module:add_feature("jabber:iq:auth");
|
module:add_feature("jabber:iq:auth");
|
||||||
module:hook("stream-features", function(event)
|
module:hook("stream-features", function(event)
|
||||||
local origin, features = event.origin, event.features;
|
local origin, features = event.origin, event.features;
|
||||||
if secure_auth_only and not origin.secure then
|
if secure_auth_only and not origin.secure then
|
||||||
-- Sorry, not offering to insecure streams!
|
-- Sorry, not offering to insecure streams!
|
||||||
return;
|
return;
|
||||||
elseif not origin.username then
|
elseif not origin.username then
|
||||||
features:tag("auth", {xmlns='http://jabber.org/features/iq-auth'}):up();
|
features:tag("auth", {xmlns='http://jabber.org/features/iq-auth'}):up();
|
||||||
end
|
end
|
||||||
end);
|
end);
|
||||||
|
|
||||||
module:hook("stanza/iq/jabber:iq:auth:query", function(event)
|
module:hook("stanza/iq/jabber:iq:auth:query", function(event)
|
||||||
local session, stanza = event.origin, event.stanza;
|
local session, stanza = event.origin, event.stanza;
|
||||||
|
|
||||||
if session.type ~= "c2s_unauthed" then
|
if session.type ~= "c2s_unauthed" then
|
||||||
(session.sends2s or session.send)(st.error_reply(stanza, "cancel", "service-unavailable", "Legacy authentication is only allowed for unauthenticated client connections."));
|
(session.sends2s or session.send)(st.error_reply(stanza, "cancel", "service-unavailable", "Legacy authentication is only allowed for unauthenticated client connections."));
|
||||||
return true;
|
return true;
|
||||||
end
|
end
|
||||||
|
|
||||||
if secure_auth_only and not session.secure then
|
if secure_auth_only and not session.secure then
|
||||||
session.send(st.error_reply(stanza, "modify", "not-acceptable", "Encryption (SSL or TLS) is required to connect to this server"));
|
session.send(st.error_reply(stanza, "modify", "not-acceptable", "Encryption (SSL or TLS) is required to connect to this server"));
|
||||||
return true;
|
return true;
|
||||||
end
|
end
|
||||||
|
|
||||||
local username = stanza.tags[1]:child_with_name("username");
|
local username = stanza.tags[1]:child_with_name("username");
|
||||||
local password = stanza.tags[1]:child_with_name("password");
|
local password = stanza.tags[1]:child_with_name("password");
|
||||||
local resource = stanza.tags[1]:child_with_name("resource");
|
local resource = stanza.tags[1]:child_with_name("resource");
|
||||||
if not (username and password and resource) then
|
if not (username and password and resource) then
|
||||||
local reply = st.reply(stanza);
|
local reply = st.reply(stanza);
|
||||||
session.send(reply:query("jabber:iq:auth")
|
session.send(reply:query("jabber:iq:auth")
|
||||||
:tag("username"):up()
|
:tag("username"):up()
|
||||||
:tag("password"):up()
|
:tag("password"):up()
|
||||||
:tag("resource"):up());
|
:tag("resource"):up());
|
||||||
else
|
else
|
||||||
username, password, resource = t_concat(username), t_concat(password), t_concat(resource);
|
username, password, resource = t_concat(username), t_concat(password), t_concat(resource);
|
||||||
username = nodeprep(username);
|
username = nodeprep(username);
|
||||||
resource = resourceprep(resource)
|
resource = resourceprep(resource)
|
||||||
if not (username and resource) then
|
if not (username and resource) then
|
||||||
session.send(st.error_reply(stanza, "modify", "bad-request"));
|
session.send(st.error_reply(stanza, "modify", "bad-request"));
|
||||||
return true;
|
return true;
|
||||||
end
|
end
|
||||||
if usermanager.test_password(username, session.host, password) then
|
if usermanager.test_password(username, session.host, password) then
|
||||||
-- Authentication successful!
|
-- Authentication successful!
|
||||||
local success, err = sessionmanager.make_authenticated(session, username);
|
local success, err = sessionmanager.make_authenticated(session, username);
|
||||||
if success then
|
if success then
|
||||||
local err_type, err_msg;
|
local err_type, err_msg;
|
||||||
success, err_type, err, err_msg = sessionmanager.bind_resource(session, resource);
|
success, err_type, err, err_msg = sessionmanager.bind_resource(session, resource);
|
||||||
if not success then
|
if not success then
|
||||||
session.send(st.error_reply(stanza, err_type, err, err_msg));
|
session.send(st.error_reply(stanza, err_type, err, err_msg));
|
||||||
session.username, session.type = nil, "c2s_unauthed"; -- FIXME should this be placed in sessionmanager?
|
session.username, session.type = nil, "c2s_unauthed"; -- FIXME should this be placed in sessionmanager?
|
||||||
return true;
|
return true;
|
||||||
elseif resource ~= session.resource then -- server changed resource, not supported by legacy auth
|
elseif resource ~= session.resource then -- server changed resource, not supported by legacy auth
|
||||||
session.send(st.error_reply(stanza, "cancel", "conflict", "The requested resource could not be assigned to this session."));
|
session.send(st.error_reply(stanza, "cancel", "conflict", "The requested resource could not be assigned to this session."));
|
||||||
session:close(); -- FIXME undo resource bind and auth instead of closing the session?
|
session:close(); -- FIXME undo resource bind and auth instead of closing the session?
|
||||||
return true;
|
return true;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
session.send(st.reply(stanza));
|
session.send(st.reply(stanza));
|
||||||
else
|
else
|
||||||
session.send(st.error_reply(stanza, "auth", "not-authorized"));
|
session.send(st.error_reply(stanza, "auth", "not-authorized"));
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true;
|
return true;
|
||||||
end);
|
end);
|
||||||
|
|
||||||
|
|
|
@ -43,35 +43,35 @@ end
|
||||||
local get_alias_for_user;
|
local get_alias_for_user;
|
||||||
|
|
||||||
do
|
do
|
||||||
local user_cache;
|
local user_cache;
|
||||||
local last_fetch_time;
|
local last_fetch_time;
|
||||||
|
|
||||||
local function populate_user_cache()
|
local function populate_user_cache()
|
||||||
local user_c = get_config(module.host, 'ldap').user;
|
local user_c = get_config(module.host, 'ldap').user;
|
||||||
if not user_c then return; end
|
if not user_c then return; end
|
||||||
|
|
||||||
local ld = ldap.getconnection();
|
local ld = ldap.getconnection();
|
||||||
|
|
||||||
local usernamefield = user_c.usernamefield;
|
local usernamefield = user_c.usernamefield;
|
||||||
local namefield = user_c.namefield;
|
local namefield = user_c.namefield;
|
||||||
|
|
||||||
user_cache = {};
|
user_cache = {};
|
||||||
|
|
||||||
for _, attrs in ld:search { base = user_c.basedn, scope = 'onelevel', filter = user_c.filter } do
|
for _, attrs in ld:search { base = user_c.basedn, scope = 'onelevel', filter = user_c.filter } do
|
||||||
user_cache[attrs[usernamefield]] = attrs[namefield];
|
user_cache[attrs[usernamefield]] = attrs[namefield];
|
||||||
end
|
end
|
||||||
last_fetch_time = gettime();
|
last_fetch_time = gettime();
|
||||||
end
|
end
|
||||||
|
|
||||||
function get_alias_for_user(user)
|
function get_alias_for_user(user)
|
||||||
if last_fetch_time and last_fetch_time + CACHE_EXPIRY < gettime() then
|
if last_fetch_time and last_fetch_time + CACHE_EXPIRY < gettime() then
|
||||||
user_cache = nil;
|
user_cache = nil;
|
||||||
end
|
end
|
||||||
if not user_cache then
|
if not user_cache then
|
||||||
populate_user_cache();
|
populate_user_cache();
|
||||||
end
|
end
|
||||||
return user_cache[user];
|
return user_cache[user];
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
@ -79,18 +79,18 @@ end
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
local function ldap_store(config)
|
local function ldap_store(config)
|
||||||
local self = {};
|
local self = {};
|
||||||
local config = config;
|
local config = config;
|
||||||
|
|
||||||
function self:get(username)
|
function self:get(username)
|
||||||
return nil, "Data getting is not available for this storage backend";
|
return nil, "Data getting is not available for this storage backend";
|
||||||
end
|
end
|
||||||
|
|
||||||
function self:set(username, data)
|
function self:set(username, data)
|
||||||
return nil, "Data setting is not available for this storage backend";
|
return nil, "Data setting is not available for this storage backend";
|
||||||
end
|
end
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
end
|
end
|
||||||
|
|
||||||
local adapters = {};
|
local adapters = {};
|
||||||
|
@ -100,60 +100,60 @@ local adapters = {};
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
adapters.roster = function (config)
|
adapters.roster = function (config)
|
||||||
-- Validate configuration requirements
|
-- Validate configuration requirements
|
||||||
if not config.groups then return nil; end
|
if not config.groups then return nil; end
|
||||||
|
|
||||||
local self = ldap_store(config)
|
local self = ldap_store(config)
|
||||||
|
|
||||||
function self:get(username)
|
function self:get(username)
|
||||||
local ld = ldap.getconnection();
|
local ld = ldap.getconnection();
|
||||||
local contacts = {};
|
local contacts = {};
|
||||||
|
|
||||||
local memberfield = config.groups.memberfield;
|
local memberfield = config.groups.memberfield;
|
||||||
local namefield = config.groups.namefield;
|
local namefield = config.groups.namefield;
|
||||||
local filter = memberfield .. '=' .. tostring(username);
|
local filter = memberfield .. '=' .. tostring(username);
|
||||||
|
|
||||||
local groups = {};
|
local groups = {};
|
||||||
for _, config in ipairs(config.groups) do
|
for _, config in ipairs(config.groups) do
|
||||||
groups[ config[namefield] ] = config.name;
|
groups[ config[namefield] ] = config.name;
|
||||||
end
|
end
|
||||||
|
|
||||||
log("debug", "Found %d group(s) for user %s", select('#', groups), username)
|
log("debug", "Found %d group(s) for user %s", select('#', groups), username)
|
||||||
|
|
||||||
-- XXX this kind of relies on the way we do groups at INOC
|
-- XXX this kind of relies on the way we do groups at INOC
|
||||||
for _, attrs in ld:search { base = config.groups.basedn, scope = 'onelevel', filter = filter } do
|
for _, attrs in ld:search { base = config.groups.basedn, scope = 'onelevel', filter = filter } do
|
||||||
if groups[ attrs[namefield] ] then
|
if groups[ attrs[namefield] ] then
|
||||||
local members = attrs[memberfield];
|
local members = attrs[memberfield];
|
||||||
|
|
||||||
for _, user in ipairs(members) do
|
for _, user in ipairs(members) do
|
||||||
if user ~= username then
|
if user ~= username then
|
||||||
local jid = user .. '@' .. module.host;
|
local jid = user .. '@' .. module.host;
|
||||||
local record = contacts[jid];
|
local record = contacts[jid];
|
||||||
|
|
||||||
if not record then
|
if not record then
|
||||||
record = {
|
record = {
|
||||||
subscription = 'both',
|
subscription = 'both',
|
||||||
groups = {},
|
groups = {},
|
||||||
name = get_alias_for_user(user),
|
name = get_alias_for_user(user),
|
||||||
};
|
};
|
||||||
contacts[jid] = record;
|
contacts[jid] = record;
|
||||||
end
|
end
|
||||||
|
|
||||||
record.groups[ groups[ attrs[namefield] ] ] = true;
|
record.groups[ groups[ attrs[namefield] ] ] = true;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return contacts;
|
return contacts;
|
||||||
end
|
end
|
||||||
|
|
||||||
function self:set(username, data)
|
function self:set(username, data)
|
||||||
log("warn", "Setting data in Roster LDAP storage is not supported yet")
|
log("warn", "Setting data in Roster LDAP storage is not supported yet")
|
||||||
return nil, "not supported";
|
return nil, "not supported";
|
||||||
end
|
end
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
end
|
end
|
||||||
|
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
@ -161,35 +161,35 @@ end
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
||||||
adapters.vcard = function (config)
|
adapters.vcard = function (config)
|
||||||
-- Validate configuration requirements
|
-- Validate configuration requirements
|
||||||
if not config.vcard_format or not config.user then return nil; end
|
if not config.vcard_format or not config.user then return nil; end
|
||||||
|
|
||||||
local self = ldap_store(config)
|
local self = ldap_store(config)
|
||||||
|
|
||||||
function self:get(username)
|
function self:get(username)
|
||||||
local ld = ldap.getconnection();
|
local ld = ldap.getconnection();
|
||||||
local filter = config.user.usernamefield .. '=' .. tostring(username);
|
local filter = config.user.usernamefield .. '=' .. tostring(username);
|
||||||
|
|
||||||
log("debug", "Retrieving vCard for user '%s'", username);
|
log("debug", "Retrieving vCard for user '%s'", username);
|
||||||
|
|
||||||
local match = ldap.singlematch {
|
local match = ldap.singlematch {
|
||||||
base = config.user.basedn,
|
base = config.user.basedn,
|
||||||
filter = filter,
|
filter = filter,
|
||||||
};
|
};
|
||||||
if match then
|
if match then
|
||||||
match.jid = username .. '@' .. module.host
|
match.jid = username .. '@' .. module.host
|
||||||
return st.preserialize(ldap_record_to_vcard(match, config.vcard_format));
|
return st.preserialize(ldap_record_to_vcard(match, config.vcard_format));
|
||||||
else
|
else
|
||||||
return nil, "username not found";
|
return nil, "username not found";
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function self:set(username, data)
|
function self:set(username, data)
|
||||||
log("warn", "Setting data in vCard LDAP storage is not supported yet")
|
log("warn", "Setting data in vCard LDAP storage is not supported yet")
|
||||||
return nil, "not supported";
|
return nil, "not supported";
|
||||||
end
|
end
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
end
|
end
|
||||||
|
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
|
|
|
@ -135,28 +135,28 @@ function builder_methods:build()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function new_builder(params)
|
local function new_builder(params)
|
||||||
local vcard_tag = st.stanza('vCard', { xmlns = VCARD_NS });
|
local vcard_tag = st.stanza('vCard', { xmlns = VCARD_NS });
|
||||||
|
|
||||||
local object = {
|
local object = {
|
||||||
vcard = vcard_tag,
|
vcard = vcard_tag,
|
||||||
__index = builder_methods,
|
__index = builder_methods,
|
||||||
};
|
};
|
||||||
|
|
||||||
for k, v in pairs(params) do
|
for k, v in pairs(params) do
|
||||||
object[k] = v;
|
object[k] = v;
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(object, object);
|
setmetatable(object, object);
|
||||||
|
|
||||||
return object;
|
return object;
|
||||||
end
|
end
|
||||||
|
|
||||||
local _M = {};
|
local _M = {};
|
||||||
|
|
||||||
function _M.create(params)
|
function _M.create(params)
|
||||||
local builder = new_builder(params);
|
local builder = new_builder(params);
|
||||||
|
|
||||||
return builder:build();
|
return builder:build();
|
||||||
end
|
end
|
||||||
|
|
||||||
return _M;
|
return _M;
|
||||||
|
|
26
debian/changelog
vendored
26
debian/changelog
vendored
|
@ -1,3 +1,29 @@
|
||||||
|
yunohost (11.2.30) stable; urgency=low
|
||||||
|
|
||||||
|
- helpers v2.1: check if patches dir exists before getting realpath ([#1938](http://github.com/YunoHost/yunohost/pull/1938))
|
||||||
|
- helpers v2.1: ynh_add_swap and ynh_smart_mktemp (aff885e6b)
|
||||||
|
- helpers v2.1: fix ynh_restore_everything ([#1943](http://github.com/YunoHost/yunohost/pull/1943))
|
||||||
|
- helpers v2.1: fix typo in docs: ynh_install_app_dependencies -> ynh_apt_install_dependencies ([#1939](http://github.com/YunoHost/yunohost/pull/1939))
|
||||||
|
- helpers: fix syntax, disambiguate subshell syntax ([#1940](http://github.com/YunoHost/yunohost/pull/1940))
|
||||||
|
- quality: Add maintenante/shfmt.sh for shell script formatting (68f35831e)
|
||||||
|
- quality: Apply shfmt everywhere, fix tabs/space/indent (8a5f2808a, e3ddb1dc4, ef1708276, 38b39ebae, b91e9dd8f)
|
||||||
|
|
||||||
|
Thanks to all contributors <3 ! (Félix Piédallu, Josué Tille, OniriCorpe, selfhoster1312)
|
||||||
|
|
||||||
|
-- Alexandre Aubin <alex.aubin@mailoo.org> Sat, 31 Aug 2024 19:26:59 +0200
|
||||||
|
|
||||||
|
yunohost (11.2.29) stable; urgency=low
|
||||||
|
|
||||||
|
- apps: generalize replacing __INSTALL_DIR__ and __APP__ in config panel 'bind' statement to any setting (9b0553580)
|
||||||
|
- apps/config panels: move the computation of the actual 'bind' value to the python core (a6785d34b)
|
||||||
|
- perf: add cache for _get_app_settings() (c14ebc8be, 7c7906046)
|
||||||
|
- quality: use _assert_is_installed for consistency instead of if not _is_intalled(app): raise (c409888a4)
|
||||||
|
- i18n: Translations updated for Basque, French, Galician, Greek, Indonesian
|
||||||
|
|
||||||
|
Thanks to all contributors <3 ! (cjdw, craftrac, José M, ppr, xabirequejo)
|
||||||
|
|
||||||
|
-- Alexandre Aubin <alex.aubin@mailoo.org> Tue, 27 Aug 2024 14:46:26 +0200
|
||||||
|
|
||||||
yunohost (11.2.28) stable; urgency=low
|
yunohost (11.2.28) stable; urgency=low
|
||||||
|
|
||||||
- ci: various changes due to CI infrastructure changes (200f0272d, 764fe6a7b, 9083a5cc3, d0df3caed, 6733526be, df320a44c, 92f4a605b, f02d4a437, c5953b542)
|
- ci: various changes due to CI infrastructure changes (200f0272d, 764fe6a7b, 9083a5cc3, d0df3caed, 6733526be, df320a44c, 92f4a605b, f02d4a437, c5953b542)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Entrypoint for the helpers scripts
|
# Entrypoint for the helpers scripts
|
||||||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
|
||||||
|
|
||||||
# Helpers version can be specified via an environment variable or default to 1.
|
# Helpers version can be specified via an environment variable or default to 1.
|
||||||
YNH_HELPERS_VERSION=${YNH_HELPERS_VERSION:-1}
|
YNH_HELPERS_VERSION=${YNH_HELPERS_VERSION:-1}
|
||||||
|
@ -21,6 +21,7 @@ case "$YNH_HELPERS_VERSION" in
|
||||||
*)
|
*)
|
||||||
echo "Helpers are not available in version '$YNH_HELPERS_VERSION'." >&2
|
echo "Helpers are not available in version '$YNH_HELPERS_VERSION'." >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
eval "$XTRACE_ENABLE"
|
eval "$XTRACE_ENABLE"
|
||||||
|
|
|
@ -7,52 +7,49 @@
|
||||||
#
|
#
|
||||||
# Requires YunoHost version *.*.* or higher.
|
# Requires YunoHost version *.*.* or higher.
|
||||||
ynh_install_apps() {
|
ynh_install_apps() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=a
|
local legacy_args=a
|
||||||
local -A args_array=([a]=apps=)
|
local -A args_array=([a]=apps=)
|
||||||
local apps
|
local apps
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
# Split the list of apps in an array
|
# Split the list of apps in an array
|
||||||
local apps_list=($(echo $apps | tr " " "\n"))
|
local apps_list=($(echo $apps | tr " " "\n"))
|
||||||
local apps_dependencies=""
|
local apps_dependencies=""
|
||||||
|
|
||||||
# For each app
|
|
||||||
for one_app_and_its_args in "${apps_list[@]}"
|
|
||||||
do
|
|
||||||
# Retrieve the name of the app (part before ?)
|
|
||||||
local one_app=$(cut -d "?" -f1 <<< "$one_app_and_its_args")
|
|
||||||
[ -z "$one_app" ] && ynh_die --message="You didn't provided a YunoHost app to install"
|
|
||||||
|
|
||||||
yunohost tools update apps
|
# For each app
|
||||||
|
for one_app_and_its_args in "${apps_list[@]}"; do
|
||||||
# Installing or upgrading the app depending if it's installed or not
|
# Retrieve the name of the app (part before ?)
|
||||||
if ! yunohost app list --output-as json --quiet | jq -e --arg id $one_app '.apps[] | select(.id == $id)' >/dev/null
|
local one_app=$(cut -d "?" -f1 <<< "$one_app_and_its_args")
|
||||||
then
|
[ -z "$one_app" ] && ynh_die --message="You didn't provided a YunoHost app to install"
|
||||||
# Retrieve the arguments of the app (part after ?)
|
|
||||||
local one_argument=""
|
|
||||||
if [[ "$one_app_and_its_args" == *"?"* ]]; then
|
|
||||||
one_argument=$(cut -d "?" -f2- <<< "$one_app_and_its_args")
|
|
||||||
one_argument="--args $one_argument"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Install the app with its arguments
|
|
||||||
yunohost app install $one_app $one_argument
|
|
||||||
else
|
|
||||||
# Upgrade the app
|
|
||||||
yunohost app upgrade $one_app
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -z "$apps_dependencies" ]
|
yunohost tools update apps
|
||||||
then
|
|
||||||
apps_dependencies="$apps_dependencies, $one_app"
|
|
||||||
else
|
|
||||||
apps_dependencies="$one_app"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
ynh_app_setting_set --app=$app --key=apps_dependencies --value="$apps_dependencies"
|
# Installing or upgrading the app depending if it's installed or not
|
||||||
|
if ! yunohost app list --output-as json --quiet | jq -e --arg id $one_app '.apps[] | select(.id == $id)' > /dev/null; then
|
||||||
|
# Retrieve the arguments of the app (part after ?)
|
||||||
|
local one_argument=""
|
||||||
|
if [[ "$one_app_and_its_args" == *"?"* ]]; then
|
||||||
|
one_argument=$(cut -d "?" -f2- <<< "$one_app_and_its_args")
|
||||||
|
one_argument="--args $one_argument"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install the app with its arguments
|
||||||
|
yunohost app install $one_app $one_argument
|
||||||
|
else
|
||||||
|
# Upgrade the app
|
||||||
|
yunohost app upgrade $one_app
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$apps_dependencies" ]; then
|
||||||
|
apps_dependencies="$apps_dependencies, $one_app"
|
||||||
|
else
|
||||||
|
apps_dependencies="$one_app"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
ynh_app_setting_set --app=$app --key=apps_dependencies --value="$apps_dependencies"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove other YunoHost apps
|
# Remove other YunoHost apps
|
||||||
|
@ -63,53 +60,47 @@ ynh_install_apps() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version *.*.* or higher.
|
# Requires YunoHost version *.*.* or higher.
|
||||||
ynh_remove_apps() {
|
ynh_remove_apps() {
|
||||||
# Retrieve the apps dependencies of the app
|
# Retrieve the apps dependencies of the app
|
||||||
local apps_dependencies=$(ynh_app_setting_get --app=$app --key=apps_dependencies)
|
local apps_dependencies=$(ynh_app_setting_get --app=$app --key=apps_dependencies)
|
||||||
ynh_app_setting_delete --app=$app --key=apps_dependencies
|
ynh_app_setting_delete --app=$app --key=apps_dependencies
|
||||||
|
|
||||||
if [ ! -z "$apps_dependencies" ]
|
if [ ! -z "$apps_dependencies" ]; then
|
||||||
then
|
# Split the list of apps dependencies in an array
|
||||||
# Split the list of apps dependencies in an array
|
local apps_dependencies_list=($(echo $apps_dependencies | tr ", " "\n"))
|
||||||
local apps_dependencies_list=($(echo $apps_dependencies | tr ", " "\n"))
|
|
||||||
|
|
||||||
# For each apps dependencies
|
|
||||||
for one_app in "${apps_dependencies_list[@]}"
|
|
||||||
do
|
|
||||||
# Retrieve the list of installed apps
|
|
||||||
local installed_apps_list=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
|
|
||||||
local required_by=""
|
|
||||||
local installed_app_required_by=""
|
|
||||||
|
|
||||||
# For each other installed app
|
# For each apps dependencies
|
||||||
for one_installed_app in $installed_apps_list
|
for one_app in "${apps_dependencies_list[@]}"; do
|
||||||
do
|
# Retrieve the list of installed apps
|
||||||
# Retrieve the other apps dependencies
|
local installed_apps_list=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
|
||||||
one_installed_apps_dependencies=$(ynh_app_setting_get --app=$one_installed_app --key=apps_dependencies)
|
local required_by=""
|
||||||
if [ ! -z "$one_installed_apps_dependencies" ]
|
local installed_app_required_by=""
|
||||||
then
|
|
||||||
one_installed_apps_dependencies_list=($(echo $one_installed_apps_dependencies | tr ", " "\n"))
|
|
||||||
|
|
||||||
# For each dependency of the other apps
|
# For each other installed app
|
||||||
for one_installed_app_dependency in "${one_installed_apps_dependencies_list[@]}"
|
for one_installed_app in $installed_apps_list; do
|
||||||
do
|
# Retrieve the other apps dependencies
|
||||||
if [[ $one_installed_app_dependency == $one_app ]]; then
|
one_installed_apps_dependencies=$(ynh_app_setting_get --app=$one_installed_app --key=apps_dependencies)
|
||||||
required_by="$required_by $one_installed_app"
|
if [ ! -z "$one_installed_apps_dependencies" ]; then
|
||||||
fi
|
one_installed_apps_dependencies_list=($(echo $one_installed_apps_dependencies | tr ", " "\n"))
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# If $one_app is no more required
|
# For each dependency of the other apps
|
||||||
if [[ -z "$required_by" ]]
|
for one_installed_app_dependency in "${one_installed_apps_dependencies_list[@]}"; do
|
||||||
then
|
if [[ $one_installed_app_dependency == $one_app ]]; then
|
||||||
# Remove $one_app
|
required_by="$required_by $one_installed_app"
|
||||||
ynh_print_info --message="Removing of $one_app"
|
fi
|
||||||
yunohost app remove $one_app --purge
|
done
|
||||||
else
|
fi
|
||||||
ynh_print_info --message="$one_app was not removed because it's still required by${required_by}"
|
done
|
||||||
fi
|
|
||||||
done
|
# If $one_app is no more required
|
||||||
fi
|
if [[ -z "$required_by" ]]; then
|
||||||
|
# Remove $one_app
|
||||||
|
ynh_print_info --message="Removing of $one_app"
|
||||||
|
yunohost app remove $one_app --purge
|
||||||
|
else
|
||||||
|
ynh_print_info --message="$one_app was not removed because it's still required by${required_by}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Spawn a Bash shell with the app environment loaded
|
# Spawn a Bash shell with the app environment loaded
|
||||||
|
@ -126,90 +117,83 @@ ynh_remove_apps() {
|
||||||
# from the app's service configuration file (defaults to $app.service, overridable by the packager with `service` setting).
|
# from the app's service configuration file (defaults to $app.service, overridable by the packager with `service` setting).
|
||||||
# If the app relies on a specific PHP version, then `php` will be aliased that version. The PHP command will also be appended with the `phpflags` settings.
|
# If the app relies on a specific PHP version, then `php` will be aliased that version. The PHP command will also be appended with the `phpflags` settings.
|
||||||
ynh_spawn_app_shell() {
|
ynh_spawn_app_shell() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=a
|
local legacy_args=a
|
||||||
local -A args_array=([a]=app=)
|
local -A args_array=([a]=app=)
|
||||||
local app
|
local app
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
# Force Bash to be used to run this helper
|
# Force Bash to be used to run this helper
|
||||||
if [[ ! $0 =~ \/?bash$ ]]
|
if [[ ! $0 =~ \/?bash$ ]]; then
|
||||||
then
|
ynh_print_err --message="Please use Bash as shell"
|
||||||
ynh_print_err --message="Please use Bash as shell"
|
exit 1
|
||||||
exit 1
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Make sure the app is installed
|
# Make sure the app is installed
|
||||||
local installed_apps_list=($(yunohost app list --output-as json --quiet | jq -r .apps[].id))
|
local installed_apps_list=($(yunohost app list --output-as json --quiet | jq -r .apps[].id))
|
||||||
if [[ " ${installed_apps_list[*]} " != *" ${app} "* ]]
|
if [[ " ${installed_apps_list[*]} " != *" ${app} "* ]]; then
|
||||||
then
|
ynh_print_err --message="$app is not in the apps list"
|
||||||
ynh_print_err --message="$app is not in the apps list"
|
exit 1
|
||||||
exit 1
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Make sure the app has its own user
|
# Make sure the app has its own user
|
||||||
if ! id -u "$app" &>/dev/null; then
|
if ! id -u "$app" &> /dev/null; then
|
||||||
ynh_print_err --message="There is no \"$app\" system user"
|
ynh_print_err --message="There is no \"$app\" system user"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure the app has an install_dir setting
|
# Make sure the app has an install_dir setting
|
||||||
local install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
local install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
if [ -z "$install_dir" ]
|
if [ -z "$install_dir" ]; then
|
||||||
then
|
ynh_print_err --message="$app has no install_dir setting (does it use packaging format >=2?)"
|
||||||
ynh_print_err --message="$app has no install_dir setting (does it use packaging format >=2?)"
|
exit 1
|
||||||
exit 1
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Load the app's service name, or default to $app
|
# Load the app's service name, or default to $app
|
||||||
local service=$(ynh_app_setting_get --app=$app --key=service)
|
local service=$(ynh_app_setting_get --app=$app --key=service)
|
||||||
[ -z "$service" ] && service=$app;
|
[ -z "$service" ] && service=$app
|
||||||
|
|
||||||
# Export HOME variable
|
# Export HOME variable
|
||||||
export HOME=$install_dir;
|
export HOME=$install_dir
|
||||||
|
|
||||||
# Load the Environment variables from the app's service
|
# Load the Environment variables from the app's service
|
||||||
local env_var=$(systemctl show $service.service -p "Environment" --value)
|
local env_var=$(systemctl show $service.service -p "Environment" --value)
|
||||||
[ -n "$env_var" ] && export $env_var;
|
[ -n "$env_var" ] && export $env_var
|
||||||
|
|
||||||
# Force `php` to its intended version
|
# Force `php` to its intended version
|
||||||
# We use `eval`+`export` since `alias` is not propagated to subshells, even with `export`
|
# We use `eval`+`export` since `alias` is not propagated to subshells, even with `export`
|
||||||
local phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
local phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
local phpflags=$(ynh_app_setting_get --app=$app --key=phpflags)
|
local phpflags=$(ynh_app_setting_get --app=$app --key=phpflags)
|
||||||
if [ -n "$phpversion" ]
|
if [ -n "$phpversion" ]; then
|
||||||
then
|
eval "php() { php${phpversion} ${phpflags} \"\$@\"; }"
|
||||||
eval "php() { php${phpversion} ${phpflags} \"\$@\"; }"
|
export -f php
|
||||||
export -f php
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Source the EnvironmentFiles from the app's service
|
# Source the EnvironmentFiles from the app's service
|
||||||
local env_files=($(systemctl show $service.service -p "EnvironmentFiles" --value))
|
local env_files=($(systemctl show $service.service -p "EnvironmentFiles" --value))
|
||||||
if [ ${#env_files[*]} -gt 0 ]
|
if [ ${#env_files[*]} -gt 0 ]; then
|
||||||
then
|
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
||||||
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
set -a
|
||||||
set -a
|
for file in ${env_files[*]}; do
|
||||||
for file in ${env_files[*]}
|
[[ $file = /* ]] && source $file
|
||||||
do
|
done
|
||||||
[[ $file = /* ]] && source $file
|
set +a
|
||||||
done
|
fi
|
||||||
set +a
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Activate the Python environment, if it exists
|
# Activate the Python environment, if it exists
|
||||||
if [ -f $install_dir/venv/bin/activate ]
|
if [ -f $install_dir/venv/bin/activate ]; then
|
||||||
then
|
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
||||||
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
set -a
|
||||||
set -a
|
source $install_dir/venv/bin/activate
|
||||||
source $install_dir/venv/bin/activate
|
set +a
|
||||||
set +a
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# cd into the WorkingDirectory set in the service, or default to the install_dir
|
# cd into the WorkingDirectory set in the service, or default to the install_dir
|
||||||
local env_dir=$(systemctl show $service.service -p "WorkingDirectory" --value)
|
local env_dir=$(systemctl show $service.service -p "WorkingDirectory" --value)
|
||||||
[ -z $env_dir ] && env_dir=$install_dir;
|
[ -z $env_dir ] && env_dir=$install_dir
|
||||||
cd $env_dir
|
cd $env_dir
|
||||||
|
|
||||||
# Spawn the app shell
|
# Spawn the app shell
|
||||||
su -s /bin/bash $app
|
su -s /bin/bash $app
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ ynh_wait_dpkg_free() {
|
||||||
# With seq 1 17, timeout will be almost 30 minutes
|
# With seq 1 17, timeout will be almost 30 minutes
|
||||||
for try in $(seq 1 17); do
|
for try in $(seq 1 17); do
|
||||||
# Check if /var/lib/dpkg/lock is used by another process
|
# Check if /var/lib/dpkg/lock is used by another process
|
||||||
if lsof /var/lib/dpkg/lock >/dev/null; then
|
if lsof /var/lib/dpkg/lock > /dev/null; then
|
||||||
echo "apt is already in use..."
|
echo "apt is already in use..."
|
||||||
# Sleep an exponential time at each round
|
# Sleep an exponential time at each round
|
||||||
sleep $((try * try))
|
sleep $((try * try))
|
||||||
|
@ -32,7 +32,7 @@ ynh_wait_dpkg_free() {
|
||||||
set -o xtrace # set -x
|
set -o xtrace # set -x
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done 9<<<"$(ls -1 $dpkg_dir)"
|
done 9<<< "$(ls -1 $dpkg_dir)"
|
||||||
set -o xtrace # set -x
|
set -o xtrace # set -x
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
@ -58,8 +58,8 @@ ynh_package_is_installed() {
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
dpkg-query --show --showformat='${Status}' "$package" 2>/dev/null \
|
dpkg-query --show --showformat='${Status}' "$package" 2> /dev/null \
|
||||||
| grep --count "ok installed" &>/dev/null
|
| grep --count "ok installed" &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Get the version of an installed package
|
# Get the version of an installed package
|
||||||
|
@ -82,7 +82,7 @@ ynh_package_version() {
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
if ynh_package_is_installed "$package"; then
|
if ynh_package_is_installed "$package"; then
|
||||||
dpkg-query --show --showformat='${Version}' "$package" 2>/dev/null
|
dpkg-query --show --showformat='${Version}' "$package" 2> /dev/null
|
||||||
else
|
else
|
||||||
echo ''
|
echo ''
|
||||||
fi
|
fi
|
||||||
|
@ -266,8 +266,7 @@ ynh_install_app_dependencies() {
|
||||||
# The (?<=php) syntax corresponds to lookbehind ;)
|
# The (?<=php) syntax corresponds to lookbehind ;)
|
||||||
local specific_php_version=$(echo $dependencies | grep -oP '(?<=php)[0-9.]+(?=-|\>|)' | sort -u)
|
local specific_php_version=$(echo $dependencies | grep -oP '(?<=php)[0-9.]+(?=-|\>|)' | sort -u)
|
||||||
|
|
||||||
if [[ -n "$specific_php_version" ]]
|
if [[ -n "$specific_php_version" ]]; then
|
||||||
then
|
|
||||||
# Cover a small edge case where a packager could have specified "php7.4-pwet php5-gni" which is confusing
|
# Cover a small edge case where a packager could have specified "php7.4-pwet php5-gni" which is confusing
|
||||||
[[ $(echo $specific_php_version | wc -l) -eq 1 ]] \
|
[[ $(echo $specific_php_version | wc -l) -eq 1 ]] \
|
||||||
|| ynh_die --message="Inconsistent php versions in dependencies ... found : $specific_php_version"
|
|| ynh_die --message="Inconsistent php versions in dependencies ... found : $specific_php_version"
|
||||||
|
@ -281,8 +280,7 @@ ynh_install_app_dependencies() {
|
||||||
local old_php_fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
|
local old_php_fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
|
||||||
local old_php_finalphpconf="$old_php_fpm_config_dir/pool.d/$app.conf"
|
local old_php_finalphpconf="$old_php_fpm_config_dir/pool.d/$app.conf"
|
||||||
|
|
||||||
if [[ -f "$old_php_finalphpconf" ]]
|
if [[ -f "$old_php_finalphpconf" ]]; then
|
||||||
then
|
|
||||||
ynh_backup_if_checksum_is_different --file="$old_php_finalphpconf"
|
ynh_backup_if_checksum_is_different --file="$old_php_finalphpconf"
|
||||||
ynh_remove_fpm_config
|
ynh_remove_fpm_config
|
||||||
fi
|
fi
|
||||||
|
@ -291,8 +289,7 @@ ynh_install_app_dependencies() {
|
||||||
ynh_app_setting_set --app=$app --key=phpversion --value=$specific_php_version
|
ynh_app_setting_set --app=$app --key=phpversion --value=$specific_php_version
|
||||||
|
|
||||||
# Set the default php version back as the default version for php-cli.
|
# Set the default php version back as the default version for php-cli.
|
||||||
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION; then
|
||||||
then
|
|
||||||
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
||||||
fi
|
fi
|
||||||
elif grep --quiet 'php' <<< "$dependencies"; then
|
elif grep --quiet 'php' <<< "$dependencies"; then
|
||||||
|
@ -306,20 +303,18 @@ ynh_install_app_dependencies() {
|
||||||
# upgrade script where ynh_install_app_dependencies is called with this
|
# upgrade script where ynh_install_app_dependencies is called with this
|
||||||
# expected effect) Otherwise, any subsequent call will add dependencies
|
# expected effect) Otherwise, any subsequent call will add dependencies
|
||||||
# to those already present in the equivs control file.
|
# to those already present in the equivs control file.
|
||||||
if [[ $YNH_INSTALL_APP_DEPENDENCIES_REPLACE == "true" ]]
|
if [[ $YNH_INSTALL_APP_DEPENDENCIES_REPLACE == "true" ]]; then
|
||||||
then
|
|
||||||
YNH_INSTALL_APP_DEPENDENCIES_REPLACE="false"
|
YNH_INSTALL_APP_DEPENDENCIES_REPLACE="false"
|
||||||
else
|
else
|
||||||
local current_dependencies=""
|
local current_dependencies=""
|
||||||
if ynh_package_is_installed --package="${dep_app}-ynh-deps"
|
if ynh_package_is_installed --package="${dep_app}-ynh-deps"; then
|
||||||
then
|
|
||||||
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
|
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) "
|
||||||
current_dependencies=${current_dependencies// | /|}
|
current_dependencies=${current_dependencies// | /|}
|
||||||
fi
|
fi
|
||||||
dependencies="$current_dependencies, $dependencies"
|
dependencies="$current_dependencies, $dependencies"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cat >/tmp/${dep_app}-ynh-deps.control <<EOF # Make a control file for equivs-build
|
cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build
|
||||||
Section: misc
|
Section: misc
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Package: ${dep_app}-ynh-deps
|
Package: ${dep_app}-ynh-deps
|
||||||
|
@ -337,8 +332,7 @@ EOF
|
||||||
|
|
||||||
# Trigger postgresql regenconf if we may have just installed postgresql
|
# Trigger postgresql regenconf if we may have just installed postgresql
|
||||||
local psql_installed2="$(ynh_package_is_installed "postgresql-$PSQL_VERSION" && echo yes || echo no)"
|
local psql_installed2="$(ynh_package_is_installed "postgresql-$PSQL_VERSION" && echo yes || echo no)"
|
||||||
if [[ "$psql_installed" != "$psql_installed2" ]]
|
if [[ "$psql_installed" != "$psql_installed2" ]]; then
|
||||||
then
|
|
||||||
yunohost tools regen-conf postgresql
|
yunohost tools regen-conf postgresql
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -372,7 +366,7 @@ ynh_add_app_dependencies() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 2.6.4 or higher.
|
# Requires YunoHost version 2.6.4 or higher.
|
||||||
ynh_remove_app_dependencies() {
|
ynh_remove_app_dependencies() {
|
||||||
local dep_app=${app//_/-} # Replace all '_' by '-'
|
local dep_app=${app//_/-} # Replace all '_' by '-'
|
||||||
|
|
||||||
local current_dependencies=""
|
local current_dependencies=""
|
||||||
if ynh_package_is_installed --package="${dep_app}-ynh-deps"; then
|
if ynh_package_is_installed --package="${dep_app}-ynh-deps"; then
|
||||||
|
@ -382,16 +376,14 @@ ynh_remove_app_dependencies() {
|
||||||
|
|
||||||
# Edge case where the app dep may be on hold,
|
# Edge case where the app dep may be on hold,
|
||||||
# cf https://forum.yunohost.org/t/migration-error-cause-of-ffsync/20675/4
|
# cf https://forum.yunohost.org/t/migration-error-cause-of-ffsync/20675/4
|
||||||
if apt-mark showhold | grep -q -w ${dep_app}-ynh-deps
|
if apt-mark showhold | grep -q -w ${dep_app}-ynh-deps; then
|
||||||
then
|
|
||||||
apt-mark unhold ${dep_app}-ynh-deps
|
apt-mark unhold ${dep_app}-ynh-deps
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the fake package and its dependencies if they not still used.
|
# Remove the fake package and its dependencies if they not still used.
|
||||||
# (except if dpkg doesn't know anything about the package,
|
# (except if dpkg doesn't know anything about the package,
|
||||||
# which should be symptomatic of a failed install, and we don't want bash to report an error)
|
# which should be symptomatic of a failed install, and we don't want bash to report an error)
|
||||||
if dpkg-query --show ${dep_app}-ynh-deps &>/dev/null
|
if dpkg-query --show ${dep_app}-ynh-deps &> /dev/null; then
|
||||||
then
|
|
||||||
ynh_package_autopurge ${dep_app}-ynh-deps
|
ynh_package_autopurge ${dep_app}-ynh-deps
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -487,11 +479,13 @@ ynh_install_extra_repo() {
|
||||||
if [[ "${repo_parts[0]}" == "deb" ]]; then
|
if [[ "${repo_parts[0]}" == "deb" ]]; then
|
||||||
index=1
|
index=1
|
||||||
fi
|
fi
|
||||||
uri="${repo_parts[$index]}" ; index=$((index+1))
|
uri="${repo_parts[$index]}"
|
||||||
suite="${repo_parts[$index]}" ; index=$((index+1))
|
index=$((index + 1))
|
||||||
|
suite="${repo_parts[$index]}"
|
||||||
|
index=$((index + 1))
|
||||||
|
|
||||||
# Get the components
|
# Get the components
|
||||||
if (( "${#repo_parts[@]}" > 0 )); then
|
if (("${#repo_parts[@]}" > 0)); then
|
||||||
component="${repo_parts[*]:$index}"
|
component="${repo_parts[*]:$index}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -512,7 +506,7 @@ ynh_install_extra_repo() {
|
||||||
if [ -n "$key" ] && [[ "$key" != "trusted=yes" ]]; then
|
if [ -n "$key" ] && [[ "$key" != "trusted=yes" ]]; then
|
||||||
mkdir --parents "/etc/apt/trusted.gpg.d"
|
mkdir --parents "/etc/apt/trusted.gpg.d"
|
||||||
# Timeout option is here to enforce the timeout on dns query and tcp connect (c.f. man wget)
|
# Timeout option is here to enforce the timeout on dns query and tcp connect (c.f. man wget)
|
||||||
wget --timeout 900 --quiet "$key" --output-document=- | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg >/dev/null
|
wget --timeout 900 --quiet "$key" --output-document=- | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Update the list of package with the new repo
|
# Update the list of package with the new repo
|
||||||
|
|
|
@ -162,7 +162,7 @@ ynh_backup() {
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
local src=$(echo "${src_path}" | sed --regexp-extended 's/"/\"\"/g')
|
local src=$(echo "${src_path}" | sed --regexp-extended 's/"/\"\"/g')
|
||||||
local dest=$(echo "${dest_path}" | sed --regexp-extended 's/"/\"\"/g')
|
local dest=$(echo "${dest_path}" | sed --regexp-extended 's/"/\"\"/g')
|
||||||
echo "\"${src}\",\"${dest}\"" >>"${YNH_BACKUP_CSV}"
|
echo "\"${src}\",\"${dest}\"" >> "${YNH_BACKUP_CSV}"
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
|
@ -289,8 +289,7 @@ ynh_restore_file() {
|
||||||
# Boring hack for nginx conf file mapped to php7.3
|
# Boring hack for nginx conf file mapped to php7.3
|
||||||
# Note that there's no need to patch the fpm config because most php apps
|
# Note that there's no need to patch the fpm config because most php apps
|
||||||
# will call "ynh_add_fpm_config" during restore, effectively recreating the file from scratch
|
# will call "ynh_add_fpm_config" during restore, effectively recreating the file from scratch
|
||||||
if [[ "${dest_path}" == "/etc/nginx/conf.d/"* ]] && grep 'php7.3.*sock' "${dest_path}"
|
if [[ "${dest_path}" == "/etc/nginx/conf.d/"* ]] && grep 'php7.3.*sock' "${dest_path}"; then
|
||||||
then
|
|
||||||
sed -i 's/php7.3/php7.4/g' "${dest_path}"
|
sed -i 's/php7.3/php7.4/g' "${dest_path}"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -376,8 +375,7 @@ ynh_backup_if_checksum_is_different() {
|
||||||
echo "$backup_file_checksum" # Return the name of the backup file
|
echo "$backup_file_checksum" # Return the name of the backup file
|
||||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
local file_path_base64=$(echo "$file" | base64 -w0)
|
local file_path_base64=$(echo "$file" | base64 -w0)
|
||||||
if test -e /var/cache/yunohost/appconfbackup/original_${file_path_base64}
|
if test -e /var/cache/yunohost/appconfbackup/original_${file_path_base64}; then
|
||||||
then
|
|
||||||
ynh_print_warn "Diff with the original file:"
|
ynh_print_warn "Diff with the original file:"
|
||||||
diff --report-identical-files --unified --color=always /var/cache/yunohost/appconfbackup/original_${file_path_base64} $file >&2 || true
|
diff --report-identical-files --unified --color=always /var/cache/yunohost/appconfbackup/original_${file_path_base64} $file >&2 || true
|
||||||
fi
|
fi
|
||||||
|
@ -412,7 +410,7 @@ ynh_delete_file_checksum() {
|
||||||
#
|
#
|
||||||
ynh_backup_archive_exists() {
|
ynh_backup_archive_exists() {
|
||||||
yunohost backup list --output-as json --quiet \
|
yunohost backup list --output-as json --quiet \
|
||||||
| jq -e --arg archive "$1" '.archives | index($archive)' >/dev/null
|
| jq -e --arg archive "$1" '.archives | index($archive)' > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Make a backup in case of failed upgrade
|
# Make a backup in case of failed upgrade
|
||||||
|
@ -455,7 +453,7 @@ ynh_backup_before_upgrade() {
|
||||||
# If the backup succeeded, remove the previous backup
|
# If the backup succeeded, remove the previous backup
|
||||||
if ynh_backup_archive_exists "$app_bck-pre-upgrade$old_backup_number"; then
|
if ynh_backup_archive_exists "$app_bck-pre-upgrade$old_backup_number"; then
|
||||||
# Remove the previous backup only if it exists
|
# Remove the previous backup only if it exists
|
||||||
yunohost backup delete $app_bck-pre-upgrade$old_backup_number >/dev/null
|
yunohost backup delete $app_bck-pre-upgrade$old_backup_number > /dev/null
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
ynh_die --message="Backup failed, the upgrade process was aborted."
|
ynh_die --message="Backup failed, the upgrade process was aborted."
|
||||||
|
@ -494,8 +492,7 @@ ynh_restore_upgradebackup() {
|
||||||
yunohost app remove $app
|
yunohost app remove $app
|
||||||
# Restore the backup
|
# Restore the backup
|
||||||
yunohost backup restore $app_bck-pre-upgrade$backup_number --apps $app --force --debug
|
yunohost backup restore $app_bck-pre-upgrade$backup_number --apps $app --force --debug
|
||||||
if [[ -d /etc/yunohost/apps/$app ]]
|
if [[ -d /etc/yunohost/apps/$app ]]; then
|
||||||
then
|
|
||||||
ynh_die --message="The app was restored to the way it was before the failed upgrade."
|
ynh_die --message="The app was restored to the way it was before the failed upgrade."
|
||||||
else
|
else
|
||||||
ynh_die --message="Uhoh ... Yunohost failed to restore the app to the way it was before the failed upgrade :|"
|
ynh_die --message="Uhoh ... Yunohost failed to restore the app to the way it was before the failed upgrade :|"
|
||||||
|
|
|
@ -6,11 +6,11 @@ _ynh_app_config_get_one() {
|
||||||
local bind="$3"
|
local bind="$3"
|
||||||
local getter="get__${short_setting}"
|
local getter="get__${short_setting}"
|
||||||
# Get value from getter if exists
|
# Get value from getter if exists
|
||||||
if type -t $getter 2>/dev/null | grep -q '^function$' 2>/dev/null; then
|
if type -t $getter 2> /dev/null | grep -q '^function$' 2> /dev/null; then
|
||||||
old[$short_setting]="$($getter)"
|
old[$short_setting]="$($getter)"
|
||||||
formats[${short_setting}]="yaml"
|
formats[${short_setting}]="yaml"
|
||||||
|
|
||||||
elif [[ "$bind" == *"("* ]] && type -t "get__${bind%%(*}" 2>/dev/null | grep -q '^function$' 2>/dev/null; then
|
elif [[ "$bind" == *"("* ]] && type -t "get__${bind%%(*}" 2> /dev/null | grep -q '^function$' 2> /dev/null; then
|
||||||
old[$short_setting]="$("get__${bind%%(*}" $short_setting $type $bind)"
|
old[$short_setting]="$("get__${bind%%(*}" $short_setting $type $bind)"
|
||||||
formats[${short_setting}]="yaml"
|
formats[${short_setting}]="yaml"
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ _ynh_app_config_get_one() {
|
||||||
if [[ "$bind" == "settings" ]]; then
|
if [[ "$bind" == "settings" ]]; then
|
||||||
ynh_die --message="File '${short_setting}' can't be stored in settings"
|
ynh_die --message="File '${short_setting}' can't be stored in settings"
|
||||||
fi
|
fi
|
||||||
old[$short_setting]="$(ls "$(echo $bind | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)" 2>/dev/null || echo YNH_NULL)"
|
old[$short_setting]="$(ls "$bind" 2> /dev/null || echo YNH_NULL)"
|
||||||
file_hash[$short_setting]="true"
|
file_hash[$short_setting]="true"
|
||||||
|
|
||||||
# Get multiline text from settings or from a full file
|
# Get multiline text from settings or from a full file
|
||||||
|
@ -32,7 +32,7 @@ _ynh_app_config_get_one() {
|
||||||
elif [[ "$bind" == *":"* ]]; then
|
elif [[ "$bind" == *":"* ]]; then
|
||||||
ynh_die --message="For technical reasons, multiline text '${short_setting}' can't be stored automatically in a variable file, you have to create custom getter/setter"
|
ynh_die --message="For technical reasons, multiline text '${short_setting}' can't be stored automatically in a variable file, you have to create custom getter/setter"
|
||||||
else
|
else
|
||||||
old[$short_setting]="$(cat $(echo $bind | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/) 2>/dev/null || echo YNH_NULL)"
|
old[$short_setting]="$(cat "$bind" 2> /dev/null || echo YNH_NULL)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get value from a kind of key/value file
|
# Get value from a kind of key/value file
|
||||||
|
@ -47,7 +47,7 @@ _ynh_app_config_get_one() {
|
||||||
bind_after="$(echo "${bind_key_}" | cut -d'>' -f1)"
|
bind_after="$(echo "${bind_key_}" | cut -d'>' -f1)"
|
||||||
bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)"
|
bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)"
|
||||||
fi
|
fi
|
||||||
local bind_file="$(echo "$bind" | cut -d: -f2 | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)"
|
local bind_file="$(echo "$bind" | cut -d: -f2)"
|
||||||
old[$short_setting]="$(ynh_read_var_in_file --file="${bind_file}" --key="${bind_key_}" --after="${bind_after}")"
|
old[$short_setting]="$(ynh_read_var_in_file --file="${bind_file}" --key="${bind_key_}" --after="${bind_after}")"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -59,10 +59,10 @@ _ynh_app_config_apply_one() {
|
||||||
local type="${types[$short_setting]}"
|
local type="${types[$short_setting]}"
|
||||||
if [ "${changed[$short_setting]}" == "true" ]; then
|
if [ "${changed[$short_setting]}" == "true" ]; then
|
||||||
# Apply setter if exists
|
# Apply setter if exists
|
||||||
if type -t $setter 2>/dev/null | grep -q '^function$' 2>/dev/null; then
|
if type -t $setter 2> /dev/null | grep -q '^function$' 2> /dev/null; then
|
||||||
$setter
|
$setter
|
||||||
|
|
||||||
elif [[ "$bind" == *"("* ]] && type -t "set__${bind%%(*}" 2>/dev/null | grep -q '^function$' 2>/dev/null; then
|
elif [[ "$bind" == *"("* ]] && type -t "set__${bind%%(*}" 2> /dev/null | grep -q '^function$' 2> /dev/null; then
|
||||||
"set__${bind%%(*}" $short_setting $type $bind
|
"set__${bind%%(*}" $short_setting $type $bind
|
||||||
|
|
||||||
elif [[ "$bind" == "null" ]]; then
|
elif [[ "$bind" == "null" ]]; then
|
||||||
|
@ -73,7 +73,7 @@ _ynh_app_config_apply_one() {
|
||||||
if [[ "$bind" == "settings" ]]; then
|
if [[ "$bind" == "settings" ]]; then
|
||||||
ynh_die --message="File '${short_setting}' can't be stored in settings"
|
ynh_die --message="File '${short_setting}' can't be stored in settings"
|
||||||
fi
|
fi
|
||||||
local bind_file="$(echo "$bind" | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)"
|
local bind_file="$bind"
|
||||||
if [[ "${!short_setting}" == "" ]]; then
|
if [[ "${!short_setting}" == "" ]]; then
|
||||||
ynh_backup_if_checksum_is_different --file="$bind_file"
|
ynh_backup_if_checksum_is_different --file="$bind_file"
|
||||||
ynh_secure_remove --file="$bind_file"
|
ynh_secure_remove --file="$bind_file"
|
||||||
|
@ -98,9 +98,9 @@ _ynh_app_config_apply_one() {
|
||||||
if [[ "$bind" == *":"* ]]; then
|
if [[ "$bind" == *":"* ]]; then
|
||||||
ynh_die --message="For technical reasons, multiline text '${short_setting}' can't be stored automatically in a variable file, you have to create custom getter/setter"
|
ynh_die --message="For technical reasons, multiline text '${short_setting}' can't be stored automatically in a variable file, you have to create custom getter/setter"
|
||||||
fi
|
fi
|
||||||
local bind_file="$(echo "$bind" | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)"
|
local bind_file="$bind"
|
||||||
ynh_backup_if_checksum_is_different --file="$bind_file"
|
ynh_backup_if_checksum_is_different --file="$bind_file"
|
||||||
echo "${!short_setting}" >"$bind_file"
|
echo "${!short_setting}" > "$bind_file"
|
||||||
ynh_store_file_checksum --file="$bind_file" --update_only
|
ynh_store_file_checksum --file="$bind_file" --update_only
|
||||||
ynh_print_info --message="File '$bind_file' overwritten with the content provided in question '${short_setting}'"
|
ynh_print_info --message="File '$bind_file' overwritten with the content provided in question '${short_setting}'"
|
||||||
|
|
||||||
|
@ -113,7 +113,7 @@ _ynh_app_config_apply_one() {
|
||||||
bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)"
|
bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)"
|
||||||
fi
|
fi
|
||||||
bind_key_=${bind_key_:-$short_setting}
|
bind_key_=${bind_key_:-$short_setting}
|
||||||
local bind_file="$(echo "$bind" | cut -d: -f2 | sed s@__INSTALL_DIR__@$install_dir@ | sed s@__FINALPATH__@$final_path@ | sed s/__APP__/$app/)"
|
local bind_file="$(echo "$bind" | cut -d: -f2)"
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different --file="$bind_file"
|
ynh_backup_if_checksum_is_different --file="$bind_file"
|
||||||
ynh_write_var_in_file --file="${bind_file}" --key="${bind_key_}" --value="${!short_setting}" --after="${bind_after}"
|
ynh_write_var_in_file --file="${bind_file}" --key="${bind_key_}" --value="${!short_setting}" --after="${bind_after}"
|
||||||
|
@ -126,69 +126,17 @@ _ynh_app_config_apply_one() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_ynh_app_config_get() {
|
_ynh_app_config_get() {
|
||||||
# From settings
|
for line in $YNH_APP_CONFIG_PANEL_OPTIONS_TYPES_AND_BINDS; do
|
||||||
local lines
|
|
||||||
lines=$(
|
|
||||||
python3 <<EOL
|
|
||||||
import toml
|
|
||||||
from collections import OrderedDict
|
|
||||||
with open("../config_panel.toml", "r") as f:
|
|
||||||
file_content = f.read()
|
|
||||||
loaded_toml = toml.loads(file_content, _dict=OrderedDict)
|
|
||||||
|
|
||||||
for panel_name, panel in loaded_toml.items():
|
|
||||||
if not isinstance(panel, dict): continue
|
|
||||||
bind_panel = panel.get('bind')
|
|
||||||
for section_name, section in panel.items():
|
|
||||||
if not isinstance(section, dict): continue
|
|
||||||
bind_section = section.get('bind')
|
|
||||||
if not bind_section:
|
|
||||||
bind_section = bind_panel
|
|
||||||
elif bind_section[-1] == ":" and bind_panel and ":" in bind_panel:
|
|
||||||
regex, bind_panel_file = bind_panel.split(":")
|
|
||||||
if ">" in bind_section:
|
|
||||||
bind_section = bind_section + bind_panel_file
|
|
||||||
else:
|
|
||||||
bind_section = regex + bind_section + bind_panel_file
|
|
||||||
|
|
||||||
for name, param in section.items():
|
|
||||||
if not isinstance(param, dict):
|
|
||||||
continue
|
|
||||||
|
|
||||||
bind = param.get('bind')
|
|
||||||
|
|
||||||
if not bind:
|
|
||||||
if bind_section:
|
|
||||||
bind = bind_section
|
|
||||||
else:
|
|
||||||
bind = 'settings'
|
|
||||||
elif bind[-1] == ":" and bind_section and ":" in bind_section:
|
|
||||||
regex, bind_file = bind_section.split(":")
|
|
||||||
if ">" in bind:
|
|
||||||
bind = bind + bind_file
|
|
||||||
else:
|
|
||||||
bind = regex + bind + bind_file
|
|
||||||
if bind == "settings" and param.get('type', 'string') == 'file':
|
|
||||||
bind = 'null'
|
|
||||||
|
|
||||||
print('|'.join([
|
|
||||||
name,
|
|
||||||
param.get('type', 'string'),
|
|
||||||
bind
|
|
||||||
]))
|
|
||||||
EOL
|
|
||||||
)
|
|
||||||
for line in $lines; do
|
|
||||||
# Split line into short_setting, type and bind
|
# Split line into short_setting, type and bind
|
||||||
IFS='|' read short_setting type bind <<<"$line"
|
IFS='|' read short_setting type bind <<< "$line"
|
||||||
binds[${short_setting}]="$bind"
|
binds[${short_setting}]="$bind"
|
||||||
types[${short_setting}]="$type"
|
types[${short_setting}]="$type"
|
||||||
file_hash[${short_setting}]=""
|
file_hash[${short_setting}]=""
|
||||||
formats[${short_setting}]=""
|
formats[${short_setting}]=""
|
||||||
ynh_app_config_get_one $short_setting $type $bind
|
ynh_app_config_get_one $short_setting $type $bind
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ynh_app_config_apply() {
|
_ynh_app_config_apply() {
|
||||||
|
@ -258,9 +206,9 @@ _ynh_app_config_validate() {
|
||||||
for short_setting in "${!old[@]}"; do
|
for short_setting in "${!old[@]}"; do
|
||||||
[[ "${changed[$short_setting]}" == "false" ]] && continue
|
[[ "${changed[$short_setting]}" == "false" ]] && continue
|
||||||
local result=""
|
local result=""
|
||||||
if type -t validate__$short_setting | grep -q '^function$' 2>/dev/null; then
|
if type -t validate__$short_setting | grep -q '^function$' 2> /dev/null; then
|
||||||
result="$(validate__$short_setting)"
|
result="$(validate__$short_setting)"
|
||||||
elif [[ "$bind" == *"("* ]] && type -t "validate__${bind%%(*}" 2>/dev/null | grep -q '^function$' 2>/dev/null; then
|
elif [[ "$bind" == *"("* ]] && type -t "validate__${bind%%(*}" 2> /dev/null | grep -q '^function$' 2> /dev/null; then
|
||||||
"validate__${bind%%(*}" $short_setting
|
"validate__${bind%%(*}" $short_setting
|
||||||
fi
|
fi
|
||||||
if [ -n "$result" ]; then
|
if [ -n "$result" ]; then
|
||||||
|
@ -315,7 +263,7 @@ ynh_app_config_apply() {
|
||||||
ynh_app_action_run() {
|
ynh_app_action_run() {
|
||||||
local runner="run__$1"
|
local runner="run__$1"
|
||||||
# Get value from getter if exists
|
# Get value from getter if exists
|
||||||
if type -t "$runner" 2>/dev/null | grep -q '^function$' 2>/dev/null; then
|
if type -t "$runner" 2> /dev/null | grep -q '^function$' 2> /dev/null; then
|
||||||
$runner
|
$runner
|
||||||
#ynh_return "result:"
|
#ynh_return "result:"
|
||||||
#ynh_return "$(echo "${result}" | sed 's/^/ /g')"
|
#ynh_return "$(echo "${result}" | sed 's/^/ /g')"
|
||||||
|
@ -333,22 +281,23 @@ ynh_app_config_run() {
|
||||||
declare -Ag formats=()
|
declare -Ag formats=()
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
show)
|
show)
|
||||||
ynh_app_config_get
|
ynh_app_config_get
|
||||||
ynh_app_config_show
|
ynh_app_config_show
|
||||||
;;
|
;;
|
||||||
apply)
|
apply)
|
||||||
max_progression=4
|
max_progression=4
|
||||||
ynh_script_progression --message="Reading config panel description and current configuration..."
|
ynh_script_progression --message="Reading config panel description and current configuration..."
|
||||||
ynh_app_config_get
|
ynh_app_config_get
|
||||||
|
|
||||||
ynh_app_config_validate
|
ynh_app_config_validate
|
||||||
|
|
||||||
ynh_script_progression --message="Applying the new configuration..."
|
ynh_script_progression --message="Applying the new configuration..."
|
||||||
ynh_app_config_apply
|
ynh_app_config_apply
|
||||||
ynh_script_progression --message="Configuration of $app completed" --last
|
ynh_script_progression --message="Configuration of $app completed" --last
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
ynh_app_action_run $1
|
ynh_app_action_run $1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ port = __PORTS__
|
||||||
filter = __APP__
|
filter = __APP__
|
||||||
logpath = __LOGPATH__
|
logpath = __LOGPATH__
|
||||||
maxretry = __MAX_RETRY__
|
maxretry = __MAX_RETRY__
|
||||||
" >"$YNH_APP_BASEDIR/conf/f2b_jail.conf"
|
" > "$YNH_APP_BASEDIR/conf/f2b_jail.conf"
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
[INCLUDES]
|
[INCLUDES]
|
||||||
|
@ -90,7 +90,7 @@ before = common.conf
|
||||||
[Definition]
|
[Definition]
|
||||||
failregex = __FAILREGEX__
|
failregex = __FAILREGEX__
|
||||||
ignoreregex =
|
ignoreregex =
|
||||||
" >"$YNH_APP_BASEDIR/conf/f2b_filter.conf"
|
" > "$YNH_APP_BASEDIR/conf/f2b_filter.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_add_config --template="f2b_jail.conf" --destination="/etc/fail2ban/jail.d/$app.conf"
|
ynh_add_config --template="f2b_jail.conf" --destination="/etc/fail2ban/jail.d/$app.conf"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
# | arg: $@ - Simply "$@" to tranfert all the positionnal arguments to the function
|
# | arg: $@ - Simply "$@" to tranfert all the positionnal arguments to the function
|
||||||
#
|
#
|
||||||
# This helper need an array, named "args_array" with all the arguments used by the helper
|
# This helper need an array, named "args_array" with all the arguments used by the helper
|
||||||
# that want to use ynh_handle_getopts_args
|
# that want to use ynh_handle_getopts_args
|
||||||
# Be carreful, this array has to be an associative array, as the following example:
|
# Be carreful, this array has to be an associative array, as the following example:
|
||||||
# local -A args_array=( [a]=arg1 [b]=arg2= [c]=arg3 )
|
# local -A args_array=( [a]=arg1 [b]=arg2= [c]=arg3 )
|
||||||
# Let's explain this array:
|
# Let's explain this array:
|
||||||
|
@ -180,7 +180,7 @@ ynh_handle_getopts_args() {
|
||||||
# If not, enter in legacy mode and manage the arguments as positionnal ones..
|
# If not, enter in legacy mode and manage the arguments as positionnal ones..
|
||||||
# Dot not echo, to prevent to go through a helper output. But print only in the log.
|
# Dot not echo, to prevent to go through a helper output. But print only in the log.
|
||||||
set -x
|
set -x
|
||||||
echo "! Helper used in legacy mode !" >/dev/null
|
echo "! Helper used in legacy mode !" > /dev/null
|
||||||
set +x
|
set +x
|
||||||
local i
|
local i
|
||||||
for i in $(seq 0 $((${#arguments[@]} - 1))); do
|
for i in $(seq 0 $((${#arguments[@]} - 1))); do
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
ynh_go_try_bash_extension() {
|
ynh_go_try_bash_extension() {
|
||||||
if [ -x src/configure ]; then
|
if [ -x src/configure ]; then
|
||||||
src/configure && make -C src || {
|
src/configure && make -C src || {
|
||||||
ynh_print_info --message="Optional bash extension failed to build, but things will still work normally."
|
ynh_print_info --message="Optional bash extension failed to build, but things will still work normally."
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
goenv_install_dir="/opt/goenv"
|
goenv_install_dir="/opt/goenv"
|
||||||
|
@ -51,7 +51,7 @@ export GOENV_ROOT="$goenv_install_dir"
|
||||||
# usage: ynh_use_go
|
# usage: ynh_use_go
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.2 or higher.
|
# Requires YunoHost version 3.2.2 or higher.
|
||||||
ynh_use_go () {
|
ynh_use_go() {
|
||||||
go_version=$(ynh_app_setting_get --app=$app --key=go_version)
|
go_version=$(ynh_app_setting_get --app=$app --key=go_version)
|
||||||
|
|
||||||
# Get the absolute path of this version of Go
|
# Get the absolute path of this version of Go
|
||||||
|
@ -73,7 +73,7 @@ ynh_use_go () {
|
||||||
|
|
||||||
# Sets the local application-specific Go version
|
# Sets the local application-specific Go version
|
||||||
pushd $install_dir
|
pushd $install_dir
|
||||||
$goenv_install_dir/bin/goenv local $go_version
|
$goenv_install_dir/bin/goenv local $go_version
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,10 +93,10 @@ ynh_use_go () {
|
||||||
# | arg: -v, --go_version= - Version of go to install.
|
# | arg: -v, --go_version= - Version of go to install.
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.2 or higher.
|
# Requires YunoHost version 3.2.2 or higher.
|
||||||
ynh_install_go () {
|
ynh_install_go() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=v
|
local legacy_args=v
|
||||||
local -A args_array=( [v]=go_version= )
|
local -A args_array=([v]=go_version=)
|
||||||
local go_version
|
local go_version
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
@ -113,34 +113,34 @@ ynh_install_go () {
|
||||||
# Install or update goenv
|
# Install or update goenv
|
||||||
mkdir -p $goenv_install_dir
|
mkdir -p $goenv_install_dir
|
||||||
pushd "$goenv_install_dir"
|
pushd "$goenv_install_dir"
|
||||||
if ! [ -x "$goenv_install_dir/bin/goenv" ]; then
|
if ! [ -x "$goenv_install_dir/bin/goenv" ]; then
|
||||||
ynh_print_info --message="Downloading goenv..."
|
ynh_print_info --message="Downloading goenv..."
|
||||||
git init -q
|
git init -q
|
||||||
git remote add origin https://github.com/syndbg/goenv.git
|
git remote add origin https://github.com/syndbg/goenv.git
|
||||||
else
|
else
|
||||||
ynh_print_info --message="Updating goenv..."
|
ynh_print_info --message="Updating goenv..."
|
||||||
fi
|
fi
|
||||||
git fetch -q --tags --prune origin
|
git fetch -q --tags --prune origin
|
||||||
local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
||||||
git checkout -q "$git_latest_tag"
|
git checkout -q "$git_latest_tag"
|
||||||
ynh_go_try_bash_extension
|
ynh_go_try_bash_extension
|
||||||
goenv=$goenv_install_dir/bin/goenv
|
goenv=$goenv_install_dir/bin/goenv
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Install or update xxenv-latest
|
# Install or update xxenv-latest
|
||||||
goenv_latest_dir="$goenv_install_dir/plugins/xxenv-latest"
|
goenv_latest_dir="$goenv_install_dir/plugins/xxenv-latest"
|
||||||
mkdir -p "$goenv_latest_dir"
|
mkdir -p "$goenv_latest_dir"
|
||||||
pushd "$goenv_latest_dir"
|
pushd "$goenv_latest_dir"
|
||||||
if ! [ -x "$goenv_latest_dir/bin/goenv-latest" ]; then
|
if ! [ -x "$goenv_latest_dir/bin/goenv-latest" ]; then
|
||||||
ynh_print_info --message="Downloading xxenv-latest..."
|
ynh_print_info --message="Downloading xxenv-latest..."
|
||||||
git init -q
|
git init -q
|
||||||
git remote add origin https://github.com/momo-lab/xxenv-latest.git
|
git remote add origin https://github.com/momo-lab/xxenv-latest.git
|
||||||
else
|
else
|
||||||
ynh_print_info --message="Updating xxenv-latest..."
|
ynh_print_info --message="Updating xxenv-latest..."
|
||||||
fi
|
fi
|
||||||
git fetch -q --tags --prune origin
|
git fetch -q --tags --prune origin
|
||||||
local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
||||||
git checkout -q "$git_latest_tag"
|
git checkout -q "$git_latest_tag"
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Enable caching
|
# Enable caching
|
||||||
|
@ -167,7 +167,7 @@ ynh_install_go () {
|
||||||
ynh_cleanup_go
|
ynh_cleanup_go
|
||||||
|
|
||||||
# Set environment for Go users
|
# Set environment for Go users
|
||||||
echo "#goenv
|
echo "#goenv
|
||||||
export GOENV_ROOT=$goenv_install_dir
|
export GOENV_ROOT=$goenv_install_dir
|
||||||
export PATH=\"$goenv_install_dir/bin:$PATH\"
|
export PATH=\"$goenv_install_dir/bin:$PATH\"
|
||||||
eval \"\$(goenv init -)\"
|
eval \"\$(goenv init -)\"
|
||||||
|
@ -182,7 +182,7 @@ eval \"\$(goenv init -)\"
|
||||||
# This helper will also cleanup Go versions
|
# This helper will also cleanup Go versions
|
||||||
#
|
#
|
||||||
# usage: ynh_remove_go
|
# usage: ynh_remove_go
|
||||||
ynh_remove_go () {
|
ynh_remove_go() {
|
||||||
local go_version=$(ynh_app_setting_get --app="$app" --key="go_version")
|
local go_version=$(ynh_app_setting_get --app="$app" --key="go_version")
|
||||||
|
|
||||||
# Load goenv path in PATH
|
# Load goenv path in PATH
|
||||||
|
@ -205,34 +205,29 @@ ynh_remove_go () {
|
||||||
# If no app uses Go, goenv will be also removed.
|
# If no app uses Go, goenv will be also removed.
|
||||||
#
|
#
|
||||||
# usage: ynh_cleanup_go
|
# usage: ynh_cleanup_go
|
||||||
ynh_cleanup_go () {
|
ynh_cleanup_go() {
|
||||||
|
|
||||||
# List required Go versions
|
# List required Go versions
|
||||||
local installed_apps=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
|
local installed_apps=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
|
||||||
local required_go_versions=""
|
local required_go_versions=""
|
||||||
for installed_app in $installed_apps
|
for installed_app in $installed_apps; do
|
||||||
do
|
|
||||||
local installed_app_go_version=$(ynh_app_setting_get --app=$installed_app --key="go_version")
|
local installed_app_go_version=$(ynh_app_setting_get --app=$installed_app --key="go_version")
|
||||||
if [[ $installed_app_go_version ]]
|
if [[ $installed_app_go_version ]]; then
|
||||||
then
|
|
||||||
required_go_versions="${installed_app_go_version}\n${required_go_versions}"
|
required_go_versions="${installed_app_go_version}\n${required_go_versions}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove no more needed Go versions
|
# Remove no more needed Go versions
|
||||||
local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/')
|
local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/')
|
||||||
for installed_go_version in $installed_go_versions
|
for installed_go_version in $installed_go_versions; do
|
||||||
do
|
if ! $(echo ${required_go_versions} | grep "${installed_go_version}" 1> /dev/null 2>&1); then
|
||||||
if ! `echo ${required_go_versions} | grep "${installed_go_version}" 1>/dev/null 2>&1`
|
|
||||||
then
|
|
||||||
ynh_print_info --message="Removing of Go-$installed_go_version"
|
ynh_print_info --message="Removing of Go-$installed_go_version"
|
||||||
$goenv_install_dir/bin/goenv uninstall --force "$installed_go_version"
|
$goenv_install_dir/bin/goenv uninstall --force "$installed_go_version"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# If none Go version is required
|
# If none Go version is required
|
||||||
if [[ ! $required_go_versions ]]
|
if [[ ! $required_go_versions ]]; then
|
||||||
then
|
|
||||||
# Remove goenv environment configuration
|
# Remove goenv environment configuration
|
||||||
ynh_print_info --message="Removing of goenv"
|
ynh_print_info --message="Removing of goenv"
|
||||||
ynh_secure_remove --file="$goenv_install_dir"
|
ynh_secure_remove --file="$goenv_install_dir"
|
||||||
|
|
|
@ -93,8 +93,7 @@ ynh_exec_err() {
|
||||||
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
||||||
# (because in the past eval was used) ...
|
# (because in the past eval was used) ...
|
||||||
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
||||||
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]
|
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]; then
|
||||||
then
|
|
||||||
ynh_print_err --message="$(eval $@)"
|
ynh_print_err --message="$(eval $@)"
|
||||||
else
|
else
|
||||||
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
||||||
|
@ -114,8 +113,7 @@ ynh_exec_warn() {
|
||||||
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
||||||
# (because in the past eval was used) ...
|
# (because in the past eval was used) ...
|
||||||
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
||||||
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]
|
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]; then
|
||||||
then
|
|
||||||
ynh_print_warn --message="$(eval $@)"
|
ynh_print_warn --message="$(eval $@)"
|
||||||
else
|
else
|
||||||
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
||||||
|
@ -135,8 +133,7 @@ ynh_exec_warn_less() {
|
||||||
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
||||||
# (because in the past eval was used) ...
|
# (because in the past eval was used) ...
|
||||||
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
||||||
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]
|
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]; then
|
||||||
then
|
|
||||||
eval $@ 2>&1
|
eval $@ 2>&1
|
||||||
else
|
else
|
||||||
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
||||||
|
@ -156,8 +153,7 @@ ynh_exec_quiet() {
|
||||||
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
||||||
# (because in the past eval was used) ...
|
# (because in the past eval was used) ...
|
||||||
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
||||||
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]
|
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]; then
|
||||||
then
|
|
||||||
eval $@ > /dev/null
|
eval $@ > /dev/null
|
||||||
else
|
else
|
||||||
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
||||||
|
@ -177,8 +173,7 @@ ynh_exec_fully_quiet() {
|
||||||
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
# Boring legacy handling for when people calls ynh_exec_* wrapping the command in quotes,
|
||||||
# (because in the past eval was used) ...
|
# (because in the past eval was used) ...
|
||||||
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
# we detect this by checking that there's no 2nd arg, and $1 contains a space
|
||||||
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]
|
if [[ "$#" -eq 1 ]] && [[ "$1" == *" "* ]]; then
|
||||||
then
|
|
||||||
eval $@ > /dev/null 2>&1
|
eval $@ > /dev/null 2>&1
|
||||||
else
|
else
|
||||||
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
||||||
|
@ -199,7 +194,7 @@ ynh_exec_and_print_stderr_only_if_error() {
|
||||||
rc=0
|
rc=0
|
||||||
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
||||||
"$@" 2> "$logfile" || rc="$?"
|
"$@" 2> "$logfile" || rc="$?"
|
||||||
if (( rc != 0 )); then
|
if ((rc != 0)); then
|
||||||
ynh_exec_warn cat "$logfile"
|
ynh_exec_warn cat "$logfile"
|
||||||
ynh_secure_remove "$logfile"
|
ynh_secure_remove "$logfile"
|
||||||
return "$rc"
|
return "$rc"
|
||||||
|
@ -216,7 +211,7 @@ ynh_exec_and_print_stderr_only_if_error() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.0 or higher.
|
# Requires YunoHost version 3.2.0 or higher.
|
||||||
ynh_print_OFF() {
|
ynh_print_OFF() {
|
||||||
exec {BASH_XTRACEFD}>/dev/null
|
exec {BASH_XTRACEFD}> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Restore the logging after ynh_print_OFF
|
# Restore the logging after ynh_print_OFF
|
||||||
|
@ -229,7 +224,7 @@ ynh_print_OFF() {
|
||||||
ynh_print_ON() {
|
ynh_print_ON() {
|
||||||
exec {BASH_XTRACEFD}>&1
|
exec {BASH_XTRACEFD}>&1
|
||||||
# Print an echo only for the log, to be able to know that ynh_print_ON has been called.
|
# Print an echo only for the log, to be able to know that ynh_print_ON has been called.
|
||||||
echo ynh_print_ON >/dev/null
|
echo ynh_print_ON > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Initial definitions for ynh_script_progression
|
# Initial definitions for ynh_script_progression
|
||||||
|
@ -271,9 +266,9 @@ ynh_script_progression() {
|
||||||
|
|
||||||
# Always activate time when running inside CI tests
|
# Always activate time when running inside CI tests
|
||||||
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
if [ ${PACKAGE_CHECK_EXEC:-0} -eq 1 ]; then
|
||||||
time=${time:-1}
|
time=${time:-1}
|
||||||
else
|
else
|
||||||
time=${time:-0}
|
time=${time:-0}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
last=${last:-0}
|
last=${last:-0}
|
||||||
|
@ -298,8 +293,8 @@ ynh_script_progression() {
|
||||||
local weight_values=$(($(echo "$weight_valuesA" "$weight_valuesB" | grep -v -E '^\s*$' | tr '\n' '+' | sed 's/+$/+0/g')))
|
local weight_values=$(($(echo "$weight_valuesA" "$weight_valuesB" | grep -v -E '^\s*$' | tr '\n' '+' | sed 's/+$/+0/g')))
|
||||||
|
|
||||||
# max_progression is a total number of calls to this helper.
|
# max_progression is a total number of calls to this helper.
|
||||||
# Less the number of calls with a weight value.
|
# Less the number of calls with a weight value.
|
||||||
# Plus the total of weight values
|
# Plus the total of weight values
|
||||||
max_progression=$(($helper_calls - $weight_calls + $weight_values))
|
max_progression=$(($helper_calls - $weight_calls + $weight_values))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -329,7 +324,7 @@ ynh_script_progression() {
|
||||||
|
|
||||||
local print_exec_time=""
|
local print_exec_time=""
|
||||||
if [ $time -eq 1 ] && [ "$exec_time" -gt 10 ]; then
|
if [ $time -eq 1 ] && [ "$exec_time" -gt 10 ]; then
|
||||||
print_exec_time=" [$(bc <<< "scale=1; $exec_time / 60" ) minutes]"
|
print_exec_time=" [$(bc <<< "scale=1; $exec_time / 60") minutes]"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_print_info "[$progression_bar] > ${message}${print_exec_time}"
|
ynh_print_info "[$progression_bar] > ${message}${print_exec_time}"
|
||||||
|
@ -343,5 +338,5 @@ ynh_script_progression() {
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.6.0 or higher.
|
# Requires YunoHost version 3.6.0 or higher.
|
||||||
ynh_return() {
|
ynh_return() {
|
||||||
echo "$1" >>"$YNH_STDRETURN"
|
echo "$1" >> "$YNH_STDRETURN"
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,11 +16,9 @@ ynh_use_logrotate() {
|
||||||
|
|
||||||
# Stupid patch to ignore legacy --non-append and --nonappend
|
# Stupid patch to ignore legacy --non-append and --nonappend
|
||||||
# which was never properly understood and improperly used and kind of bullshit
|
# which was never properly understood and improperly used and kind of bullshit
|
||||||
local all_args=( ${@} )
|
local all_args=(${@})
|
||||||
for I in $(seq 0 $(($# - 1)))
|
for I in $(seq 0 $(($# - 1))); do
|
||||||
do
|
if [[ "${all_args[$I]}" == "--non-append" ]] || [[ "${all_args[$I]}" == "--nonappend" ]]; then
|
||||||
if [[ "${all_args[$I]}" == "--non-append" ]] || [[ "${all_args[$I]}" == "--nonappend" ]]
|
|
||||||
then
|
|
||||||
unset all_args[$I]
|
unset all_args[$I]
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -43,8 +41,7 @@ ynh_use_logrotate() {
|
||||||
fi
|
fi
|
||||||
set +o noglob
|
set +o noglob
|
||||||
|
|
||||||
for stuff in $logfile
|
for stuff in $logfile; do
|
||||||
do
|
|
||||||
mkdir --parents $(dirname "$stuff")
|
mkdir --parents $(dirname "$stuff")
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -54,7 +51,7 @@ ynh_use_logrotate() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local tempconf="$(mktemp)"
|
local tempconf="$(mktemp)"
|
||||||
cat << EOF >$tempconf
|
cat << EOF > $tempconf
|
||||||
$logfile {
|
$logfile {
|
||||||
# Rotate if the logfile exceeds 100Mo
|
# Rotate if the logfile exceeds 100Mo
|
||||||
size 100M
|
size 100M
|
||||||
|
@ -76,8 +73,7 @@ $logfile {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [[ "$FIRST_CALL_TO_LOGROTATE" == "true" ]]
|
if [[ "$FIRST_CALL_TO_LOGROTATE" == "true" ]]; then
|
||||||
then
|
|
||||||
cat $tempconf > /etc/logrotate.d/$app
|
cat $tempconf > /etc/logrotate.d/$app
|
||||||
else
|
else
|
||||||
cat $tempconf >> /etc/logrotate.d/$app
|
cat $tempconf >> /etc/logrotate.d/$app
|
||||||
|
|
|
@ -6,100 +6,92 @@
|
||||||
# example: ynh_mongo_exec --command="db.getMongo().getDBNames().indexOf(\"wekan\")"
|
# example: ynh_mongo_exec --command="db.getMongo().getDBNames().indexOf(\"wekan\")"
|
||||||
#
|
#
|
||||||
# usage: ynh_mongo_exec [--user=user] [--password=password] [--authenticationdatabase=authenticationdatabase] [--database=database] [--host=host] [--port=port] --command="command" [--eval]
|
# usage: ynh_mongo_exec [--user=user] [--password=password] [--authenticationdatabase=authenticationdatabase] [--database=database] [--host=host] [--port=port] --command="command" [--eval]
|
||||||
# | arg: -u, --user= - The user name to connect as
|
# | arg: -u, --user= - The user name to connect as
|
||||||
# | arg: -p, --password= - The user password
|
# | arg: -p, --password= - The user password
|
||||||
# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to
|
# | arg: -d, --authenticationdatabase= - The authenticationdatabase to connect to
|
||||||
# | arg: -d, --database= - The database to connect to
|
# | arg: -d, --database= - The database to connect to
|
||||||
# | arg: -h, --host= - The host to connect to
|
# | arg: -h, --host= - The host to connect to
|
||||||
# | arg: -P, --port= - The port to connect to
|
# | arg: -P, --port= - The port to connect to
|
||||||
# | arg: -c, --command= - The command to evaluate
|
# | arg: -c, --command= - The command to evaluate
|
||||||
# | arg: -e, --eval - Evaluate instead of execute the command.
|
# | arg: -e, --eval - Evaluate instead of execute the command.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_exec() {
|
ynh_mongo_exec() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=upadhPce
|
local legacy_args=upadhPce
|
||||||
local -A args_array=( [u]=user= [p]=password= [a]=authenticationdatabase= [d]=database= [h]=host= [P]=port= [c]=command= [e]=eval )
|
local -A args_array=([u]=user= [p]=password= [a]=authenticationdatabase= [d]=database= [h]=host= [P]=port= [c]=command= [e]=eval)
|
||||||
local user
|
local user
|
||||||
local password
|
local password
|
||||||
local authenticationdatabase
|
local authenticationdatabase
|
||||||
local database
|
local database
|
||||||
local host
|
local host
|
||||||
local port
|
local port
|
||||||
local command
|
local command
|
||||||
local eval
|
local eval
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
user="${user:-}"
|
user="${user:-}"
|
||||||
password="${password:-}"
|
password="${password:-}"
|
||||||
authenticationdatabase="${authenticationdatabase:-}"
|
authenticationdatabase="${authenticationdatabase:-}"
|
||||||
database="${database:-}"
|
database="${database:-}"
|
||||||
host="${host:-}"
|
host="${host:-}"
|
||||||
port="${port:-}"
|
port="${port:-}"
|
||||||
eval=${eval:-0}
|
eval=${eval:-0}
|
||||||
|
|
||||||
# If user is provided
|
# If user is provided
|
||||||
if [ -n "$user" ]
|
if [ -n "$user" ]; then
|
||||||
then
|
user="--username=$user"
|
||||||
user="--username=$user"
|
|
||||||
|
|
||||||
# If password is provided
|
# If password is provided
|
||||||
if [ -n "$password" ]
|
if [ -n "$password" ]; then
|
||||||
then
|
password="--password=$password"
|
||||||
password="--password=$password"
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# If authenticationdatabase is provided
|
# If authenticationdatabase is provided
|
||||||
if [ -n "$authenticationdatabase" ]
|
if [ -n "$authenticationdatabase" ]; then
|
||||||
then
|
authenticationdatabase="--authenticationDatabase=$authenticationdatabase"
|
||||||
authenticationdatabase="--authenticationDatabase=$authenticationdatabase"
|
else
|
||||||
else
|
authenticationdatabase="--authenticationDatabase=admin"
|
||||||
authenticationdatabase="--authenticationDatabase=admin"
|
fi
|
||||||
fi
|
else
|
||||||
else
|
password=""
|
||||||
password=""
|
authenticationdatabase=""
|
||||||
authenticationdatabase=""
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# If host is provided
|
# If host is provided
|
||||||
if [ -n "$host" ]
|
if [ -n "$host" ]; then
|
||||||
then
|
host="--host=$host"
|
||||||
host="--host=$host"
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# If port is provided
|
# If port is provided
|
||||||
if [ -n "$port" ]
|
if [ -n "$port" ]; then
|
||||||
then
|
port="--port=$port"
|
||||||
port="--port=$port"
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# If eval is not provided
|
# If eval is not provided
|
||||||
if [ $eval -eq 0 ]
|
if [ $eval -eq 0 ]; then
|
||||||
then
|
# If database is provided
|
||||||
# If database is provided
|
if [ -n "$database" ]; then
|
||||||
if [ -n "$database" ]
|
database="use $database"
|
||||||
then
|
else
|
||||||
database="use $database"
|
database=""
|
||||||
else
|
fi
|
||||||
database=""
|
|
||||||
fi
|
|
||||||
|
|
||||||
mongosh --quiet --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port <<EOF
|
mongosh --quiet --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port << EOF
|
||||||
$database
|
$database
|
||||||
${command}
|
${command}
|
||||||
quit()
|
quit()
|
||||||
EOF
|
EOF
|
||||||
else
|
else
|
||||||
# If database is provided
|
# If database is provided
|
||||||
if [ -n "$database" ]
|
if [ -n "$database" ]; then
|
||||||
then
|
database="$database"
|
||||||
database="$database"
|
else
|
||||||
else
|
database=""
|
||||||
database=""
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
mongosh --quiet $database --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port --eval="$command"
|
mongosh --quiet $database --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port --eval="$command"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Drop a database
|
# Drop a database
|
||||||
|
@ -110,18 +102,18 @@ EOF
|
||||||
# consider using ynh_mongo_remove_db instead.
|
# consider using ynh_mongo_remove_db instead.
|
||||||
#
|
#
|
||||||
# usage: ynh_mongo_drop_db --database=database
|
# usage: ynh_mongo_drop_db --database=database
|
||||||
# | arg: -d, --database= - The database name to drop
|
# | arg: -d, --database= - The database name to drop
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_drop_db() {
|
ynh_mongo_drop_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=d
|
local legacy_args=d
|
||||||
local -A args_array=( [d]=database= )
|
local -A args_array=([d]=database=)
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
ynh_mongo_exec --database="$database" --command='db.runCommand({dropDatabase: 1})'
|
ynh_mongo_exec --database="$database" --command='db.runCommand({dropDatabase: 1})'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Dump a database
|
# Dump a database
|
||||||
|
@ -129,19 +121,19 @@ ynh_mongo_drop_db() {
|
||||||
# example: ynh_mongo_dump_db --database=wekan > ./dump.bson
|
# example: ynh_mongo_dump_db --database=wekan > ./dump.bson
|
||||||
#
|
#
|
||||||
# usage: ynh_mongo_dump_db --database=database
|
# usage: ynh_mongo_dump_db --database=database
|
||||||
# | arg: -d, --database= - The database name to dump
|
# | arg: -d, --database= - The database name to dump
|
||||||
# | ret: the mongodump output
|
# | ret: the mongodump output
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_dump_db() {
|
ynh_mongo_dump_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=d
|
local legacy_args=d
|
||||||
local -A args_array=( [d]=database= )
|
local -A args_array=([d]=database=)
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
mongodump --quiet --db="$database" --archive
|
mongodump --quiet --db="$database" --archive
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a user
|
# Create a user
|
||||||
|
@ -149,49 +141,48 @@ ynh_mongo_dump_db() {
|
||||||
# [internal]
|
# [internal]
|
||||||
#
|
#
|
||||||
# usage: ynh_mongo_create_user --db_user=user --db_pwd=pwd --db_name=name
|
# usage: ynh_mongo_create_user --db_user=user --db_pwd=pwd --db_name=name
|
||||||
# | arg: -u, --db_user= - The user name to create
|
# | arg: -u, --db_user= - The user name to create
|
||||||
# | arg: -p, --db_pwd= - The password to identify user by
|
# | arg: -p, --db_pwd= - The password to identify user by
|
||||||
# | arg: -n, --db_name= - Name of the database to grant privilegies
|
# | arg: -n, --db_name= - Name of the database to grant privilegies
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_create_user() {
|
ynh_mongo_create_user() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=unp
|
local legacy_args=unp
|
||||||
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
|
local -A args_array=([u]=db_user= [n]=db_name= [p]=db_pwd=)
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
local db_pwd
|
local db_pwd
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
# Create the user and set the user as admin of the db
|
# Create the user and set the user as admin of the db
|
||||||
ynh_mongo_exec --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );'
|
ynh_mongo_exec --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );'
|
||||||
|
|
||||||
# Add clustermonitoring rights
|
# Add clustermonitoring rights
|
||||||
ynh_mongo_exec --database="$db_name" --command='db.grantRolesToUser("'${db_user}'",[{ role: "clusterMonitor", db: "admin" }]);'
|
ynh_mongo_exec --database="$db_name" --command='db.grantRolesToUser("'${db_user}'",[{ role: "clusterMonitor", db: "admin" }]);'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if a mongo database exists
|
# Check if a mongo database exists
|
||||||
#
|
#
|
||||||
# usage: ynh_mongo_database_exists --database=database
|
# usage: ynh_mongo_database_exists --database=database
|
||||||
# | arg: -d, --database= - The database for which to check existence
|
# | arg: -d, --database= - The database for which to check existence
|
||||||
# | exit: Return 1 if the database doesn't exist, 0 otherwise
|
# | exit: Return 1 if the database doesn't exist, 0 otherwise
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_database_exists() {
|
ynh_mongo_database_exists() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=d
|
local legacy_args=d
|
||||||
local -A args_array=([d]=database=)
|
local -A args_array=([d]=database=)
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")' --eval) -lt 0 ]
|
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")' --eval) -lt 0 ]; then
|
||||||
then
|
return 1
|
||||||
return 1
|
else
|
||||||
else
|
return 0
|
||||||
return 0
|
fi
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Restore a database
|
# Restore a database
|
||||||
|
@ -199,18 +190,18 @@ ynh_mongo_database_exists() {
|
||||||
# example: ynh_mongo_restore_db --database=wekan < ./dump.bson
|
# example: ynh_mongo_restore_db --database=wekan < ./dump.bson
|
||||||
#
|
#
|
||||||
# usage: ynh_mongo_restore_db --database=database
|
# usage: ynh_mongo_restore_db --database=database
|
||||||
# | arg: -d, --database= - The database name to restore
|
# | arg: -d, --database= - The database name to restore
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_restore_db() {
|
ynh_mongo_restore_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=d
|
local legacy_args=d
|
||||||
local -A args_array=( [d]=database= )
|
local -A args_array=([d]=database=)
|
||||||
local database
|
local database
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
mongorestore --quiet --db="$database" --archive
|
mongorestore --quiet --db="$database" --archive
|
||||||
}
|
}
|
||||||
|
|
||||||
# Drop a user
|
# Drop a user
|
||||||
|
@ -218,120 +209,120 @@ ynh_mongo_restore_db() {
|
||||||
# [internal]
|
# [internal]
|
||||||
#
|
#
|
||||||
# usage: ynh_mongo_drop_user --db_user=user --db_name=name
|
# usage: ynh_mongo_drop_user --db_user=user --db_name=name
|
||||||
# | arg: -u, --db_user= - The user to drop
|
# | arg: -u, --db_user= - The user to drop
|
||||||
# | arg: -n, --db_name= - Name of the database
|
# | arg: -n, --db_name= - Name of the database
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_drop_user() {
|
ynh_mongo_drop_user() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=un
|
local legacy_args=un
|
||||||
local -A args_array=( [u]=db_user= [n]=db_name= )
|
local -A args_array=([u]=db_user= [n]=db_name=)
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
ynh_mongo_exec --database="$db_name" --command='db.dropUser("'$db_user'", {w: "majority", wtimeout: 5000})'
|
ynh_mongo_exec --database="$db_name" --command='db.dropUser("'$db_user'", {w: "majority", wtimeout: 5000})'
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a database, an user and its password. Then store the password in the app's config
|
# Create a database, an user and its password. Then store the password in the app's config
|
||||||
#
|
#
|
||||||
# usage: ynh_mongo_setup_db --db_user=user --db_name=name [--db_pwd=pwd]
|
# usage: ynh_mongo_setup_db --db_user=user --db_name=name [--db_pwd=pwd]
|
||||||
# | arg: -u, --db_user= - Owner of the database
|
# | arg: -u, --db_user= - Owner of the database
|
||||||
# | arg: -n, --db_name= - Name of the database
|
# | arg: -n, --db_name= - Name of the database
|
||||||
# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated
|
# | arg: -p, --db_pwd= - Password of the database. If not provided, a password will be generated
|
||||||
#
|
#
|
||||||
# After executing this helper, the password of the created database will be available in $db_pwd
|
# After executing this helper, the password of the created database will be available in $db_pwd
|
||||||
# It will also be stored as "mongopwd" into the app settings.
|
# It will also be stored as "mongopwd" into the app settings.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_setup_db() {
|
ynh_mongo_setup_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=unp
|
local legacy_args=unp
|
||||||
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
|
local -A args_array=([u]=db_user= [n]=db_name= [p]=db_pwd=)
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
db_pwd=""
|
db_pwd=""
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
local new_db_pwd=$(ynh_string_random) # Generate a random password
|
local new_db_pwd=$(ynh_string_random) # Generate a random password
|
||||||
# If $db_pwd is not provided, use new_db_pwd instead for db_pwd
|
# If $db_pwd is not provided, use new_db_pwd instead for db_pwd
|
||||||
db_pwd="${db_pwd:-$new_db_pwd}"
|
db_pwd="${db_pwd:-$new_db_pwd}"
|
||||||
|
|
||||||
# Create the user and grant access to the database
|
# Create the user and grant access to the database
|
||||||
ynh_mongo_create_user --db_user="$db_user" --db_pwd="$db_pwd" --db_name="$db_name"
|
ynh_mongo_create_user --db_user="$db_user" --db_pwd="$db_pwd" --db_name="$db_name"
|
||||||
|
|
||||||
# Store the password in the app's config
|
# Store the password in the app's config
|
||||||
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove a database if it exists, and the associated user
|
# Remove a database if it exists, and the associated user
|
||||||
#
|
#
|
||||||
# usage: ynh_mongo_remove_db --db_user=user --db_name=name
|
# usage: ynh_mongo_remove_db --db_user=user --db_name=name
|
||||||
# | arg: -u, --db_user= - Owner of the database
|
# | arg: -u, --db_user= - Owner of the database
|
||||||
# | arg: -n, --db_name= - Name of the database
|
# | arg: -n, --db_name= - Name of the database
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_mongo_remove_db() {
|
ynh_mongo_remove_db() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=un
|
local legacy_args=un
|
||||||
local -A args_array=( [u]=db_user= [n]=db_name= )
|
local -A args_array=([u]=db_user= [n]=db_name=)
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
if ynh_mongo_database_exists --database=$db_name; then # Check if the database exists
|
if ynh_mongo_database_exists --database=$db_name; then # Check if the database exists
|
||||||
ynh_mongo_drop_db --database=$db_name # Remove the database
|
ynh_mongo_drop_db --database=$db_name # Remove the database
|
||||||
else
|
else
|
||||||
ynh_print_warn --message="Database $db_name not found"
|
ynh_print_warn --message="Database $db_name not found"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove mongo user if it exists
|
# Remove mongo user if it exists
|
||||||
ynh_mongo_drop_user --db_user=$db_user --db_name=$db_name
|
ynh_mongo_drop_user --db_user=$db_user --db_name=$db_name
|
||||||
}
|
}
|
||||||
|
|
||||||
# Install MongoDB and integrate MongoDB service in YunoHost
|
# Install MongoDB and integrate MongoDB service in YunoHost
|
||||||
#
|
#
|
||||||
# usage: ynh_install_mongo [--mongo_version=mongo_version]
|
# usage: ynh_install_mongo [--mongo_version=mongo_version]
|
||||||
# | arg: -m, --mongo_version= - Version of MongoDB to install
|
# | arg: -m, --mongo_version= - Version of MongoDB to install
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_install_mongo() {
|
ynh_install_mongo() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=m
|
local legacy_args=m
|
||||||
local -A args_array=([m]=mongo_version=)
|
local -A args_array=([m]=mongo_version=)
|
||||||
local mongo_version
|
local mongo_version
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
mongo_version="${mongo_version:-$YNH_MONGO_VERSION}"
|
mongo_version="${mongo_version:-$YNH_MONGO_VERSION}"
|
||||||
|
|
||||||
ynh_print_info --message="Installing MongoDB Community Edition ..."
|
ynh_print_info --message="Installing MongoDB Community Edition ..."
|
||||||
local mongo_debian_release=$(ynh_get_debian_release)
|
local mongo_debian_release=$(ynh_get_debian_release)
|
||||||
|
|
||||||
if [[ "$(grep '^flags' /proc/cpuinfo | uniq)" != *"avx"* && "$mongo_version" != "4.4" ]]; then
|
if [[ "$(grep '^flags' /proc/cpuinfo | uniq)" != *"avx"* && "$mongo_version" != "4.4" ]]; then
|
||||||
ynh_print_warn --message="Installing Mongo 4.4 as $mongo_version is not compatible with your cpu (see https://docs.mongodb.com/manual/administration/production-notes/#x86_64)."
|
ynh_print_warn --message="Installing Mongo 4.4 as $mongo_version is not compatible with your cpu (see https://docs.mongodb.com/manual/administration/production-notes/#x86_64)."
|
||||||
mongo_version="4.4"
|
mongo_version="4.4"
|
||||||
fi
|
fi
|
||||||
if [[ "$mongo_version" == "4.4" ]]; then
|
if [[ "$mongo_version" == "4.4" ]]; then
|
||||||
ynh_print_warn --message="Switched to buster install as Mongo 4.4 is not compatible with $mongo_debian_release."
|
ynh_print_warn --message="Switched to buster install as Mongo 4.4 is not compatible with $mongo_debian_release."
|
||||||
mongo_debian_release=buster
|
mongo_debian_release=buster
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian $mongo_debian_release/mongodb-org/$mongo_version main" --package="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh" --key="https://www.mongodb.org/static/pgp/server-$mongo_version.asc"
|
ynh_install_extra_app_dependencies --repo="deb http://repo.mongodb.org/apt/debian $mongo_debian_release/mongodb-org/$mongo_version main" --package="mongodb-org mongodb-org-server mongodb-org-tools mongodb-mongosh" --key="https://www.mongodb.org/static/pgp/server-$mongo_version.asc"
|
||||||
mongodb_servicename=mongod
|
mongodb_servicename=mongod
|
||||||
|
|
||||||
# Make sure MongoDB is started and enabled
|
# Make sure MongoDB is started and enabled
|
||||||
systemctl enable $mongodb_servicename --quiet
|
systemctl enable $mongodb_servicename --quiet
|
||||||
systemctl daemon-reload --quiet
|
systemctl daemon-reload --quiet
|
||||||
ynh_systemd_action --service_name=$mongodb_servicename --action=restart --line_match="aiting for connections" --log_path="/var/log/mongodb/$mongodb_servicename.log"
|
ynh_systemd_action --service_name=$mongodb_servicename --action=restart --line_match="aiting for connections" --log_path="/var/log/mongodb/$mongodb_servicename.log"
|
||||||
|
|
||||||
# Integrate MongoDB service in YunoHost
|
# Integrate MongoDB service in YunoHost
|
||||||
yunohost service add $mongodb_servicename --description="MongoDB daemon" --log="/var/log/mongodb/$mongodb_servicename.log"
|
yunohost service add $mongodb_servicename --description="MongoDB daemon" --log="/var/log/mongodb/$mongodb_servicename.log"
|
||||||
|
|
||||||
# Store mongo_version into the config of this app
|
# Store mongo_version into the config of this app
|
||||||
ynh_app_setting_set --app=$app --key=mongo_version --value=$mongo_version
|
ynh_app_setting_set --app=$app --key=mongo_version --value=$mongo_version
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remove MongoDB
|
# Remove MongoDB
|
||||||
|
@ -342,14 +333,13 @@ ynh_install_mongo() {
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
ynh_remove_mongo() {
|
ynh_remove_mongo() {
|
||||||
# Only remove the mongodb service if it is not installed.
|
# Only remove the mongodb service if it is not installed.
|
||||||
if ! ynh_package_is_installed --package="mongodb*"
|
if ! ynh_package_is_installed --package="mongodb*"; then
|
||||||
then
|
ynh_print_info --message="Removing MongoDB service..."
|
||||||
ynh_print_info --message="Removing MongoDB service..."
|
mongodb_servicename=mongod
|
||||||
mongodb_servicename=mongod
|
# Remove the mongodb service
|
||||||
# Remove the mongodb service
|
yunohost service remove $mongodb_servicename
|
||||||
yunohost service remove $mongodb_servicename
|
ynh_secure_remove --file="/var/lib/mongodb"
|
||||||
ynh_secure_remove --file="/var/lib/mongodb"
|
ynh_secure_remove --file="/var/log/mongodb"
|
||||||
ynh_secure_remove --file="/var/log/mongodb"
|
fi
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ ynh_mysql_execute_as_root() {
|
||||||
database="--database=$database"
|
database="--database=$database"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mysql -B "$database" <<<"$sql"
|
mysql -B "$database" <<< "$sql"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute a command from a file as root user
|
# Execute a command from a file as root user
|
||||||
|
@ -71,7 +71,7 @@ ynh_mysql_execute_file_as_root() {
|
||||||
database="--database=$database"
|
database="--database=$database"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mysql -B "$database" <"$file"
|
mysql -B "$database" < "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a database and grant optionnaly privilegies to a user
|
# Create a database and grant optionnaly privilegies to a user
|
||||||
|
|
|
@ -79,7 +79,7 @@ ynh_validate_ip() {
|
||||||
|
|
||||||
[ "$family" == "4" ] || [ "$family" == "6" ] || return 1
|
[ "$family" == "4" ] || [ "$family" == "6" ] || return 1
|
||||||
|
|
||||||
python3 /dev/stdin <<EOF
|
python3 /dev/stdin << EOF
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
family = { "4" : socket.AF_INET, "6" : socket.AF_INET6 }
|
family = { "4" : socket.AF_INET, "6" : socket.AF_INET6 }
|
||||||
|
|
|
@ -43,7 +43,6 @@ ynh_remove_nginx_config() {
|
||||||
ynh_systemd_action --service_name=nginx --action=reload
|
ynh_systemd_action --service_name=nginx --action=reload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Regen the nginx config in a change url context
|
# Regen the nginx config in a change url context
|
||||||
#
|
#
|
||||||
# usage: ynh_change_url_nginx_config
|
# usage: ynh_change_url_nginx_config
|
||||||
|
@ -53,7 +52,7 @@ ynh_change_url_nginx_config() {
|
||||||
|
|
||||||
# Make a backup of the original NGINX config file if manually modified
|
# Make a backup of the original NGINX config file if manually modified
|
||||||
# (nb: this is possibly different from the same instruction called by
|
# (nb: this is possibly different from the same instruction called by
|
||||||
# ynh_add_config inside ynh_add_nginx_config because the path may have
|
# ynh_add_config inside ynh_add_nginx_config because the path may have
|
||||||
# changed if we're changing the domain too...)
|
# changed if we're changing the domain too...)
|
||||||
local old_nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
local old_nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
ynh_backup_if_checksum_is_different --file="$old_nginx_conf_path"
|
ynh_backup_if_checksum_is_different --file="$old_nginx_conf_path"
|
||||||
|
|
|
@ -174,7 +174,7 @@ ynh_permission_exists() {
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
yunohost user permission list "$app" --output-as json --quiet \
|
yunohost user permission list "$app" --output-as json --quiet \
|
||||||
| jq -e --arg perm "$app.$permission" '.permissions[$perm]' >/dev/null
|
| jq -e --arg perm "$app.$permission" '.permissions[$perm]' > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Redefine the url associated to a permission
|
# Redefine the url associated to a permission
|
||||||
|
@ -342,7 +342,7 @@ ynh_permission_has_user() {
|
||||||
# Check both allowed and corresponding_users sections in the json
|
# Check both allowed and corresponding_users sections in the json
|
||||||
for section in "allowed" "corresponding_users"; do
|
for section in "allowed" "corresponding_users"; do
|
||||||
if yunohost user permission info "$app.$permission" --output-as json --quiet \
|
if yunohost user permission info "$app.$permission" --output-as json --quiet \
|
||||||
| jq -e --arg user $user --arg section $section '.[$section] | index($user)' >/dev/null; then
|
| jq -e --arg user $user --arg section $section '.[$section] | index($user)' > /dev/null; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -11,19 +11,19 @@ YNH_PHP_VERSION=${YNH_PHP_VERSION:-$YNH_DEFAULT_PHP_VERSION}
|
||||||
#
|
#
|
||||||
# Case 1 (recommended) : your provided a snippet conf/extra_php-fpm.conf
|
# Case 1 (recommended) : your provided a snippet conf/extra_php-fpm.conf
|
||||||
#
|
#
|
||||||
# The actual PHP configuration will be automatically generated,
|
# The actual PHP configuration will be automatically generated,
|
||||||
# and your extra_php-fpm.conf will be appended (typically contains PHP upload limits)
|
# and your extra_php-fpm.conf will be appended (typically contains PHP upload limits)
|
||||||
#
|
#
|
||||||
# The resulting configuration will be deployed to the appropriate place, /etc/php/$phpversion/fpm/pool.d/$app.conf
|
# The resulting configuration will be deployed to the appropriate place, /etc/php/$phpversion/fpm/pool.d/$app.conf
|
||||||
#
|
#
|
||||||
# Performance-related options in the PHP conf, such as :
|
# Performance-related options in the PHP conf, such as :
|
||||||
# pm.max_children, pm.start_servers, pm.min_spare_servers pm.max_spare_servers
|
# pm.max_children, pm.start_servers, pm.min_spare_servers pm.max_spare_servers
|
||||||
# are computed from two parameters called "usage" and "footprint" which can be set to low/medium/high. (cf details below)
|
# are computed from two parameters called "usage" and "footprint" which can be set to low/medium/high. (cf details below)
|
||||||
#
|
#
|
||||||
# If you wish to tweak those, please initialize the settings `fpm_usage` and `fpm_footprint`
|
# If you wish to tweak those, please initialize the settings `fpm_usage` and `fpm_footprint`
|
||||||
# *prior* to calling this helper. Otherwise, "low" will be used as a default for both values.
|
# *prior* to calling this helper. Otherwise, "low" will be used as a default for both values.
|
||||||
#
|
#
|
||||||
# Otherwise, if you want the user to have control over these, we encourage to create a config panel
|
# Otherwise, if you want the user to have control over these, we encourage to create a config panel
|
||||||
# (which should ultimately be standardized by the core ...)
|
# (which should ultimately be standardized by the core ...)
|
||||||
#
|
#
|
||||||
# Case 2 (deprecate) : you provided an entire conf/php-fpm.conf
|
# Case 2 (deprecate) : you provided an entire conf/php-fpm.conf
|
||||||
|
@ -33,7 +33,7 @@ YNH_PHP_VERSION=${YNH_PHP_VERSION:-$YNH_DEFAULT_PHP_VERSION}
|
||||||
# The resulting configuration will be deployed to the appropriate place, /etc/php/$phpversion/fpm/pool.d/$app.conf
|
# The resulting configuration will be deployed to the appropriate place, /etc/php/$phpversion/fpm/pool.d/$app.conf
|
||||||
#
|
#
|
||||||
# ----------------------
|
# ----------------------
|
||||||
#
|
#
|
||||||
# fpm_footprint: Memory footprint of the service (low/medium/high).
|
# fpm_footprint: Memory footprint of the service (low/medium/high).
|
||||||
# low - Less than 20 MB of RAM by pool.
|
# low - Less than 20 MB of RAM by pool.
|
||||||
# medium - Between 20 MB and 40 MB of RAM by pool.
|
# medium - Between 20 MB and 40 MB of RAM by pool.
|
||||||
|
@ -92,16 +92,14 @@ ynh_add_fpm_config() {
|
||||||
|
|
||||||
# If no usage provided, default to the value existing in setting ... or to low
|
# If no usage provided, default to the value existing in setting ... or to low
|
||||||
local fpm_usage_in_setting=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
local fpm_usage_in_setting=$(ynh_app_setting_get --app=$app --key=fpm_usage)
|
||||||
if [ -z "$usage" ]
|
if [ -z "$usage" ]; then
|
||||||
then
|
|
||||||
usage=${fpm_usage_in_setting:-low}
|
usage=${fpm_usage_in_setting:-low}
|
||||||
ynh_app_setting_set --app=$app --key=fpm_usage --value=$usage
|
ynh_app_setting_set --app=$app --key=fpm_usage --value=$usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If no footprint provided, default to the value existing in setting ... or to low
|
# If no footprint provided, default to the value existing in setting ... or to low
|
||||||
local fpm_footprint_in_setting=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
local fpm_footprint_in_setting=$(ynh_app_setting_get --app=$app --key=fpm_footprint)
|
||||||
if [ -z "$footprint" ]
|
if [ -z "$footprint" ]; then
|
||||||
then
|
|
||||||
footprint=${fpm_footprint_in_setting:-low}
|
footprint=${fpm_footprint_in_setting:-low}
|
||||||
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$footprint
|
ynh_app_setting_set --app=$app --key=fpm_footprint --value=$footprint
|
||||||
fi
|
fi
|
||||||
|
@ -125,8 +123,7 @@ ynh_add_fpm_config() {
|
||||||
local old_php_fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
|
local old_php_fpm_config_dir=$(ynh_app_setting_get --app=$app --key=fpm_config_dir)
|
||||||
local old_php_finalphpconf="$old_php_fpm_config_dir/pool.d/$app.conf"
|
local old_php_finalphpconf="$old_php_fpm_config_dir/pool.d/$app.conf"
|
||||||
|
|
||||||
if [[ -f "$old_php_finalphpconf" ]]
|
if [[ -f "$old_php_finalphpconf" ]]; then
|
||||||
then
|
|
||||||
ynh_backup_if_checksum_is_different --file="$old_php_finalphpconf"
|
ynh_backup_if_checksum_is_different --file="$old_php_finalphpconf"
|
||||||
ynh_remove_fpm_config
|
ynh_remove_fpm_config
|
||||||
fi
|
fi
|
||||||
|
@ -200,24 +197,24 @@ pm = __PHP_PM__
|
||||||
pm.max_children = __PHP_MAX_CHILDREN__
|
pm.max_children = __PHP_MAX_CHILDREN__
|
||||||
pm.max_requests = 500
|
pm.max_requests = 500
|
||||||
request_terminate_timeout = 1d
|
request_terminate_timeout = 1d
|
||||||
" >"$phpfpm_path"
|
" > "$phpfpm_path"
|
||||||
|
|
||||||
if [ "$php_pm" = "dynamic" ]; then
|
if [ "$php_pm" = "dynamic" ]; then
|
||||||
echo "
|
echo "
|
||||||
pm.start_servers = __PHP_START_SERVERS__
|
pm.start_servers = __PHP_START_SERVERS__
|
||||||
pm.min_spare_servers = __PHP_MIN_SPARE_SERVERS__
|
pm.min_spare_servers = __PHP_MIN_SPARE_SERVERS__
|
||||||
pm.max_spare_servers = __PHP_MAX_SPARE_SERVERS__
|
pm.max_spare_servers = __PHP_MAX_SPARE_SERVERS__
|
||||||
" >>"$phpfpm_path"
|
" >> "$phpfpm_path"
|
||||||
|
|
||||||
elif [ "$php_pm" = "ondemand" ]; then
|
elif [ "$php_pm" = "ondemand" ]; then
|
||||||
echo "
|
echo "
|
||||||
pm.process_idle_timeout = 10s
|
pm.process_idle_timeout = 10s
|
||||||
" >>"$phpfpm_path"
|
" >> "$phpfpm_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Concatene the extra config.
|
# Concatene the extra config.
|
||||||
if [ -e $YNH_APP_BASEDIR/conf/extra_php-fpm.conf ]; then
|
if [ -e $YNH_APP_BASEDIR/conf/extra_php-fpm.conf ]; then
|
||||||
cat $YNH_APP_BASEDIR/conf/extra_php-fpm.conf >>"$phpfpm_path"
|
cat $YNH_APP_BASEDIR/conf/extra_php-fpm.conf >> "$phpfpm_path"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -238,7 +235,7 @@ pid = /run/php/php__PHPVERSION__-fpm-__APP__.pid
|
||||||
error_log = /var/log/php/fpm-php.__APP__.log
|
error_log = /var/log/php/fpm-php.__APP__.log
|
||||||
syslog.ident = php-fpm-__APP__
|
syslog.ident = php-fpm-__APP__
|
||||||
include = __FINALPHPCONF__
|
include = __FINALPHPCONF__
|
||||||
" >$YNH_APP_BASEDIR/conf/php-fpm-$app.conf
|
" > $YNH_APP_BASEDIR/conf/php-fpm-$app.conf
|
||||||
|
|
||||||
ynh_add_config --template="php-fpm-$app.conf" --destination="$globalphpconf"
|
ynh_add_config --template="php-fpm-$app.conf" --destination="$globalphpconf"
|
||||||
|
|
||||||
|
@ -255,7 +252,7 @@ ExecReload=/bin/kill -USR2 \$MAINPID
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
" >$YNH_APP_BASEDIR/conf/$fpm_service
|
" > $YNH_APP_BASEDIR/conf/$fpm_service
|
||||||
|
|
||||||
# Create this dedicated PHP-FPM service
|
# Create this dedicated PHP-FPM service
|
||||||
ynh_add_systemd_config --service=$fpm_service --template=$fpm_service
|
ynh_add_systemd_config --service=$fpm_service --template=$fpm_service
|
||||||
|
@ -267,7 +264,7 @@ WantedBy=multi-user.target
|
||||||
ynh_systemd_action --service_name=$fpm_service --action=restart
|
ynh_systemd_action --service_name=$fpm_service --action=restart
|
||||||
else
|
else
|
||||||
# Validate that the new php conf doesn't break php-fpm entirely
|
# Validate that the new php conf doesn't break php-fpm entirely
|
||||||
if ! php-fpm${phpversion} --test 2>/dev/null; then
|
if ! php-fpm${phpversion} --test 2> /dev/null; then
|
||||||
php-fpm${phpversion} --test || true
|
php-fpm${phpversion} --test || true
|
||||||
ynh_secure_remove --file="$finalphpconf"
|
ynh_secure_remove --file="$finalphpconf"
|
||||||
ynh_die --message="The new configuration broke php-fpm?"
|
ynh_die --message="The new configuration broke php-fpm?"
|
||||||
|
@ -360,7 +357,7 @@ ynh_install_php() {
|
||||||
# usage: ynh_remove_php
|
# usage: ynh_remove_php
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.8.1 or higher.
|
# Requires YunoHost version 3.8.1 or higher.
|
||||||
ynh_remove_php () {
|
ynh_remove_php() {
|
||||||
ynh_remove_app_dependencies
|
ynh_remove_app_dependencies
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ ynh_psql_execute_as_root() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_psql_connect_as --user="postgres" --password="$(cat $PSQL_ROOT_PWD_FILE)" \
|
ynh_psql_connect_as --user="postgres" --password="$(cat $PSQL_ROOT_PWD_FILE)" \
|
||||||
$database <<<"$sql"
|
$database <<< "$sql"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Execute a command from a file as root user
|
# Execute a command from a file as root user
|
||||||
|
@ -76,7 +76,7 @@ ynh_psql_execute_file_as_root() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_psql_connect_as --user="postgres" --password="$(cat $PSQL_ROOT_PWD_FILE)" \
|
ynh_psql_connect_as --user="postgres" --password="$(cat $PSQL_ROOT_PWD_FILE)" \
|
||||||
$database <"$file"
|
$database < "$file"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a database and grant optionnaly privilegies to a user
|
# Create a database and grant optionnaly privilegies to a user
|
||||||
|
@ -199,10 +199,9 @@ ynh_psql_database_exists() {
|
||||||
|
|
||||||
# if psql is not there, we cannot check the db
|
# if psql is not there, we cannot check the db
|
||||||
# though it could exists.
|
# though it could exists.
|
||||||
if ! command -v psql
|
if ! command -v psql; then
|
||||||
then
|
ynh_print_err -m "PostgreSQL is not installed, impossible to check for db existence."
|
||||||
ynh_print_err -m "PostgreSQL is not installed, impossible to check for db existence."
|
return 1
|
||||||
return 1
|
|
||||||
elif ! sudo --login --user=postgres PGUSER="postgres" PGPASSWORD="$(cat $PSQL_ROOT_PWD_FILE)" psql -tAc "SELECT datname FROM pg_database WHERE datname='$database';" | grep --quiet "$database"; then
|
elif ! sudo --login --user=postgres PGUSER="postgres" PGPASSWORD="$(cat $PSQL_ROOT_PWD_FILE)" psql -tAc "SELECT datname FROM pg_database WHERE datname='$database';" | grep --quiet "$database"; then
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
|
|
|
@ -5,27 +5,25 @@
|
||||||
# usage: ynh_redis_get_free_db
|
# usage: ynh_redis_get_free_db
|
||||||
# | returns: the database number to use
|
# | returns: the database number to use
|
||||||
ynh_redis_get_free_db() {
|
ynh_redis_get_free_db() {
|
||||||
local result max db
|
local result max db
|
||||||
result=$(redis-cli INFO keyspace)
|
result=$(redis-cli INFO keyspace)
|
||||||
|
|
||||||
# get the num
|
# get the num
|
||||||
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
|
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
|
||||||
|
|
||||||
db=0
|
db=0
|
||||||
# default Debian setting is 15 databases
|
# default Debian setting is 15 databases
|
||||||
for i in $(seq 0 "$max")
|
for i in $(seq 0 "$max"); do
|
||||||
do
|
if ! echo "$result" | grep -q "db$i"; then
|
||||||
if ! echo "$result" | grep -q "db$i"
|
db=$i
|
||||||
then
|
break 1
|
||||||
db=$i
|
fi
|
||||||
break 1
|
db=-1
|
||||||
fi
|
done
|
||||||
db=-1
|
|
||||||
done
|
|
||||||
|
|
||||||
test "$db" -eq -1 && ynh_die --message="No available Redis databases..."
|
test "$db" -eq -1 && ynh_die --message="No available Redis databases..."
|
||||||
|
|
||||||
echo "$db"
|
echo "$db"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a master password and set up global settings
|
# Create a master password and set up global settings
|
||||||
|
@ -34,6 +32,6 @@ ynh_redis_get_free_db() {
|
||||||
# usage: ynh_redis_remove_db database
|
# usage: ynh_redis_remove_db database
|
||||||
# | arg: database - the database to erase
|
# | arg: database - the database to erase
|
||||||
ynh_redis_remove_db() {
|
ynh_redis_remove_db() {
|
||||||
local db=$1
|
local db=$1
|
||||||
redis-cli -n "$db" flushdb
|
redis-cli -n "$db" flushdb
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@ export RBENV_ROOT="$rbenv_install_dir"
|
||||||
export rbenv_root="$rbenv_install_dir"
|
export rbenv_root="$rbenv_install_dir"
|
||||||
|
|
||||||
if dpkg --compare-versions ${YNH_APP_PACKAGING_FORMAT:-0} lt 2; then
|
if dpkg --compare-versions ${YNH_APP_PACKAGING_FORMAT:-0} lt 2; then
|
||||||
build_ruby_dependencies="libjemalloc-dev curl build-essential libreadline-dev zlib1g-dev libsqlite3-dev libssl-dev libxml2-dev libxslt-dev autoconf automake bison libtool"
|
build_ruby_dependencies="libjemalloc-dev curl build-essential libreadline-dev zlib1g-dev libsqlite3-dev libssl-dev libxml2-dev libxslt-dev autoconf automake bison libtool"
|
||||||
build_pkg_dependencies="${build_pkg_dependencies:-} $build_ruby_dependencies"
|
build_pkg_dependencies="${build_pkg_dependencies:-} $build_ruby_dependencies"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Load the version of Ruby for an app, and set variables.
|
# Load the version of Ruby for an app, and set variables.
|
||||||
|
@ -50,7 +50,7 @@ fi
|
||||||
# usage: ynh_use_ruby
|
# usage: ynh_use_ruby
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.2 or higher.
|
# Requires YunoHost version 3.2.2 or higher.
|
||||||
ynh_use_ruby () {
|
ynh_use_ruby() {
|
||||||
ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
|
ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
|
||||||
|
|
||||||
# Get the absolute path of this version of Ruby
|
# Get the absolute path of this version of Ruby
|
||||||
|
@ -75,7 +75,7 @@ ynh_use_ruby () {
|
||||||
|
|
||||||
# Sets the local application-specific Ruby version
|
# Sets the local application-specific Ruby version
|
||||||
pushd ${install_dir:-$final_path}
|
pushd ${install_dir:-$final_path}
|
||||||
$rbenv_install_dir/bin/rbenv local $ruby_version
|
$rbenv_install_dir/bin/rbenv local $ruby_version
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,10 +95,10 @@ ynh_use_ruby () {
|
||||||
# | arg: -v, --ruby_version= - Version of ruby to install.
|
# | arg: -v, --ruby_version= - Version of ruby to install.
|
||||||
#
|
#
|
||||||
# Requires YunoHost version 3.2.2 or higher.
|
# Requires YunoHost version 3.2.2 or higher.
|
||||||
ynh_install_ruby () {
|
ynh_install_ruby() {
|
||||||
# Declare an array to define the options of this helper.
|
# Declare an array to define the options of this helper.
|
||||||
local legacy_args=v
|
local legacy_args=v
|
||||||
local -A args_array=( [v]=ruby_version= )
|
local -A args_array=([v]=ruby_version=)
|
||||||
local ruby_version
|
local ruby_version
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
@ -117,31 +117,31 @@ ynh_install_ruby () {
|
||||||
rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | grep "$rbenv_install_dir/bin/rbenv" | head -1)"
|
rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | grep "$rbenv_install_dir/bin/rbenv" | head -1)"
|
||||||
if [ -n "$rbenv" ]; then
|
if [ -n "$rbenv" ]; then
|
||||||
pushd "${rbenv%/*/*}"
|
pushd "${rbenv%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/rbenv.git"; then
|
if git remote -v 2> /dev/null | grep "https://github.com/rbenv/rbenv.git"; then
|
||||||
ynh_print_info --message="Updating rbenv..."
|
ynh_print_info --message="Updating rbenv..."
|
||||||
git pull -q --tags origin master
|
git pull -q --tags origin master
|
||||||
ynh_ruby_try_bash_extension
|
ynh_ruby_try_bash_extension
|
||||||
else
|
else
|
||||||
ynh_print_info --message="Reinstalling rbenv..."
|
ynh_print_info --message="Reinstalling rbenv..."
|
||||||
cd ..
|
cd ..
|
||||||
ynh_secure_remove --file=$rbenv_install_dir
|
ynh_secure_remove --file=$rbenv_install_dir
|
||||||
mkdir -p $rbenv_install_dir
|
mkdir -p $rbenv_install_dir
|
||||||
cd $rbenv_install_dir
|
cd $rbenv_install_dir
|
||||||
git init -q
|
|
||||||
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
|
||||||
git checkout -q -b master origin/master
|
|
||||||
ynh_ruby_try_bash_extension
|
|
||||||
rbenv=$rbenv_install_dir/bin/rbenv
|
|
||||||
fi
|
|
||||||
popd
|
|
||||||
else
|
|
||||||
ynh_print_info --message="Installing rbenv..."
|
|
||||||
pushd $rbenv_install_dir
|
|
||||||
git init -q
|
git init -q
|
||||||
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||||
git checkout -q -b master origin/master
|
git checkout -q -b master origin/master
|
||||||
ynh_ruby_try_bash_extension
|
ynh_ruby_try_bash_extension
|
||||||
rbenv=$rbenv_install_dir/bin/rbenv
|
rbenv=$rbenv_install_dir/bin/rbenv
|
||||||
|
fi
|
||||||
|
popd
|
||||||
|
else
|
||||||
|
ynh_print_info --message="Installing rbenv..."
|
||||||
|
pushd $rbenv_install_dir
|
||||||
|
git init -q
|
||||||
|
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||||
|
git checkout -q -b master origin/master
|
||||||
|
ynh_ruby_try_bash_extension
|
||||||
|
rbenv=$rbenv_install_dir/bin/rbenv
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -150,10 +150,10 @@ ynh_install_ruby () {
|
||||||
ruby_build="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
|
ruby_build="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
|
||||||
if [ -n "$ruby_build" ]; then
|
if [ -n "$ruby_build" ]; then
|
||||||
pushd "${ruby_build%/*/*}"
|
pushd "${ruby_build%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
|
if git remote -v 2> /dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
|
||||||
ynh_print_info --message="Updating ruby-build..."
|
ynh_print_info --message="Updating ruby-build..."
|
||||||
git pull -q origin master
|
git pull -q origin master
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
ynh_print_info --message="Installing ruby-build..."
|
ynh_print_info --message="Installing ruby-build..."
|
||||||
|
@ -163,10 +163,10 @@ ynh_install_ruby () {
|
||||||
rbenv_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
|
rbenv_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
|
||||||
if [ -n "$rbenv_alias" ]; then
|
if [ -n "$rbenv_alias" ]; then
|
||||||
pushd "${rbenv_alias%/*/*}"
|
pushd "${rbenv_alias%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then
|
if git remote -v 2> /dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then
|
||||||
ynh_print_info --message="Updating rbenv-aliases..."
|
ynh_print_info --message="Updating rbenv-aliases..."
|
||||||
git pull -q origin master
|
git pull -q origin master
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
ynh_print_info --message="Installing rbenv-aliases..."
|
ynh_print_info --message="Installing rbenv-aliases..."
|
||||||
|
@ -176,10 +176,10 @@ ynh_install_ruby () {
|
||||||
rbenv_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
|
rbenv_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
|
||||||
if [ -n "$rbenv_latest" ]; then
|
if [ -n "$rbenv_latest" ]; then
|
||||||
pushd "${rbenv_latest%/*/*}"
|
pushd "${rbenv_latest%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
if git remote -v 2> /dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
||||||
ynh_print_info --message="Updating xxenv-latest..."
|
ynh_print_info --message="Updating xxenv-latest..."
|
||||||
git pull -q origin master
|
git pull -q origin master
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
ynh_print_info --message="Installing xxenv-latest..."
|
ynh_print_info --message="Installing xxenv-latest..."
|
||||||
|
@ -210,8 +210,7 @@ ynh_install_ruby () {
|
||||||
ynh_app_setting_set --app=$app --key=ruby_version --value=$final_ruby_version
|
ynh_app_setting_set --app=$app --key=ruby_version --value=$final_ruby_version
|
||||||
|
|
||||||
# Remove app virtualenv
|
# Remove app virtualenv
|
||||||
if rbenv alias --list | grep --quiet "$app "
|
if rbenv alias --list | grep --quiet "$app "; then
|
||||||
then
|
|
||||||
rbenv alias $app --remove
|
rbenv alias $app --remove
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -222,7 +221,7 @@ ynh_install_ruby () {
|
||||||
ynh_cleanup_ruby
|
ynh_cleanup_ruby
|
||||||
|
|
||||||
# Set environment for Ruby users
|
# Set environment for Ruby users
|
||||||
echo "#rbenv
|
echo "#rbenv
|
||||||
export RBENV_ROOT=$rbenv_install_dir
|
export RBENV_ROOT=$rbenv_install_dir
|
||||||
export PATH=\"$rbenv_install_dir/bin:$PATH\"
|
export PATH=\"$rbenv_install_dir/bin:$PATH\"
|
||||||
eval \"\$(rbenv init -)\"
|
eval \"\$(rbenv init -)\"
|
||||||
|
@ -237,7 +236,7 @@ eval \"\$(rbenv init -)\"
|
||||||
# This helper will also cleanup Ruby versions
|
# This helper will also cleanup Ruby versions
|
||||||
#
|
#
|
||||||
# usage: ynh_remove_ruby
|
# usage: ynh_remove_ruby
|
||||||
ynh_remove_ruby () {
|
ynh_remove_ruby() {
|
||||||
local ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
|
local ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version)
|
||||||
|
|
||||||
# Load rbenv path in PATH
|
# Load rbenv path in PATH
|
||||||
|
@ -262,34 +261,29 @@ ynh_remove_ruby () {
|
||||||
# If no app uses Ruby, rbenv will be also removed.
|
# If no app uses Ruby, rbenv will be also removed.
|
||||||
#
|
#
|
||||||
# usage: ynh_cleanup_ruby
|
# usage: ynh_cleanup_ruby
|
||||||
ynh_cleanup_ruby () {
|
ynh_cleanup_ruby() {
|
||||||
|
|
||||||
# List required Ruby versions
|
# List required Ruby versions
|
||||||
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
||||||
local required_ruby_versions=""
|
local required_ruby_versions=""
|
||||||
for installed_app in $installed_apps
|
for installed_app in $installed_apps; do
|
||||||
do
|
|
||||||
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
||||||
if [[ -n "$installed_app_ruby_version" ]]
|
if [[ -n "$installed_app_ruby_version" ]]; then
|
||||||
then
|
|
||||||
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove no more needed Ruby versions
|
# Remove no more needed Ruby versions
|
||||||
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
||||||
for installed_ruby_version in $installed_ruby_versions
|
for installed_ruby_version in $installed_ruby_versions; do
|
||||||
do
|
if ! echo ${required_ruby_versions} | grep -q "${installed_ruby_version}"; then
|
||||||
if ! echo ${required_ruby_versions} | grep -q "${installed_ruby_version}"
|
|
||||||
then
|
|
||||||
ynh_print_info --message="Removing Ruby-$installed_ruby_version"
|
ynh_print_info --message="Removing Ruby-$installed_ruby_version"
|
||||||
$rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version
|
$rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# If none Ruby version is required
|
# If none Ruby version is required
|
||||||
if [[ -z "$required_ruby_versions" ]]
|
if [[ -z "$required_ruby_versions" ]]; then
|
||||||
then
|
|
||||||
# Remove rbenv environment configuration
|
# Remove rbenv environment configuration
|
||||||
ynh_print_info --message="Removing rbenv"
|
ynh_print_info --message="Removing rbenv"
|
||||||
ynh_secure_remove --file="$rbenv_install_dir"
|
ynh_secure_remove --file="$rbenv_install_dir"
|
||||||
|
@ -298,9 +292,9 @@ ynh_cleanup_ruby () {
|
||||||
}
|
}
|
||||||
|
|
||||||
ynh_ruby_try_bash_extension() {
|
ynh_ruby_try_bash_extension() {
|
||||||
if [ -x src/configure ]; then
|
if [ -x src/configure ]; then
|
||||||
src/configure && make -C src || {
|
src/configure && make -C src || {
|
||||||
ynh_print_info --message="Optional bash extension failed to build, but things will still work normally."
|
ynh_print_info --message="Optional bash extension failed to build, but things will still work normally."
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ ynh_app_setting_delete() {
|
||||||
#
|
#
|
||||||
ynh_app_setting() {
|
ynh_app_setting() {
|
||||||
set +o xtrace # set +x
|
set +o xtrace # set +x
|
||||||
ACTION="$1" APP="$2" KEY="$3" VALUE="${4:-}" python3 - <<EOF
|
ACTION="$1" APP="$2" KEY="$3" VALUE="${4:-}" python3 - << EOF
|
||||||
import os, yaml, sys
|
import os, yaml, sys
|
||||||
app, action = os.environ['APP'], os.environ['ACTION'].lower()
|
app, action = os.environ['APP'], os.environ['ACTION'].lower()
|
||||||
key, value = os.environ['KEY'], os.environ.get('VALUE', None)
|
key, value = os.environ['KEY'], os.environ.get('VALUE', None)
|
||||||
|
|
|
@ -77,12 +77,10 @@ ynh_setup_source() {
|
||||||
keep="${keep:-}"
|
keep="${keep:-}"
|
||||||
full_replace="${full_replace:-0}"
|
full_replace="${full_replace:-0}"
|
||||||
|
|
||||||
if test -e $YNH_APP_BASEDIR/manifest.toml && cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq -e '.resources.sources' >/dev/null
|
if test -e $YNH_APP_BASEDIR/manifest.toml && cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq -e '.resources.sources' > /dev/null; then
|
||||||
then
|
|
||||||
source_id="${source_id:-main}"
|
source_id="${source_id:-main}"
|
||||||
local sources_json=$(cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq ".resources.sources[\"$source_id\"]")
|
local sources_json=$(cat $YNH_APP_BASEDIR/manifest.toml | toml_to_json | jq ".resources.sources[\"$source_id\"]")
|
||||||
if jq -re ".url" <<< "$sources_json"
|
if jq -re ".url" <<< "$sources_json"; then
|
||||||
then
|
|
||||||
local arch_prefix=""
|
local arch_prefix=""
|
||||||
else
|
else
|
||||||
local arch_prefix=".$YNH_ARCH"
|
local arch_prefix=".$YNH_ARCH"
|
||||||
|
@ -100,22 +98,16 @@ ynh_setup_source() {
|
||||||
[[ -n "$src_url" ]] || ynh_die "No URL defined for source $source_id$arch_prefix ?"
|
[[ -n "$src_url" ]] || ynh_die "No URL defined for source $source_id$arch_prefix ?"
|
||||||
[[ -n "$src_sum" ]] || ynh_die "No sha256 sum defined for source $source_id$arch_prefix ?"
|
[[ -n "$src_sum" ]] || ynh_die "No sha256 sum defined for source $source_id$arch_prefix ?"
|
||||||
|
|
||||||
if [[ -z "$src_format" ]]
|
if [[ -z "$src_format" ]]; then
|
||||||
then
|
if [[ "$src_url" =~ ^.*\.zip$ ]] || [[ "$src_url" =~ ^.*/zipball/.*$ ]]; then
|
||||||
if [[ "$src_url" =~ ^.*\.zip$ ]] || [[ "$src_url" =~ ^.*/zipball/.*$ ]]
|
|
||||||
then
|
|
||||||
src_format="zip"
|
src_format="zip"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar\.gz$ ]] || [[ "$src_url" =~ ^.*\.tgz$ ]] || [[ "$src_url" =~ ^.*/tar\.gz/.*$ ]] || [[ "$src_url" =~ ^.*/tarball/.*$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar\.gz$ ]] || [[ "$src_url" =~ ^.*\.tgz$ ]] || [[ "$src_url" =~ ^.*/tar\.gz/.*$ ]] || [[ "$src_url" =~ ^.*/tarball/.*$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar.gz"
|
src_format="tar.gz"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar\.xz$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar\.xz$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar.xz"
|
src_format="tar.xz"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar\.bz2$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar\.bz2$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar.bz2"
|
src_format="tar.bz2"
|
||||||
elif [[ -z "$src_extract" ]]
|
elif [[ -z "$src_extract" ]]; then
|
||||||
then
|
|
||||||
src_extract="false"
|
src_extract="false"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -142,12 +134,10 @@ ynh_setup_source() {
|
||||||
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
||||||
src_extract=${src_extract:-true}
|
src_extract=${src_extract:-true}
|
||||||
|
|
||||||
if [[ "$src_extract" != "true" ]] && [[ "$src_extract" != "false" ]]
|
if [[ "$src_extract" != "true" ]] && [[ "$src_extract" != "false" ]]; then
|
||||||
then
|
|
||||||
ynh_die "For source $source_id, expected either 'true' or 'false' for the extract parameter"
|
ynh_die "For source $source_id, expected either 'true' or 'false' for the extract parameter"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# (Unused?) mecanism where one can have the file in a special local cache to not have to download it...
|
# (Unused?) mecanism where one can have the file in a special local cache to not have to download it...
|
||||||
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${source_id}"
|
local local_src="/opt/yunohost-apps-src/${YNH_APP_ID}/${source_id}"
|
||||||
|
|
||||||
|
@ -165,14 +155,12 @@ ynh_setup_source() {
|
||||||
[ -n "$src_url" ] || ynh_die "Couldn't parse SOURCE_URL from $src_file_path ?"
|
[ -n "$src_url" ] || ynh_die "Couldn't parse SOURCE_URL from $src_file_path ?"
|
||||||
|
|
||||||
# If the file was prefetched but somehow doesn't match the sum, rm and redownload it
|
# If the file was prefetched but somehow doesn't match the sum, rm and redownload it
|
||||||
if [ -e "$src_filename" ] && ! echo "${src_sum} ${src_filename}" | ${src_sumprg} --check --status
|
if [ -e "$src_filename" ] && ! echo "${src_sum} ${src_filename}" | ${src_sumprg} --check --status; then
|
||||||
then
|
|
||||||
rm -f "$src_filename"
|
rm -f "$src_filename"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Only redownload the file if it wasnt prefetched
|
# Only redownload the file if it wasnt prefetched
|
||||||
if [ ! -e "$src_filename" ]
|
if [ ! -e "$src_filename" ]; then
|
||||||
then
|
|
||||||
# NB. we have to declare the var as local first,
|
# NB. we have to declare the var as local first,
|
||||||
# otherwise 'local foo=$(false) || echo 'pwet'" does'nt work
|
# otherwise 'local foo=$(false) || echo 'pwet'" does'nt work
|
||||||
# because local always return 0 ...
|
# because local always return 0 ...
|
||||||
|
@ -183,8 +171,7 @@ ynh_setup_source() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check the control sum
|
# Check the control sum
|
||||||
if ! echo "${src_sum} ${src_filename}" | ${src_sumprg} --check --status
|
if ! echo "${src_sum} ${src_filename}" | ${src_sumprg} --check --status; then
|
||||||
then
|
|
||||||
local actual_sum="$(${src_sumprg} ${src_filename} | cut --delimiter=' ' --fields=1)"
|
local actual_sum="$(${src_sumprg} ${src_filename} | cut --delimiter=' ' --fields=1)"
|
||||||
local actual_size="$(du -hs ${src_filename} | cut --fields=1)"
|
local actual_size="$(du -hs ${src_filename} | cut --fields=1)"
|
||||||
rm -f ${src_filename}
|
rm -f ${src_filename}
|
||||||
|
@ -222,8 +209,7 @@ ynh_setup_source() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$src_extract" == "false" ]]; then
|
if [[ "$src_extract" == "false" ]]; then
|
||||||
if [[ -z "$src_rename" ]]
|
if [[ -z "$src_rename" ]]; then
|
||||||
then
|
|
||||||
mv $src_filename $dest_dir
|
mv $src_filename $dest_dir
|
||||||
else
|
else
|
||||||
mv $src_filename $dest_dir/$src_rename
|
mv $src_filename $dest_dir/$src_rename
|
||||||
|
@ -263,11 +249,11 @@ ynh_setup_source() {
|
||||||
# Apply patches
|
# Apply patches
|
||||||
if [ -d "$YNH_APP_BASEDIR/sources/patches/" ]; then
|
if [ -d "$YNH_APP_BASEDIR/sources/patches/" ]; then
|
||||||
local patches_folder=$(realpath $YNH_APP_BASEDIR/sources/patches/)
|
local patches_folder=$(realpath $YNH_APP_BASEDIR/sources/patches/)
|
||||||
if (($(find $patches_folder -type f -name "${source_id}-*.patch" 2>/dev/null | wc --lines) > "0")); then
|
if (($(find $patches_folder -type f -name "${source_id}-*.patch" 2> /dev/null | wc --lines) > "0")); then
|
||||||
pushd "$dest_dir"
|
pushd "$dest_dir"
|
||||||
for p in $patches_folder/${source_id}-*.patch; do
|
for p in $patches_folder/${source_id}-*.patch; do
|
||||||
echo $p
|
echo $p
|
||||||
patch --strip=1 <$p || ynh_print_warn --message="Packagers /!\\ patch $p failed to apply"
|
patch --strip=1 < $p || ynh_print_warn --message="Packagers /!\\ patch $p failed to apply"
|
||||||
done
|
done
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -21,7 +21,7 @@ ynh_string_random() {
|
||||||
length=${length:-24}
|
length=${length:-24}
|
||||||
filter=${filter:-'A-Za-z0-9'}
|
filter=${filter:-'A-Za-z0-9'}
|
||||||
|
|
||||||
dd if=/dev/urandom bs=1 count=1000 2>/dev/null \
|
dd if=/dev/urandom bs=1 count=1000 2> /dev/null \
|
||||||
| tr --complement --delete "$filter" \
|
| tr --complement --delete "$filter" \
|
||||||
| sed --quiet 's/\(.\{'"$length"'\}\).*/\1/p'
|
| sed --quiet 's/\(.\{'"$length"'\}\).*/\1/p'
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,12 +94,12 @@ ynh_systemd_action() {
|
||||||
# Following the starting of the app in its log
|
# Following the starting of the app in its log
|
||||||
if [ "$log_path" == "systemd" ]; then
|
if [ "$log_path" == "systemd" ]; then
|
||||||
# Read the systemd journal
|
# Read the systemd journal
|
||||||
journalctl --unit=$service_name --follow --since=-0 --quiet >"$templog" &
|
journalctl --unit=$service_name --follow --since=-0 --quiet > "$templog" &
|
||||||
# Get the PID of the journalctl command
|
# Get the PID of the journalctl command
|
||||||
local pid_tail=$!
|
local pid_tail=$!
|
||||||
else
|
else
|
||||||
# Read the specified log file
|
# Read the specified log file
|
||||||
tail --follow=name --retry --lines=0 "$log_path" >"$templog" 2>&1 &
|
tail --follow=name --retry --lines=0 "$log_path" > "$templog" 2>&1 &
|
||||||
# Get the PID of the tail command
|
# Get the PID of the tail command
|
||||||
local pid_tail=$!
|
local pid_tail=$!
|
||||||
fi
|
fi
|
||||||
|
@ -149,8 +149,7 @@ ynh_systemd_action() {
|
||||||
# Also check the timeout using actual timestamp, because sometimes for some reason,
|
# Also check the timeout using actual timestamp, because sometimes for some reason,
|
||||||
# journalctl may take a huge time to run, and we end up waiting literally an entire hour
|
# journalctl may take a huge time to run, and we end up waiting literally an entire hour
|
||||||
# instead of 5 min ...
|
# instead of 5 min ...
|
||||||
if [[ "$(( $(date +%s) - $starttime))" -gt "$timeout" ]]
|
if [[ "$(($(date +%s) - $starttime))" -gt "$timeout" ]]; then
|
||||||
then
|
|
||||||
i=$timeout
|
i=$timeout
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -17,7 +17,7 @@ ynh_system_user_exists() {
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
getent passwd "$username" &>/dev/null
|
getent passwd "$username" &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if a group exists on the system
|
# Check if a group exists on the system
|
||||||
|
@ -37,7 +37,7 @@ ynh_system_group_exists() {
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
getent group "$group" &>/dev/null
|
getent group "$group" &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
|
|
|
@ -39,11 +39,11 @@
|
||||||
# This option is meant for advanced use-cases where the "simple" templating
|
# This option is meant for advanced use-cases where the "simple" templating
|
||||||
# mode ain't enough because you need conditional blocks or loops.
|
# mode ain't enough because you need conditional blocks or loops.
|
||||||
#
|
#
|
||||||
# For a full documentation of jinja's syntax you can refer to:
|
# For a full documentation of jinja's syntax you can refer to:
|
||||||
# https://jinja.palletsprojects.com/en/3.1.x/templates/
|
# https://jinja.palletsprojects.com/en/3.1.x/templates/
|
||||||
#
|
#
|
||||||
# Note that in YunoHost context, all variables are from shell variables and therefore are strings
|
# Note that in YunoHost context, all variables are from shell variables and therefore are strings
|
||||||
#
|
#
|
||||||
# ##### Keeping track of manual changes by the admin
|
# ##### Keeping track of manual changes by the admin
|
||||||
#
|
#
|
||||||
# The helper will verify the checksum and backup the destination file
|
# The helper will verify the checksum and backup the destination file
|
||||||
|
@ -83,10 +83,9 @@ ynh_add_config() {
|
||||||
chmod 640 $destination
|
chmod 640 $destination
|
||||||
_ynh_apply_default_permissions $destination
|
_ynh_apply_default_permissions $destination
|
||||||
|
|
||||||
if [[ "$jinja" == 1 ]]
|
if [[ "$jinja" == 1 ]]; then
|
||||||
then
|
|
||||||
# This is ran in a subshell such that the "export" does not "contaminate" the main process
|
# This is ran in a subshell such that the "export" does not "contaminate" the main process
|
||||||
(
|
(
|
||||||
export $(compgen -v)
|
export $(compgen -v)
|
||||||
j2 "$template_path" -f env -o $destination
|
j2 "$template_path" -f env -o $destination
|
||||||
)
|
)
|
||||||
|
@ -267,7 +266,7 @@ ynh_read_var_in_file() {
|
||||||
var_part+='\s*'
|
var_part+='\s*'
|
||||||
|
|
||||||
# Extract the part after assignation sign
|
# Extract the part after assignation sign
|
||||||
local expression_with_comment="$((tail +$line_number ${file} | grep -i -o -P $var_part'\K.*$' || echo YNH_NULL) | head -n1)"
|
local expression_with_comment="$( (tail +$line_number ${file} | grep -i -o -P $var_part'\K.*$' || echo YNH_NULL) | head -n1)"
|
||||||
if [[ "$expression_with_comment" == "YNH_NULL" ]]; then
|
if [[ "$expression_with_comment" == "YNH_NULL" ]]; then
|
||||||
set -o xtrace # set -x
|
set -o xtrace # set -x
|
||||||
echo YNH_NULL
|
echo YNH_NULL
|
||||||
|
@ -346,7 +345,7 @@ ynh_write_var_in_file() {
|
||||||
var_part+='\s*'
|
var_part+='\s*'
|
||||||
|
|
||||||
# Extract the part after assignation sign
|
# Extract the part after assignation sign
|
||||||
local expression_with_comment="$((tail +$after_line_number ${file} | grep -i -o -P $var_part'\K.*$' || echo YNH_NULL) | head -n1)"
|
local expression_with_comment="$( (tail +$after_line_number ${file} | grep -i -o -P $var_part'\K.*$' || echo YNH_NULL) | head -n1)"
|
||||||
if [[ "$expression_with_comment" == "YNH_NULL" ]]; then
|
if [[ "$expression_with_comment" == "YNH_NULL" ]]; then
|
||||||
set -o xtrace # set -x
|
set -o xtrace # set -x
|
||||||
return 1
|
return 1
|
||||||
|
@ -403,5 +402,5 @@ ynh_render_template() {
|
||||||
# Taken from https://stackoverflow.com/a/35009576
|
# Taken from https://stackoverflow.com/a/35009576
|
||||||
python3 -c 'import os, sys, jinja2; sys.stdout.write(
|
python3 -c 'import os, sys, jinja2; sys.stdout.write(
|
||||||
jinja2.Template(sys.stdin.read()
|
jinja2.Template(sys.stdin.read()
|
||||||
).render(os.environ));' <$template_path >$output_path
|
).render(os.environ));' < $template_path > $output_path
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,8 +22,7 @@ YNH_APP_BASEDIR=${YNH_APP_BASEDIR:-$(realpath ..)}
|
||||||
ynh_exit_properly() {
|
ynh_exit_properly() {
|
||||||
local exit_code=$?
|
local exit_code=$?
|
||||||
|
|
||||||
if [[ "${YNH_APP_ACTION:-}" =~ ^install$|^upgrade$|^restore$ ]]
|
if [[ "${YNH_APP_ACTION:-}" =~ ^install$|^upgrade$|^restore$ ]]; then
|
||||||
then
|
|
||||||
rm -rf "/var/cache/yunohost/download/"
|
rm -rf "/var/cache/yunohost/download/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -39,7 +38,7 @@ ynh_exit_properly() {
|
||||||
# Small tempo to avoid the next message being mixed up with other DEBUG messages
|
# Small tempo to avoid the next message being mixed up with other DEBUG messages
|
||||||
sleep 0.5
|
sleep 0.5
|
||||||
|
|
||||||
if type -t ynh_clean_setup >/dev/null; then # Check if the function exist in the app script.
|
if type -t ynh_clean_setup > /dev/null; then # Check if the function exist in the app script.
|
||||||
ynh_clean_setup # Call the function to do specific cleaning for the app.
|
ynh_clean_setup # Call the function to do specific cleaning for the app.
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -67,8 +66,7 @@ ynh_abort_if_errors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# When running an app script with packaging format >= 2, auto-enable ynh_abort_if_errors except for remove script
|
# When running an app script with packaging format >= 2, auto-enable ynh_abort_if_errors except for remove script
|
||||||
if [[ "${YNH_CONTEXT:-}" != "regenconf" ]] && dpkg --compare-versions ${YNH_APP_PACKAGING_FORMAT:-0} ge 2 && [[ ${YNH_APP_ACTION} != "remove" ]]
|
if [[ "${YNH_CONTEXT:-}" != "regenconf" ]] && dpkg --compare-versions ${YNH_APP_PACKAGING_FORMAT:-0} ge 2 && [[ ${YNH_APP_ACTION} != "remove" ]]; then
|
||||||
then
|
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -149,8 +147,7 @@ _acceptable_path_to_delete() {
|
||||||
local forbidden_paths=$(ls -d / /* /{var,home,usr}/* /etc/{default,sudoers.d,yunohost,cron*} /etc/yunohost/{apps,domains,hooks.d} /opt/yunohost 2> /dev/null)
|
local forbidden_paths=$(ls -d / /* /{var,home,usr}/* /etc/{default,sudoers.d,yunohost,cron*} /etc/yunohost/{apps,domains,hooks.d} /opt/yunohost 2> /dev/null)
|
||||||
|
|
||||||
# Legacy : A couple apps still have data in /home/$app ...
|
# Legacy : A couple apps still have data in /home/$app ...
|
||||||
if [[ -n "${app:-}" ]]
|
if [[ -n "${app:-}" ]]; then
|
||||||
then
|
|
||||||
forbidden_paths=$(echo "$forbidden_paths" | grep -v "/home/$app")
|
forbidden_paths=$(echo "$forbidden_paths" | grep -v "/home/$app")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -215,19 +212,16 @@ ynh_read_manifest() {
|
||||||
|
|
||||||
if [ ! -e "${manifest:-}" ]; then
|
if [ ! -e "${manifest:-}" ]; then
|
||||||
# If the manifest isn't found, try the common place for backup and restore script.
|
# If the manifest isn't found, try the common place for backup and restore script.
|
||||||
if [ -e "$YNH_APP_BASEDIR/manifest.json" ]
|
if [ -e "$YNH_APP_BASEDIR/manifest.json" ]; then
|
||||||
then
|
|
||||||
manifest="$YNH_APP_BASEDIR/manifest.json"
|
manifest="$YNH_APP_BASEDIR/manifest.json"
|
||||||
elif [ -e "$YNH_APP_BASEDIR/manifest.toml" ]
|
elif [ -e "$YNH_APP_BASEDIR/manifest.toml" ]; then
|
||||||
then
|
|
||||||
manifest="$YNH_APP_BASEDIR/manifest.toml"
|
manifest="$YNH_APP_BASEDIR/manifest.toml"
|
||||||
else
|
else
|
||||||
ynh_die --message "No manifest found !?"
|
ynh_die --message "No manifest found !?"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo "$manifest" | grep -q '\.json$'
|
if echo "$manifest" | grep -q '\.json$'; then
|
||||||
then
|
|
||||||
jq ".$manifest_key" "$manifest" --raw-output
|
jq ".$manifest_key" "$manifest" --raw-output
|
||||||
else
|
else
|
||||||
cat "$manifest" | python3 -c 'import json, toml, sys; print(json.dumps(toml.load(sys.stdin)))' | jq ".$manifest_key" --raw-output
|
cat "$manifest" | python3 -c 'import json, toml, sys; print(json.dumps(toml.load(sys.stdin)))' | jq ".$manifest_key" --raw-output
|
||||||
|
@ -387,8 +381,7 @@ _ynh_apply_default_permissions() {
|
||||||
# Crons should be owned by root
|
# Crons should be owned by root
|
||||||
# Also we don't want systemd conf, nginx conf or others stuff to be owned by the app,
|
# Also we don't want systemd conf, nginx conf or others stuff to be owned by the app,
|
||||||
# otherwise they could self-edit their own systemd conf and escalate privilege
|
# otherwise they could self-edit their own systemd conf and escalate privilege
|
||||||
if grep -qE '^(/etc/cron|/etc/php|/etc/nginx/conf.d|/etc/fail2ban|/etc/systemd/system)' <<< "$target"
|
if grep -qE '^(/etc/cron|/etc/php|/etc/nginx/conf.d|/etc/fail2ban|/etc/systemd/system)' <<< "$target"; then
|
||||||
then
|
|
||||||
chmod 400 $target
|
chmod 400 $target
|
||||||
chown root:root $target
|
chown root:root $target
|
||||||
fi
|
fi
|
||||||
|
@ -419,7 +412,7 @@ ynh_user_exists() {
|
||||||
# Manage arguments with getopts
|
# Manage arguments with getopts
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
yunohost user list --output-as json --quiet | jq -e ".users.\"${username}\"" >/dev/null
|
yunohost user list --output-as json --quiet | jq -e ".users.\"${username}\"" > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Retrieve a YunoHost user information
|
# Retrieve a YunoHost user information
|
||||||
|
|
|
@ -4,9 +4,9 @@ YNH_APT_INSTALL_DEPENDENCIES_REPLACE="true"
|
||||||
|
|
||||||
# Define and install dependencies with a equivs control file
|
# Define and install dependencies with a equivs control file
|
||||||
#
|
#
|
||||||
# example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5"
|
# example : ynh_apt_install_dependencies dep1 dep2 "dep3|dep4|dep5"
|
||||||
#
|
#
|
||||||
# usage: ynh_install_app_dependencies dep [dep [...]]
|
# usage: ynh_apt_install_dependencies dep [dep [...]]
|
||||||
# | arg: dep - the package name to install in dependence.
|
# | arg: dep - the package name to install in dependence.
|
||||||
# | arg: "dep1|dep2|…" - You can specify alternatives. It will require to install (dep1 or dep2, etc).
|
# | arg: "dep1|dep2|…" - You can specify alternatives. It will require to install (dep1 or dep2, etc).
|
||||||
#
|
#
|
||||||
|
@ -39,8 +39,7 @@ ynh_apt_install_dependencies() {
|
||||||
# The (?<=php) syntax corresponds to lookbehind ;)
|
# The (?<=php) syntax corresponds to lookbehind ;)
|
||||||
local specific_php_version=$(grep -oP '(?<=php)[0-9.]+(?=-|\>|)' <<< "$dependencies" | sort -u)
|
local specific_php_version=$(grep -oP '(?<=php)[0-9.]+(?=-|\>|)' <<< "$dependencies" | sort -u)
|
||||||
|
|
||||||
if [[ -n "$specific_php_version" ]]
|
if [[ -n "$specific_php_version" ]]; then
|
||||||
then
|
|
||||||
# Cover a small edge case where a packager could have specified "php7.4-pwet php5-gni" which is confusing
|
# Cover a small edge case where a packager could have specified "php7.4-pwet php5-gni" which is confusing
|
||||||
[[ $(echo $specific_php_version | wc -l) -eq 1 ]] \
|
[[ $(echo $specific_php_version | wc -l) -eq 1 ]] \
|
||||||
|| ynh_die "Inconsistent php versions in dependencies ... found : $specific_php_version"
|
|| ynh_die "Inconsistent php versions in dependencies ... found : $specific_php_version"
|
||||||
|
@ -51,8 +50,7 @@ ynh_apt_install_dependencies() {
|
||||||
|
|
||||||
# If the PHP version changed, remove the old fpm conf
|
# If the PHP version changed, remove the old fpm conf
|
||||||
if [ -n "$old_php_version" ] && [ "$old_php_version" != "$specific_php_version" ]; then
|
if [ -n "$old_php_version" ] && [ "$old_php_version" != "$specific_php_version" ]; then
|
||||||
if [[ -f "/etc/php/$php_version/fpm/pool.d/$app.conf" ]]
|
if [[ -f "/etc/php/$php_version/fpm/pool.d/$app.conf" ]]; then
|
||||||
then
|
|
||||||
ynh_backup_if_checksum_is_different "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
ynh_backup_if_checksum_is_different "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||||
ynh_config_remove_phpfpm
|
ynh_config_remove_phpfpm
|
||||||
fi
|
fi
|
||||||
|
@ -61,8 +59,7 @@ ynh_apt_install_dependencies() {
|
||||||
ynh_app_setting_set --key=php_version --value=$specific_php_version
|
ynh_app_setting_set --key=php_version --value=$specific_php_version
|
||||||
|
|
||||||
# Set the default php version back as the default version for php-cli.
|
# Set the default php version back as the default version for php-cli.
|
||||||
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION; then
|
||||||
then
|
|
||||||
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
||||||
fi
|
fi
|
||||||
elif grep --quiet 'php' <<< "$dependencies"; then
|
elif grep --quiet 'php' <<< "$dependencies"; then
|
||||||
|
@ -72,18 +69,16 @@ ynh_apt_install_dependencies() {
|
||||||
# Specific tweak related to Postgresql (cf end of the helper)
|
# Specific tweak related to Postgresql (cf end of the helper)
|
||||||
local psql_installed="$(_ynh_apt_package_is_installed "postgresql-$PSQL_VERSION" && echo yes || echo no)"
|
local psql_installed="$(_ynh_apt_package_is_installed "postgresql-$PSQL_VERSION" && echo yes || echo no)"
|
||||||
|
|
||||||
# The first time we run ynh_install_app_dependencies, we will replace the
|
# The first time we run ynh_apt_install_dependencies, we will replace the
|
||||||
# entire control file (This is in particular meant to cover the case of
|
# entire control file (This is in particular meant to cover the case of
|
||||||
# upgrade script where ynh_install_app_dependencies is called with this
|
# upgrade script where ynh_apt_install_dependencies is called with this
|
||||||
# expected effect) Otherwise, any subsequent call will add dependencies
|
# expected effect) Otherwise, any subsequent call will add dependencies
|
||||||
# to those already present in the equivs control file.
|
# to those already present in the equivs control file.
|
||||||
if [[ $YNH_APT_INSTALL_DEPENDENCIES_REPLACE == "true" ]]
|
if [[ $YNH_APT_INSTALL_DEPENDENCIES_REPLACE == "true" ]]; then
|
||||||
then
|
|
||||||
YNH_APT_INSTALL_DEPENDENCIES_REPLACE="false"
|
YNH_APT_INSTALL_DEPENDENCIES_REPLACE="false"
|
||||||
else
|
else
|
||||||
local current_dependencies=""
|
local current_dependencies=""
|
||||||
if _ynh_apt_package_is_installed "${app_ynh_deps}"
|
if _ynh_apt_package_is_installed "${app_ynh_deps}"; then
|
||||||
then
|
|
||||||
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${app_ynh_deps}) "
|
current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${app_ynh_deps}) "
|
||||||
current_dependencies=${current_dependencies// | /|}
|
current_dependencies=${current_dependencies// | /|}
|
||||||
fi
|
fi
|
||||||
|
@ -100,7 +95,7 @@ ynh_apt_install_dependencies() {
|
||||||
# For some reason, dpkg-deb insists for folder perm to be 755 and sometimes it's 777 o_O?
|
# For some reason, dpkg-deb insists for folder perm to be 755 and sometimes it's 777 o_O?
|
||||||
chmod -R 755 ${TMPDIR}/${app_ynh_deps}
|
chmod -R 755 ${TMPDIR}/${app_ynh_deps}
|
||||||
|
|
||||||
cat >${TMPDIR}/${app_ynh_deps}/DEBIAN/control <<EOF
|
cat > ${TMPDIR}/${app_ynh_deps}/DEBIAN/control << EOF
|
||||||
Section: misc
|
Section: misc
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Package: ${app_ynh_deps}
|
Package: ${app_ynh_deps}
|
||||||
|
@ -145,8 +140,7 @@ EOF
|
||||||
# Specific tweak related to Postgresql
|
# Specific tweak related to Postgresql
|
||||||
# -> trigger postgresql regenconf if we may have just installed postgresql
|
# -> trigger postgresql regenconf if we may have just installed postgresql
|
||||||
local psql_installed2="$(_ynh_apt_package_is_installed "postgresql-$PSQL_VERSION" && echo yes || echo no)"
|
local psql_installed2="$(_ynh_apt_package_is_installed "postgresql-$PSQL_VERSION" && echo yes || echo no)"
|
||||||
if [[ "$psql_installed" != "$psql_installed2" ]]
|
if [[ "$psql_installed" != "$psql_installed2" ]]; then
|
||||||
then
|
|
||||||
yunohost tools regen-conf postgresql
|
yunohost tools regen-conf postgresql
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -168,16 +162,14 @@ ynh_apt_remove_dependencies() {
|
||||||
|
|
||||||
# Edge case where the app dep may be on hold,
|
# Edge case where the app dep may be on hold,
|
||||||
# cf https://forum.yunohost.org/t/migration-error-cause-of-ffsync/20675/4
|
# cf https://forum.yunohost.org/t/migration-error-cause-of-ffsync/20675/4
|
||||||
if apt-mark showhold | grep -q -w ${app_ynh_deps}
|
if apt-mark showhold | grep -q -w ${app_ynh_deps}; then
|
||||||
then
|
|
||||||
apt-mark unhold ${app_ynh_deps}
|
apt-mark unhold ${app_ynh_deps}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Remove the fake package and its dependencies if they not still used.
|
# Remove the fake package and its dependencies if they not still used.
|
||||||
# (except if dpkg doesn't know anything about the package,
|
# (except if dpkg doesn't know anything about the package,
|
||||||
# which should be symptomatic of a failed install, and we don't want bash to report an error)
|
# which should be symptomatic of a failed install, and we don't want bash to report an error)
|
||||||
if dpkg-query --show ${app_ynh_deps} &>/dev/null
|
if dpkg-query --show ${app_ynh_deps} &> /dev/null; then
|
||||||
then
|
|
||||||
_ynh_apt autoremove --purge ${app_ynh_deps}
|
_ynh_apt autoremove --purge ${app_ynh_deps}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -206,11 +198,13 @@ ynh_apt_install_dependencies_from_extra_repository() {
|
||||||
if [[ "${repo_parts[0]}" == "deb" ]]; then
|
if [[ "${repo_parts[0]}" == "deb" ]]; then
|
||||||
index=1
|
index=1
|
||||||
fi
|
fi
|
||||||
uri="${repo_parts[$index]}" ; index=$((index+1))
|
uri="${repo_parts[$index]}"
|
||||||
suite="${repo_parts[$index]}" ; index=$((index+1))
|
index=$((index + 1))
|
||||||
|
suite="${repo_parts[$index]}"
|
||||||
|
index=$((index + 1))
|
||||||
|
|
||||||
# Get the components
|
# Get the components
|
||||||
if (( "${#repo_parts[@]}" > 0 )); then
|
if (("${#repo_parts[@]}" > 0)); then
|
||||||
component="${repo_parts[*]:$index}"
|
component="${repo_parts[*]:$index}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -280,7 +274,7 @@ _ynh_wait_dpkg_free() {
|
||||||
# With seq 1 17, timeout will be almost 30 minutes
|
# With seq 1 17, timeout will be almost 30 minutes
|
||||||
for try in $(seq 1 17); do
|
for try in $(seq 1 17); do
|
||||||
# Check if /var/lib/dpkg/lock is used by another process
|
# Check if /var/lib/dpkg/lock is used by another process
|
||||||
if lsof /var/lib/dpkg/lock >/dev/null; then
|
if lsof /var/lib/dpkg/lock > /dev/null; then
|
||||||
echo "apt is already in use..."
|
echo "apt is already in use..."
|
||||||
# Sleep an exponential time at each round
|
# Sleep an exponential time at each round
|
||||||
sleep $((try * try))
|
sleep $((try * try))
|
||||||
|
@ -298,7 +292,7 @@ _ynh_wait_dpkg_free() {
|
||||||
set -o xtrace # set -x
|
set -o xtrace # set -x
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
done 9<<<"$(ls -1 $dpkg_dir)"
|
done 9<<< "$(ls -1 $dpkg_dir)"
|
||||||
set -o xtrace # set -x
|
set -o xtrace # set -x
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
@ -310,14 +304,14 @@ _ynh_wait_dpkg_free() {
|
||||||
# Check either a package is installed or not
|
# Check either a package is installed or not
|
||||||
_ynh_apt_package_is_installed() {
|
_ynh_apt_package_is_installed() {
|
||||||
local package=$1
|
local package=$1
|
||||||
dpkg-query --show --showformat='${db:Status-Status}' "$package" 2>/dev/null \
|
dpkg-query --show --showformat='${db:Status-Status}' "$package" 2> /dev/null \
|
||||||
| grep --quiet "^installed$" &>/dev/null
|
| grep --quiet "^installed$" &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Return the installed version of an apt package, if installed
|
# Return the installed version of an apt package, if installed
|
||||||
_ynh_apt_package_version() {
|
_ynh_apt_package_version() {
|
||||||
if _ynh_apt_package_is_installed "$package"; then
|
if _ynh_apt_package_is_installed "$package"; then
|
||||||
dpkg-query --show --showformat='${Version}' "$package" 2>/dev/null
|
dpkg-query --show --showformat='${Version}' "$package" 2> /dev/null
|
||||||
else
|
else
|
||||||
echo ''
|
echo ''
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -27,13 +27,11 @@ ynh_backup() {
|
||||||
local is_data=false
|
local is_data=false
|
||||||
|
|
||||||
# If the path starts with /var/log/$app or $data_dir
|
# If the path starts with /var/log/$app or $data_dir
|
||||||
if ([[ -n "${app:-}" ]] && [[ "$target" == "/var/log/$app*" ]]) || ([[ -n "${data_dir:-}" ]] && [[ "$target" == "$data_dir*" ]])
|
if ([[ -n "${app:-}" ]] && [[ "$target" == "/var/log/$app*" ]]) || ([[ -n "${data_dir:-}" ]] && [[ "$target" == "$data_dir*" ]]); then
|
||||||
then
|
|
||||||
is_data=true
|
is_data=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${app:-}" ]]
|
if [[ -n "${app:-}" ]]; then
|
||||||
then
|
|
||||||
local do_not_backup_data=$(ynh_app_setting_get --key=do_not_backup_data)
|
local do_not_backup_data=$(ynh_app_setting_get --key=do_not_backup_data)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -83,7 +81,7 @@ ynh_backup() {
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
local src=$(echo "${src_path}" | sed --regexp-extended 's/"/\"\"/g')
|
local src=$(echo "${src_path}" | sed --regexp-extended 's/"/\"\"/g')
|
||||||
local dest=$(echo "${dest_path}" | sed --regexp-extended 's/"/\"\"/g')
|
local dest=$(echo "${dest_path}" | sed --regexp-extended 's/"/\"\"/g')
|
||||||
echo "\"${src}\",\"${dest}\"" >>"${YNH_BACKUP_CSV}"
|
echo "\"${src}\",\"${dest}\"" >> "${YNH_BACKUP_CSV}"
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
|
@ -135,15 +133,13 @@ ynh_restore() {
|
||||||
|
|
||||||
# If the path starts with /var/log/$app or $data_dir
|
# If the path starts with /var/log/$app or $data_dir
|
||||||
local is_data=false
|
local is_data=false
|
||||||
if ([[ -n "${app:-}" ]] && [[ "$target" == "/var/log/$app*" ]]) || ([[ -n "${data_dir:-}" ]] && [[ "$target" == "$data_dir*" ]])
|
if ([[ -n "${app:-}" ]] && [[ "$target" == "/var/log/$app*" ]]) || ([[ -n "${data_dir:-}" ]] && [[ "$target" == "$data_dir*" ]]); then
|
||||||
then
|
|
||||||
is_data=true
|
is_data=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If archive_path doesn't exist, search for a corresponding path in CSV
|
# If archive_path doesn't exist, search for a corresponding path in CSV
|
||||||
if [ ! -d "$archive_path" ] && [ ! -f "$archive_path" ] && [ ! -L "$archive_path" ]; then
|
if [ ! -d "$archive_path" ] && [ ! -f "$archive_path" ] && [ ! -L "$archive_path" ]; then
|
||||||
if [[ "$is_data" == true ]]
|
if [[ "$is_data" == true ]]; then
|
||||||
then
|
|
||||||
ynh_print_info "Skipping $target which doesn't exists in the archive, probably because restoring from a safety-backup-before-upgrade"
|
ynh_print_info "Skipping $target which doesn't exists in the archive, probably because restoring from a safety-backup-before-upgrade"
|
||||||
# Assume it's not a big deal, we may be restoring a safety-backup-before-upgrade which doesnt contain those
|
# Assume it's not a big deal, we may be restoring a safety-backup-before-upgrade which doesnt contain those
|
||||||
return 0
|
return 0
|
||||||
|
@ -194,7 +190,7 @@ ynh_restore_everything() {
|
||||||
# For each destination path begining by $REL_DIR
|
# For each destination path begining by $REL_DIR
|
||||||
cat ${YNH_BACKUP_CSV} | tr --delete $'\r' | grep --only-matching --no-filename --perl-regexp "^\".*\",\"$REL_DIR.*\"$" \
|
cat ${YNH_BACKUP_CSV} | tr --delete $'\r' | grep --only-matching --no-filename --perl-regexp "^\".*\",\"$REL_DIR.*\"$" \
|
||||||
| while read line; do
|
| while read line; do
|
||||||
local ARCHIVE_PATH=$(echo "$line" | grep --only-matching --no-filename --perl-regexp "^\".*\",\"$REL_DIR\K.*(?=\"$)")
|
local ARCHIVE_PATH=$(echo "$line" | grep --only-matching --no-filename --perl-regexp "^\"\K.*(?=\",\"$REL_DIR.*\"$)")
|
||||||
ynh_restore "$ARCHIVE_PATH"
|
ynh_restore "$ARCHIVE_PATH"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -256,8 +252,7 @@ ynh_backup_if_checksum_is_different() {
|
||||||
echo "$backup_file_checksum" # Return the name of the backup file
|
echo "$backup_file_checksum" # Return the name of the backup file
|
||||||
if ynh_in_ci_tests; then
|
if ynh_in_ci_tests; then
|
||||||
local file_path_base64=$(echo "$file" | base64 -w0)
|
local file_path_base64=$(echo "$file" | base64 -w0)
|
||||||
if test -e /var/cache/yunohost/appconfbackup/original_${file_path_base64}
|
if test -e /var/cache/yunohost/appconfbackup/original_${file_path_base64}; then
|
||||||
then
|
|
||||||
ynh_print_warn "Diff with the original file:"
|
ynh_print_warn "Diff with the original file:"
|
||||||
diff --report-identical-files --unified --color=always /var/cache/yunohost/appconfbackup/original_${file_path_base64} $file >&2 || true
|
diff --report-identical-files --unified --color=always /var/cache/yunohost/appconfbackup/original_${file_path_base64} $file >&2 || true
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -38,8 +38,8 @@ ynh_composer_exec() {
|
||||||
local workdir="${composer_workdir:-$install_dir}"
|
local workdir="${composer_workdir:-$install_dir}"
|
||||||
|
|
||||||
COMPOSER_HOME="$workdir/.composer" \
|
COMPOSER_HOME="$workdir/.composer" \
|
||||||
COMPOSER_MEMORY_LIMIT=-1 \
|
COMPOSER_MEMORY_LIMIT=-1 \
|
||||||
sudo -E -u "${composer_user:-$app}" \
|
sudo -E -u "${composer_user:-$app}" \
|
||||||
php${php_version} "$workdir/composer.phar" $@ \
|
php${php_version} "$workdir/composer.phar" $@ \
|
||||||
-d "$workdir" --no-interaction --no-ansi 2>&1
|
-d "$workdir" --no-interaction --no-ansi 2>&1
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,11 @@ _ynh_app_config_get_one() {
|
||||||
local bind="$3"
|
local bind="$3"
|
||||||
local getter="get__${short_setting}"
|
local getter="get__${short_setting}"
|
||||||
# Get value from getter if exists
|
# Get value from getter if exists
|
||||||
if type -t $getter 2>/dev/null | grep -q '^function$' 2>/dev/null; then
|
if type -t $getter 2> /dev/null | grep -q '^function$' 2> /dev/null; then
|
||||||
old[$short_setting]="$($getter)"
|
old[$short_setting]="$($getter)"
|
||||||
formats[${short_setting}]="yaml"
|
formats[${short_setting}]="yaml"
|
||||||
|
|
||||||
elif [[ "$bind" == *"("* ]] && type -t "get__${bind%%(*}" 2>/dev/null | grep -q '^function$' 2>/dev/null; then
|
elif [[ "$bind" == *"("* ]] && type -t "get__${bind%%(*}" 2> /dev/null | grep -q '^function$' 2> /dev/null; then
|
||||||
old[$short_setting]="$("get__${bind%%(*}" $short_setting $type $bind)"
|
old[$short_setting]="$("get__${bind%%(*}" $short_setting $type $bind)"
|
||||||
formats[${short_setting}]="yaml"
|
formats[${short_setting}]="yaml"
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ _ynh_app_config_get_one() {
|
||||||
if [[ "$bind" == "settings" ]]; then
|
if [[ "$bind" == "settings" ]]; then
|
||||||
ynh_die "File '${short_setting}' can't be stored in settings"
|
ynh_die "File '${short_setting}' can't be stored in settings"
|
||||||
fi
|
fi
|
||||||
old[$short_setting]="$(ls "$(echo $bind | sed s@__INSTALL_DIR__@${install_dir:-}@ | sed s/__APP__/$app/)" 2>/dev/null || echo YNH_NULL)"
|
old[$short_setting]="$(ls "$bind" 2> /dev/null || echo YNH_NULL)"
|
||||||
file_hash[$short_setting]="true"
|
file_hash[$short_setting]="true"
|
||||||
|
|
||||||
# Get multiline text from settings or from a full file
|
# Get multiline text from settings or from a full file
|
||||||
|
@ -32,7 +32,7 @@ _ynh_app_config_get_one() {
|
||||||
elif [[ "$bind" == *":"* ]]; then
|
elif [[ "$bind" == *":"* ]]; then
|
||||||
ynh_die "For technical reasons, multiline text '${short_setting}' can't be stored automatically in a variable file, you have to create custom getter/setter"
|
ynh_die "For technical reasons, multiline text '${short_setting}' can't be stored automatically in a variable file, you have to create custom getter/setter"
|
||||||
else
|
else
|
||||||
old[$short_setting]="$(cat $(echo $bind | sed s@__INSTALL_DIR__@${install_dir:-}@ | sed s/__APP__/$app/) 2>/dev/null || echo YNH_NULL)"
|
old[$short_setting]="$(cat "$bind" 2> /dev/null || echo YNH_NULL)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get value from a kind of key/value file
|
# Get value from a kind of key/value file
|
||||||
|
@ -47,7 +47,7 @@ _ynh_app_config_get_one() {
|
||||||
bind_after="$(echo "${bind_key_}" | cut -d'>' -f1)"
|
bind_after="$(echo "${bind_key_}" | cut -d'>' -f1)"
|
||||||
bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)"
|
bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)"
|
||||||
fi
|
fi
|
||||||
local bind_file="$(echo "$bind" | cut -d: -f2 | sed s@__INSTALL_DIR__@${install_dir:-}@ | sed s/__APP__/$app/)"
|
local bind_file="$(echo "$bind" | cut -d: -f2)"
|
||||||
old[$short_setting]="$(ynh_read_var_in_file --file="${bind_file}" --key="${bind_key_}" --after="${bind_after}")"
|
old[$short_setting]="$(ynh_read_var_in_file --file="${bind_file}" --key="${bind_key_}" --after="${bind_after}")"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -59,10 +59,10 @@ _ynh_app_config_apply_one() {
|
||||||
local type="${types[$short_setting]}"
|
local type="${types[$short_setting]}"
|
||||||
if [ "${changed[$short_setting]}" == "true" ]; then
|
if [ "${changed[$short_setting]}" == "true" ]; then
|
||||||
# Apply setter if exists
|
# Apply setter if exists
|
||||||
if type -t $setter 2>/dev/null | grep -q '^function$' 2>/dev/null; then
|
if type -t $setter 2> /dev/null | grep -q '^function$' 2> /dev/null; then
|
||||||
$setter
|
$setter
|
||||||
|
|
||||||
elif [[ "$bind" == *"("* ]] && type -t "set__${bind%%(*}" 2>/dev/null | grep -q '^function$' 2>/dev/null; then
|
elif [[ "$bind" == *"("* ]] && type -t "set__${bind%%(*}" 2> /dev/null | grep -q '^function$' 2> /dev/null; then
|
||||||
"set__${bind%%(*}" $short_setting $type $bind
|
"set__${bind%%(*}" $short_setting $type $bind
|
||||||
|
|
||||||
elif [[ "$bind" == "null" ]]; then
|
elif [[ "$bind" == "null" ]]; then
|
||||||
|
@ -73,7 +73,7 @@ _ynh_app_config_apply_one() {
|
||||||
if [[ "$bind" == "settings" ]]; then
|
if [[ "$bind" == "settings" ]]; then
|
||||||
ynh_die "File '${short_setting}' can't be stored in settings"
|
ynh_die "File '${short_setting}' can't be stored in settings"
|
||||||
fi
|
fi
|
||||||
local bind_file="$(echo "$bind" | sed s@__INSTALL_DIR__@${install_dir:-}@ | sed s/__APP__/$app/)"
|
local bind_file="$bind"
|
||||||
if [[ "${!short_setting}" == "" ]]; then
|
if [[ "${!short_setting}" == "" ]]; then
|
||||||
ynh_backup_if_checksum_is_different "$bind_file"
|
ynh_backup_if_checksum_is_different "$bind_file"
|
||||||
ynh_safe_rm "$bind_file"
|
ynh_safe_rm "$bind_file"
|
||||||
|
@ -84,8 +84,7 @@ _ynh_app_config_apply_one() {
|
||||||
if [[ "${!short_setting}" != "$bind_file" ]]; then
|
if [[ "${!short_setting}" != "$bind_file" ]]; then
|
||||||
cp "${!short_setting}" "$bind_file"
|
cp "${!short_setting}" "$bind_file"
|
||||||
fi
|
fi
|
||||||
if _ynh_file_checksum_exists "$bind_file"
|
if _ynh_file_checksum_exists "$bind_file"; then
|
||||||
then
|
|
||||||
ynh_store_file_checksum "$bind_file"
|
ynh_store_file_checksum "$bind_file"
|
||||||
fi
|
fi
|
||||||
ynh_print_info "File '$bind_file' overwritten with ${!short_setting}"
|
ynh_print_info "File '$bind_file' overwritten with ${!short_setting}"
|
||||||
|
@ -101,11 +100,10 @@ _ynh_app_config_apply_one() {
|
||||||
if [[ "$bind" == *":"* ]]; then
|
if [[ "$bind" == *":"* ]]; then
|
||||||
ynh_die "For technical reasons, multiline text '${short_setting}' can't be stored automatically in a variable file, you have to create custom getter/setter"
|
ynh_die "For technical reasons, multiline text '${short_setting}' can't be stored automatically in a variable file, you have to create custom getter/setter"
|
||||||
fi
|
fi
|
||||||
local bind_file="$(echo "$bind" | sed s@__INSTALL_DIR__@${install_dir:-}@ | sed s/__APP__/$app/)"
|
local bind_file="$bind"
|
||||||
ynh_backup_if_checksum_is_different "$bind_file"
|
ynh_backup_if_checksum_is_different "$bind_file"
|
||||||
echo "${!short_setting}" >"$bind_file"
|
echo "${!short_setting}" > "$bind_file"
|
||||||
if _ynh_file_checksum_exists "$bind_file"
|
if _ynh_file_checksum_exists "$bind_file"; then
|
||||||
then
|
|
||||||
ynh_store_file_checksum "$bind_file"
|
ynh_store_file_checksum "$bind_file"
|
||||||
fi
|
fi
|
||||||
ynh_print_info "File '$bind_file' overwritten with the content provided in question '${short_setting}'"
|
ynh_print_info "File '$bind_file' overwritten with the content provided in question '${short_setting}'"
|
||||||
|
@ -119,12 +117,11 @@ _ynh_app_config_apply_one() {
|
||||||
bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)"
|
bind_key_="$(echo "${bind_key_}" | cut -d'>' -f2)"
|
||||||
fi
|
fi
|
||||||
bind_key_=${bind_key_:-$short_setting}
|
bind_key_=${bind_key_:-$short_setting}
|
||||||
local bind_file="$(echo "$bind" | cut -d: -f2 | sed s@__INSTALL_DIR__@${install_dir:-}@ | sed s/__APP__/$app/)"
|
local bind_file="$(echo "$bind" | cut -d: -f2)"
|
||||||
|
|
||||||
ynh_backup_if_checksum_is_different "$bind_file"
|
ynh_backup_if_checksum_is_different "$bind_file"
|
||||||
ynh_write_var_in_file --file="${bind_file}" --key="${bind_key_}" --value="${!short_setting}" --after="${bind_after}"
|
ynh_write_var_in_file --file="${bind_file}" --key="${bind_key_}" --value="${!short_setting}" --after="${bind_after}"
|
||||||
if _ynh_file_checksum_exists "$bind_file"
|
if _ynh_file_checksum_exists "$bind_file"; then
|
||||||
then
|
|
||||||
ynh_store_file_checksum "$bind_file"
|
ynh_store_file_checksum "$bind_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -135,69 +132,17 @@ _ynh_app_config_apply_one() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
_ynh_app_config_get() {
|
_ynh_app_config_get() {
|
||||||
# From settings
|
for line in $YNH_APP_CONFIG_PANEL_OPTIONS_TYPES_AND_BINDS; do
|
||||||
local lines
|
|
||||||
lines=$(
|
|
||||||
python3 <<EOL
|
|
||||||
import toml
|
|
||||||
from collections import OrderedDict
|
|
||||||
with open("../config_panel.toml", "r") as f:
|
|
||||||
file_content = f.read()
|
|
||||||
loaded_toml = toml.loads(file_content, _dict=OrderedDict)
|
|
||||||
|
|
||||||
for panel_name, panel in loaded_toml.items():
|
|
||||||
if not isinstance(panel, dict): continue
|
|
||||||
bind_panel = panel.get('bind')
|
|
||||||
for section_name, section in panel.items():
|
|
||||||
if not isinstance(section, dict): continue
|
|
||||||
bind_section = section.get('bind')
|
|
||||||
if not bind_section:
|
|
||||||
bind_section = bind_panel
|
|
||||||
elif bind_section[-1] == ":" and bind_panel and ":" in bind_panel:
|
|
||||||
regex, bind_panel_file = bind_panel.split(":")
|
|
||||||
if ">" in bind_section:
|
|
||||||
bind_section = bind_section + bind_panel_file
|
|
||||||
else:
|
|
||||||
bind_section = regex + bind_section + bind_panel_file
|
|
||||||
|
|
||||||
for name, param in section.items():
|
|
||||||
if not isinstance(param, dict):
|
|
||||||
continue
|
|
||||||
|
|
||||||
bind = param.get('bind')
|
|
||||||
|
|
||||||
if not bind:
|
|
||||||
if bind_section:
|
|
||||||
bind = bind_section
|
|
||||||
else:
|
|
||||||
bind = 'settings'
|
|
||||||
elif bind[-1] == ":" and bind_section and ":" in bind_section:
|
|
||||||
regex, bind_file = bind_section.split(":")
|
|
||||||
if ">" in bind:
|
|
||||||
bind = bind + bind_file
|
|
||||||
else:
|
|
||||||
bind = regex + bind + bind_file
|
|
||||||
if bind == "settings" and param.get('type', 'string') == 'file':
|
|
||||||
bind = 'null'
|
|
||||||
|
|
||||||
print('|'.join([
|
|
||||||
name,
|
|
||||||
param.get('type', 'string'),
|
|
||||||
bind
|
|
||||||
]))
|
|
||||||
EOL
|
|
||||||
)
|
|
||||||
for line in $lines; do
|
|
||||||
# Split line into short_setting, type and bind
|
# Split line into short_setting, type and bind
|
||||||
IFS='|' read short_setting type bind <<<"$line"
|
IFS='|' read short_setting type bind <<< "$line"
|
||||||
binds[${short_setting}]="$bind"
|
binds[${short_setting}]="$bind"
|
||||||
types[${short_setting}]="$type"
|
types[${short_setting}]="$type"
|
||||||
file_hash[${short_setting}]=""
|
file_hash[${short_setting}]=""
|
||||||
formats[${short_setting}]=""
|
formats[${short_setting}]=""
|
||||||
ynh_app_config_get_one $short_setting $type $bind
|
ynh_app_config_get_one $short_setting $type $bind
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_ynh_app_config_apply() {
|
_ynh_app_config_apply() {
|
||||||
|
@ -267,9 +212,9 @@ _ynh_app_config_validate() {
|
||||||
for short_setting in "${!old[@]}"; do
|
for short_setting in "${!old[@]}"; do
|
||||||
[[ "${changed[$short_setting]}" == "false" ]] && continue
|
[[ "${changed[$short_setting]}" == "false" ]] && continue
|
||||||
local result=""
|
local result=""
|
||||||
if type -t validate__$short_setting | grep -q '^function$' 2>/dev/null; then
|
if type -t validate__$short_setting | grep -q '^function$' 2> /dev/null; then
|
||||||
result="$(validate__$short_setting)"
|
result="$(validate__$short_setting)"
|
||||||
elif [[ "$bind" == *"("* ]] && type -t "validate__${bind%%(*}" 2>/dev/null | grep -q '^function$' 2>/dev/null; then
|
elif [[ "$bind" == *"("* ]] && type -t "validate__${bind%%(*}" 2> /dev/null | grep -q '^function$' 2> /dev/null; then
|
||||||
"validate__${bind%%(*}" $short_setting
|
"validate__${bind%%(*}" $short_setting
|
||||||
fi
|
fi
|
||||||
if [ -n "$result" ]; then
|
if [ -n "$result" ]; then
|
||||||
|
@ -324,7 +269,7 @@ ynh_app_config_apply() {
|
||||||
ynh_app_action_run() {
|
ynh_app_action_run() {
|
||||||
local runner="run__$1"
|
local runner="run__$1"
|
||||||
# Get value from getter if exists
|
# Get value from getter if exists
|
||||||
if type -t "$runner" 2>/dev/null | grep -q '^function$' 2>/dev/null; then
|
if type -t "$runner" 2> /dev/null | grep -q '^function$' 2> /dev/null; then
|
||||||
$runner
|
$runner
|
||||||
#ynh_return "result:"
|
#ynh_return "result:"
|
||||||
#ynh_return "$(echo "${result}" | sed 's/^/ /g')"
|
#ynh_return "$(echo "${result}" | sed 's/^/ /g')"
|
||||||
|
@ -342,22 +287,23 @@ ynh_app_config_run() {
|
||||||
declare -Ag formats=()
|
declare -Ag formats=()
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
show)
|
show)
|
||||||
ynh_app_config_get
|
ynh_app_config_get
|
||||||
ynh_app_config_show
|
ynh_app_config_show
|
||||||
;;
|
;;
|
||||||
apply)
|
apply)
|
||||||
max_progression=4
|
max_progression=4
|
||||||
ynh_script_progression "Reading config panel description and current configuration..."
|
ynh_script_progression "Reading config panel description and current configuration..."
|
||||||
ynh_app_config_get
|
ynh_app_config_get
|
||||||
|
|
||||||
ynh_app_config_validate
|
ynh_app_config_validate
|
||||||
|
|
||||||
ynh_script_progression "Applying the new configuration..."
|
ynh_script_progression "Applying the new configuration..."
|
||||||
ynh_app_config_apply
|
ynh_app_config_apply
|
||||||
ynh_script_progression "Configuration of $app completed"
|
ynh_script_progression "Configuration of $app completed"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
ynh_app_action_run $1
|
ynh_app_action_run $1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ port = http,https
|
||||||
filter = __APP__
|
filter = __APP__
|
||||||
logpath = __LOGPATH__
|
logpath = __LOGPATH__
|
||||||
maxretry = 5
|
maxretry = 5
|
||||||
" >"$YNH_APP_BASEDIR/conf/f2b_jail.conf"
|
" > "$YNH_APP_BASEDIR/conf/f2b_jail.conf"
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
[INCLUDES]
|
[INCLUDES]
|
||||||
|
@ -76,7 +76,7 @@ before = common.conf
|
||||||
[Definition]
|
[Definition]
|
||||||
failregex = __FAILREGEX__
|
failregex = __FAILREGEX__
|
||||||
ignoreregex =
|
ignoreregex =
|
||||||
" >"$YNH_APP_BASEDIR/conf/f2b_filter.conf"
|
" > "$YNH_APP_BASEDIR/conf/f2b_filter.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_config_add --template="f2b_jail.conf" --destination="/etc/fail2ban/jail.d/$app.conf"
|
ynh_config_add --template="f2b_jail.conf" --destination="/etc/fail2ban/jail.d/$app.conf"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
# | arg: $@ - Simply "$@" to tranfert all the positionnal arguments to the function
|
# | arg: $@ - Simply "$@" to tranfert all the positionnal arguments to the function
|
||||||
#
|
#
|
||||||
# This helper need an array, named "args_array" with all the arguments used by the helper
|
# This helper need an array, named "args_array" with all the arguments used by the helper
|
||||||
# that want to use ynh_handle_getopts_args
|
# that want to use ynh_handle_getopts_args
|
||||||
# Be carreful, this array has to be an associative array, as the following example:
|
# Be carreful, this array has to be an associative array, as the following example:
|
||||||
# local -A args_array=( [a]=arg1 [b]=arg2= [c]=arg3 )
|
# local -A args_array=( [a]=arg1 [b]=arg2= [c]=arg3 )
|
||||||
# Let's explain this array:
|
# Let's explain this array:
|
||||||
|
@ -50,8 +50,7 @@ ynh_handle_getopts_args() {
|
||||||
eval "$xtrace_enable"
|
eval "$xtrace_enable"
|
||||||
return
|
return
|
||||||
# Validate that the first char is - because it should be something like --option=value or -o ...
|
# Validate that the first char is - because it should be something like --option=value or -o ...
|
||||||
elif [[ "${1:0:1}" != "-" ]]
|
elif [[ "${1:0:1}" != "-" ]]; then
|
||||||
then
|
|
||||||
ynh_die "It looks like you called the helper using positional arguments instead of keyword arguments ?"
|
ynh_die "It looks like you called the helper using positional arguments instead of keyword arguments ?"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -182,6 +181,6 @@ ynh_handle_getopts_args() {
|
||||||
|
|
||||||
# Call parse_arg and pass the modified list of args as an array of arguments.
|
# Call parse_arg and pass the modified list of args as an array of arguments.
|
||||||
parse_arg "${arguments[@]}"
|
parse_arg "${arguments[@]}"
|
||||||
|
|
||||||
eval "$xtrace_enable"
|
eval "$xtrace_enable"
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ _ynh_load_go_in_path_and_other_tweaks() {
|
||||||
|
|
||||||
# Sets the local application-specific go version
|
# Sets the local application-specific go version
|
||||||
pushd ${install_dir}
|
pushd ${install_dir}
|
||||||
$GOENV_INSTALL_DIR/bin/goenv local $go_version
|
$GOENV_INSTALL_DIR/bin/goenv local $go_version
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ _ynh_load_go_in_path_and_other_tweaks() {
|
||||||
# - `$go_dir` (the directory containing the specific go version)
|
# - `$go_dir` (the directory containing the specific go version)
|
||||||
#
|
#
|
||||||
# This helper also creates a /etc/profile.d/goenv.sh that configures PATH environment for goenv
|
# This helper also creates a /etc/profile.d/goenv.sh that configures PATH environment for goenv
|
||||||
ynh_go_install () {
|
ynh_go_install() {
|
||||||
|
|
||||||
[[ -n "${go_version:-}" ]] || ynh_die "\$go_version should be defined prior to calling ynh_go_install"
|
[[ -n "${go_version:-}" ]] || ynh_die "\$go_version should be defined prior to calling ynh_go_install"
|
||||||
|
|
||||||
|
@ -55,33 +55,33 @@ ynh_go_install () {
|
||||||
# Install or update goenv
|
# Install or update goenv
|
||||||
mkdir -p $GOENV_INSTALL_DIR
|
mkdir -p $GOENV_INSTALL_DIR
|
||||||
pushd "$GOENV_INSTALL_DIR"
|
pushd "$GOENV_INSTALL_DIR"
|
||||||
if ! [ -x "$GOENV_INSTALL_DIR/bin/goenv" ]; then
|
if ! [ -x "$GOENV_INSTALL_DIR/bin/goenv" ]; then
|
||||||
ynh_print_info "Downloading goenv..."
|
ynh_print_info "Downloading goenv..."
|
||||||
git init -q
|
git init -q
|
||||||
git remote add origin https://github.com/syndbg/goenv.git
|
git remote add origin https://github.com/syndbg/goenv.git
|
||||||
else
|
else
|
||||||
ynh_print_info "Updating goenv..."
|
ynh_print_info "Updating goenv..."
|
||||||
fi
|
fi
|
||||||
git fetch -q --tags --prune origin
|
git fetch -q --tags --prune origin
|
||||||
local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
||||||
git checkout -q "$git_latest_tag"
|
git checkout -q "$git_latest_tag"
|
||||||
_ynh_go_try_bash_extension
|
_ynh_go_try_bash_extension
|
||||||
goenv=$GOENV_INSTALL_DIR/bin/goenv
|
goenv=$GOENV_INSTALL_DIR/bin/goenv
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Install or update xxenv-latest
|
# Install or update xxenv-latest
|
||||||
mkdir -p "$GOENV_INSTALL_DIR/plugins/xxenv-latest"
|
mkdir -p "$GOENV_INSTALL_DIR/plugins/xxenv-latest"
|
||||||
pushd "$GOENV_INSTALL_DIR/plugins/xxenv-latest"
|
pushd "$GOENV_INSTALL_DIR/plugins/xxenv-latest"
|
||||||
if ! [ -x "$GOENV_INSTALL_DIR/plugins/xxenv-latest/bin/goenv-latest" ]; then
|
if ! [ -x "$GOENV_INSTALL_DIR/plugins/xxenv-latest/bin/goenv-latest" ]; then
|
||||||
ynh_print_info "Downloading xxenv-latest..."
|
ynh_print_info "Downloading xxenv-latest..."
|
||||||
git init -q
|
git init -q
|
||||||
git remote add origin https://github.com/momo-lab/xxenv-latest.git
|
git remote add origin https://github.com/momo-lab/xxenv-latest.git
|
||||||
else
|
else
|
||||||
ynh_print_info "Updating xxenv-latest..."
|
ynh_print_info "Updating xxenv-latest..."
|
||||||
fi
|
fi
|
||||||
git fetch -q --tags --prune origin
|
git fetch -q --tags --prune origin
|
||||||
local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
local git_latest_tag=$(git describe --tags "$(git rev-list --tags --max-count=1)")
|
||||||
git checkout -q "$git_latest_tag"
|
git checkout -q "$git_latest_tag"
|
||||||
popd
|
popd
|
||||||
|
|
||||||
# Enable caching
|
# Enable caching
|
||||||
|
@ -109,7 +109,7 @@ ynh_go_install () {
|
||||||
_ynh_go_cleanup
|
_ynh_go_cleanup
|
||||||
|
|
||||||
# Set environment for Go users
|
# Set environment for Go users
|
||||||
echo "#goenv
|
echo "#goenv
|
||||||
export GOENV_ROOT=$GOENV_INSTALL_DIR
|
export GOENV_ROOT=$GOENV_INSTALL_DIR
|
||||||
export PATH=\"$GOENV_INSTALL_DIR/bin:$PATH\"
|
export PATH=\"$GOENV_INSTALL_DIR/bin:$PATH\"
|
||||||
eval \"\$(goenv init -)\"
|
eval \"\$(goenv init -)\"
|
||||||
|
@ -126,7 +126,7 @@ eval \"\$(goenv init -)\"
|
||||||
# This helper will also cleanup Go versions
|
# This helper will also cleanup Go versions
|
||||||
#
|
#
|
||||||
# usage: ynh_go_remove
|
# usage: ynh_go_remove
|
||||||
ynh_go_remove () {
|
ynh_go_remove() {
|
||||||
local go_version=$(ynh_app_setting_get --key="go_version")
|
local go_version=$(ynh_app_setting_get --key="go_version")
|
||||||
|
|
||||||
# Load goenv path in PATH
|
# Load goenv path in PATH
|
||||||
|
@ -151,34 +151,29 @@ ynh_go_remove () {
|
||||||
# If no app uses Go, goenv will be also removed.
|
# If no app uses Go, goenv will be also removed.
|
||||||
#
|
#
|
||||||
# usage: _ynh_go_cleanup
|
# usage: _ynh_go_cleanup
|
||||||
_ynh_go_cleanup () {
|
_ynh_go_cleanup() {
|
||||||
|
|
||||||
# List required Go versions
|
# List required Go versions
|
||||||
local installed_apps=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
|
local installed_apps=$(yunohost app list --output-as json --quiet | jq -r .apps[].id)
|
||||||
local required_go_versions=""
|
local required_go_versions=""
|
||||||
for installed_app in $installed_apps
|
for installed_app in $installed_apps; do
|
||||||
do
|
|
||||||
local installed_app_go_version=$(ynh_app_setting_get --app=$installed_app --key="go_version")
|
local installed_app_go_version=$(ynh_app_setting_get --app=$installed_app --key="go_version")
|
||||||
if [[ $installed_app_go_version ]]
|
if [[ $installed_app_go_version ]]; then
|
||||||
then
|
|
||||||
required_go_versions="${installed_app_go_version}\n${required_go_versions}"
|
required_go_versions="${installed_app_go_version}\n${required_go_versions}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove no more needed Go versions
|
# Remove no more needed Go versions
|
||||||
local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/')
|
local installed_go_versions=$(goenv versions --bare --skip-aliases | grep -Ev '/')
|
||||||
for installed_go_version in $installed_go_versions
|
for installed_go_version in $installed_go_versions; do
|
||||||
do
|
if ! $(echo ${required_go_versions} | grep "${installed_go_version}" 1> /dev/null 2>&1); then
|
||||||
if ! `echo ${required_go_versions} | grep "${installed_go_version}" 1>/dev/null 2>&1`
|
|
||||||
then
|
|
||||||
ynh_print_info "Removing of Go-$installed_go_version"
|
ynh_print_info "Removing of Go-$installed_go_version"
|
||||||
$GOENV_INSTALL_DIR/bin/goenv uninstall --force "$installed_go_version"
|
$GOENV_INSTALL_DIR/bin/goenv uninstall --force "$installed_go_version"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# If none Go version is required
|
# If none Go version is required
|
||||||
if [[ ! $required_go_versions ]]
|
if [[ ! $required_go_versions ]]; then
|
||||||
then
|
|
||||||
# Remove goenv environment configuration
|
# Remove goenv environment configuration
|
||||||
ynh_print_info "Removing of goenv"
|
ynh_print_info "Removing of goenv"
|
||||||
ynh_safe_rm "$GOENV_INSTALL_DIR"
|
ynh_safe_rm "$GOENV_INSTALL_DIR"
|
||||||
|
@ -187,9 +182,9 @@ _ynh_go_cleanup () {
|
||||||
}
|
}
|
||||||
|
|
||||||
_ynh_go_try_bash_extension() {
|
_ynh_go_try_bash_extension() {
|
||||||
if [ -x src/configure ]; then
|
if [ -x src/configure ]; then
|
||||||
src/configure && make -C src || {
|
src/configure && make -C src || {
|
||||||
ynh_print_info "Optional bash extension failed to build, but things will still work normally."
|
ynh_print_info "Optional bash extension failed to build, but things will still work normally."
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,9 @@
|
||||||
# usage: ynh_die "Some message"
|
# usage: ynh_die "Some message"
|
||||||
ynh_die() {
|
ynh_die() {
|
||||||
set +o xtrace # set +x
|
set +o xtrace # set +x
|
||||||
if [[ -n "${1:-}" ]]
|
if [[ -n "${1:-}" ]]; then
|
||||||
then
|
if [[ -n "${YNH_STDRETURN:-}" ]]; then
|
||||||
if [[ -n "${YNH_STDRETURN:-}" ]]
|
python3 -c 'import yaml, sys; print(yaml.dump({"error": sys.stdin.read()}))' <<< "${1:-}" >> "$YNH_STDRETURN"
|
||||||
then
|
|
||||||
python3 -c 'import yaml, sys; print(yaml.dump({"error": sys.stdin.read()}))' <<< "${1:-}" >>"$YNH_STDRETURN"
|
|
||||||
fi
|
fi
|
||||||
echo "${1:-}" 1>&2
|
echo "${1:-}" 1>&2
|
||||||
fi
|
fi
|
||||||
|
@ -51,7 +49,7 @@ ynh_exec_and_print_stderr_only_if_error() {
|
||||||
rc=0
|
rc=0
|
||||||
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
# Note that "$@" is used and not $@, c.f. https://unix.stackexchange.com/a/129077
|
||||||
"$@" 2> "$logfile" || rc="$?"
|
"$@" 2> "$logfile" || rc="$?"
|
||||||
if (( rc != 0 )); then
|
if ((rc != 0)); then
|
||||||
cat "$logfile" >&2
|
cat "$logfile" >&2
|
||||||
ynh_safe_rm "$logfile"
|
ynh_safe_rm "$logfile"
|
||||||
return "$rc"
|
return "$rc"
|
||||||
|
@ -63,7 +61,7 @@ ynh_exec_and_print_stderr_only_if_error() {
|
||||||
#
|
#
|
||||||
# usage: ynh_return somedata
|
# usage: ynh_return somedata
|
||||||
ynh_return() {
|
ynh_return() {
|
||||||
echo "$1" >>"$YNH_STDRETURN"
|
echo "$1" >> "$YNH_STDRETURN"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Initial definitions for ynh_script_progression
|
# Initial definitions for ynh_script_progression
|
||||||
|
@ -105,10 +103,9 @@ ynh_script_progression() {
|
||||||
local expected_progression="$((($increment_progression + 1) * $progress_scale / $max_progression - $effective_progression))"
|
local expected_progression="$((($increment_progression + 1) * $progress_scale / $max_progression - $effective_progression))"
|
||||||
|
|
||||||
# Hack for the "--last" message
|
# Hack for the "--last" message
|
||||||
if grep -qw 'completed' <<< "$1";
|
if grep -qw 'completed' <<< "$1"; then
|
||||||
then
|
effective_progression=$progress_scale
|
||||||
effective_progression=$progress_scale
|
expected_progression=0
|
||||||
expected_progression=0
|
|
||||||
fi
|
fi
|
||||||
# left_progression is the progression not yet done
|
# left_progression is the progression not yet done
|
||||||
local left_progression="$(($progress_scale - $effective_progression - $expected_progression))"
|
local left_progression="$(($progress_scale - $effective_progression - $expected_progression))"
|
||||||
|
|
|
@ -22,8 +22,7 @@ ynh_config_add_logrotate() {
|
||||||
fi
|
fi
|
||||||
set +o noglob
|
set +o noglob
|
||||||
|
|
||||||
for stuff in $logfile
|
for stuff in $logfile; do
|
||||||
do
|
|
||||||
# Make sure the permissions of the parent dir are correct (otherwise the config file could be ignored and the corresponding logs never rotated)
|
# Make sure the permissions of the parent dir are correct (otherwise the config file could be ignored and the corresponding logs never rotated)
|
||||||
local dir=$(dirname "$stuff")
|
local dir=$(dirname "$stuff")
|
||||||
mkdir --parents $dir
|
mkdir --parents $dir
|
||||||
|
@ -32,7 +31,7 @@ ynh_config_add_logrotate() {
|
||||||
done
|
done
|
||||||
|
|
||||||
local tempconf="$(mktemp)"
|
local tempconf="$(mktemp)"
|
||||||
cat << EOF >$tempconf
|
cat << EOF > $tempconf
|
||||||
$logfile {
|
$logfile {
|
||||||
# Rotate if the logfile exceeds 100Mo
|
# Rotate if the logfile exceeds 100Mo
|
||||||
size 100M
|
size 100M
|
||||||
|
@ -53,8 +52,7 @@ $logfile {
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
if [[ "$FIRST_CALL_TO_LOGROTATE" == "true" ]]
|
if [[ "$FIRST_CALL_TO_LOGROTATE" == "true" ]]; then
|
||||||
then
|
|
||||||
cat $tempconf > /etc/logrotate.d/$app
|
cat $tempconf > /etc/logrotate.d/$app
|
||||||
else
|
else
|
||||||
cat $tempconf >> /etc/logrotate.d/$app
|
cat $tempconf >> /etc/logrotate.d/$app
|
||||||
|
|
|
@ -12,16 +12,15 @@
|
||||||
#
|
#
|
||||||
ynh_mongo_exec() {
|
ynh_mongo_exec() {
|
||||||
# ============ Argument parsing =============
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [d]=database= [c]=command= )
|
local -A args_array=([d]=database= [c]=command=)
|
||||||
local database
|
local database
|
||||||
local command
|
local command
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
database="${database:-}"
|
database="${database:-}"
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
if [ -n "$database" ]
|
if [ -n "$database" ]; then
|
||||||
then
|
mongosh --quiet << EOF
|
||||||
mongosh --quiet <<EOF
|
|
||||||
use $database
|
use $database
|
||||||
${command}
|
${command}
|
||||||
quit()
|
quit()
|
||||||
|
@ -44,7 +43,7 @@ EOF
|
||||||
#
|
#
|
||||||
ynh_mongo_drop_db() {
|
ynh_mongo_drop_db() {
|
||||||
# ============ Argument parsing =============
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [d]=database= )
|
local -A args_array=([d]=database=)
|
||||||
local database
|
local database
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
@ -63,7 +62,7 @@ ynh_mongo_drop_db() {
|
||||||
#
|
#
|
||||||
ynh_mongo_dump_db() {
|
ynh_mongo_dump_db() {
|
||||||
# ============ Argument parsing =============
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [d]=database= )
|
local -A args_array=([d]=database=)
|
||||||
local database
|
local database
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
@ -83,7 +82,7 @@ ynh_mongo_dump_db() {
|
||||||
#
|
#
|
||||||
ynh_mongo_create_user() {
|
ynh_mongo_create_user() {
|
||||||
# ============ Argument parsing =============
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
|
local -A args_array=([u]=db_user= [n]=db_name= [p]=db_pwd=)
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
local db_pwd
|
local db_pwd
|
||||||
|
@ -111,8 +110,7 @@ ynh_mongo_database_exists() {
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")') -lt 0 ]
|
if [ $(ynh_mongo_exec --command='db.getMongo().getDBNames().indexOf("'${database}'")') -lt 0 ]; then
|
||||||
then
|
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
return 0
|
return 0
|
||||||
|
@ -129,7 +127,7 @@ ynh_mongo_database_exists() {
|
||||||
#
|
#
|
||||||
ynh_mongo_restore_db() {
|
ynh_mongo_restore_db() {
|
||||||
# ============ Argument parsing =============
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [d]=database= )
|
local -A args_array=([d]=database=)
|
||||||
local database
|
local database
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
@ -148,7 +146,7 @@ ynh_mongo_restore_db() {
|
||||||
#
|
#
|
||||||
ynh_mongo_drop_user() {
|
ynh_mongo_drop_user() {
|
||||||
# ============ Argument parsing =============
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [u]=db_user= [n]=db_name= )
|
local -A args_array=([u]=db_user= [n]=db_name=)
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
|
@ -170,7 +168,7 @@ ynh_mongo_drop_user() {
|
||||||
#
|
#
|
||||||
ynh_mongo_setup_db() {
|
ynh_mongo_setup_db() {
|
||||||
# ============ Argument parsing =============
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [u]=db_user= [n]=db_name= [p]=db_pwd= )
|
local -A args_array=([u]=db_user= [n]=db_name= [p]=db_pwd=)
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
db_pwd=""
|
db_pwd=""
|
||||||
|
@ -197,14 +195,14 @@ ynh_mongo_setup_db() {
|
||||||
#
|
#
|
||||||
ynh_mongo_remove_db() {
|
ynh_mongo_remove_db() {
|
||||||
# ============ Argument parsing =============
|
# ============ Argument parsing =============
|
||||||
local -A args_array=( [u]=db_user= [n]=db_name= )
|
local -A args_array=([u]=db_user= [n]=db_name=)
|
||||||
local db_user
|
local db_user
|
||||||
local db_name
|
local db_name
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
if ynh_mongo_database_exists --database=$db_name; then # Check if the database exists
|
if ynh_mongo_database_exists --database=$db_name; then # Check if the database exists
|
||||||
ynh_mongo_drop_db --database=$db_name # Remove the database
|
ynh_mongo_drop_db --database=$db_name # Remove the database
|
||||||
else
|
else
|
||||||
ynh_print_warn "Database $db_name not found"
|
ynh_print_warn "Database $db_name not found"
|
||||||
fi
|
fi
|
||||||
|
@ -262,8 +260,7 @@ ynh_install_mongo() {
|
||||||
#
|
#
|
||||||
ynh_remove_mongo() {
|
ynh_remove_mongo() {
|
||||||
# Only remove the mongodb service if it is not installed.
|
# Only remove the mongodb service if it is not installed.
|
||||||
if ! _ynh_apt_package_is_installed "mongodb*"
|
if ! _ynh_apt_package_is_installed "mongodb*"; then
|
||||||
then
|
|
||||||
ynh_print_info "Removing MongoDB service..."
|
ynh_print_info "Removing MongoDB service..."
|
||||||
mongodb_servicename=mongod
|
mongodb_servicename=mongod
|
||||||
# Remove the mongodb service
|
# Remove the mongodb service
|
||||||
|
|
|
@ -39,7 +39,6 @@ ynh_config_remove_nginx() {
|
||||||
ynh_systemctl --service=nginx --action=reload
|
ynh_systemctl --service=nginx --action=reload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# Regen the nginx config in a change url context
|
# Regen the nginx config in a change url context
|
||||||
#
|
#
|
||||||
# usage: ynh_config_change_url_nginx
|
# usage: ynh_config_change_url_nginx
|
||||||
|
@ -47,7 +46,7 @@ ynh_config_change_url_nginx() {
|
||||||
|
|
||||||
# Make a backup of the original NGINX config file if manually modified
|
# Make a backup of the original NGINX config file if manually modified
|
||||||
# (nb: this is possibly different from the same instruction called by
|
# (nb: this is possibly different from the same instruction called by
|
||||||
# ynh_config_add inside ynh_config_add_nginx because the path may have
|
# ynh_config_add inside ynh_config_add_nginx because the path may have
|
||||||
# changed if we're changing the domain too...)
|
# changed if we're changing the domain too...)
|
||||||
local old_nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
local old_nginx_conf_path=/etc/nginx/conf.d/$old_domain.d/$app.conf
|
||||||
ynh_backup_if_checksum_is_different "$old_nginx_conf_path"
|
ynh_backup_if_checksum_is_different "$old_nginx_conf_path"
|
||||||
|
|
|
@ -169,7 +169,7 @@ ynh_permission_exists() {
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
yunohost user permission list "$app" --output-as json --quiet \
|
yunohost user permission list "$app" --output-as json --quiet \
|
||||||
| jq -e --arg perm "$app.$permission" '.permissions[$perm]' >/dev/null
|
| jq -e --arg perm "$app.$permission" '.permissions[$perm]' > /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Redefine the url associated to a permission
|
# Redefine the url associated to a permission
|
||||||
|
@ -301,7 +301,7 @@ ynh_permission_has_user() {
|
||||||
# Check both allowed and corresponding_users sections in the json
|
# Check both allowed and corresponding_users sections in the json
|
||||||
for section in "allowed" "corresponding_users"; do
|
for section in "allowed" "corresponding_users"; do
|
||||||
if yunohost user permission info "$app.$permission" --output-as json --quiet \
|
if yunohost user permission info "$app.$permission" --output-as json --quiet \
|
||||||
| jq -e --arg user $user --arg section $section '.[$section] | index($user)' >/dev/null; then
|
| jq -e --arg user $user --arg section $section '.[$section] | index($user)' > /dev/null; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
@ -59,9 +59,9 @@ ynh_config_add_phpfpm() {
|
||||||
# Apps willing to tweak these should use ynh_setting_set_default_value (in install and upgrade?)
|
# Apps willing to tweak these should use ynh_setting_set_default_value (in install and upgrade?)
|
||||||
#
|
#
|
||||||
local php_upload_max_filesize=${php_upload_max_filesize:-50M}
|
local php_upload_max_filesize=${php_upload_max_filesize:-50M}
|
||||||
local php_process_management=${php_process_management:-ondemand} # alternatively 'dynamic' or 'static'
|
local php_process_management=${php_process_management:-ondemand} # alternatively 'dynamic' or 'static'
|
||||||
local php_max_children=${php_max_children:-$(_default_php_max_children)}
|
local php_max_children=${php_max_children:-$(_default_php_max_children)}
|
||||||
local php_memory_limit=${php_memory_limit:-128M} # default value is from global php.ini
|
local php_memory_limit=${php_memory_limit:-128M} # default value is from global php.ini
|
||||||
|
|
||||||
local phpfpm_template=$(mktemp)
|
local phpfpm_template=$(mktemp)
|
||||||
cat << EOF > $phpfpm_template
|
cat << EOF > $phpfpm_template
|
||||||
|
@ -102,7 +102,7 @@ EOF
|
||||||
|
|
||||||
# Concatene the extra config
|
# Concatene the extra config
|
||||||
if [ -e $YNH_APP_BASEDIR/conf/extra_php-fpm.conf ]; then
|
if [ -e $YNH_APP_BASEDIR/conf/extra_php-fpm.conf ]; then
|
||||||
cat $YNH_APP_BASEDIR/conf/extra_php-fpm.conf >>"$phpfpm_template"
|
cat $YNH_APP_BASEDIR/conf/extra_php-fpm.conf >> "$phpfpm_template"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure the fpm pool dir exists
|
# Make sure the fpm pool dir exists
|
||||||
|
@ -111,7 +111,7 @@ EOF
|
||||||
ynh_config_add --template="$phpfpm_template" --destination="/etc/php/$php_version/fpm/pool.d/$app.conf"
|
ynh_config_add --template="$phpfpm_template" --destination="/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||||
|
|
||||||
# Validate that the new php conf doesn't break php-fpm entirely
|
# Validate that the new php conf doesn't break php-fpm entirely
|
||||||
if ! php-fpm${php_version} --test 2>/dev/null; then
|
if ! php-fpm${php_version} --test 2> /dev/null; then
|
||||||
php-fpm${php_version} --test || true
|
php-fpm${php_version} --test || true
|
||||||
ynh_safe_rm "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
ynh_safe_rm "/etc/php/$php_version/fpm/pool.d/$app.conf"
|
||||||
ynh_die "The new configuration broke php-fpm?"
|
ynh_die "The new configuration broke php-fpm?"
|
||||||
|
|
|
@ -5,27 +5,25 @@
|
||||||
# usage: ynh_redis_get_free_db
|
# usage: ynh_redis_get_free_db
|
||||||
# | returns: the database number to use
|
# | returns: the database number to use
|
||||||
ynh_redis_get_free_db() {
|
ynh_redis_get_free_db() {
|
||||||
local result max db
|
local result max db
|
||||||
result=$(redis-cli INFO keyspace)
|
result=$(redis-cli INFO keyspace)
|
||||||
|
|
||||||
# get the num
|
# get the num
|
||||||
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
|
max=$(cat /etc/redis/redis.conf | grep ^databases | grep -Eow "[0-9]+")
|
||||||
|
|
||||||
db=0
|
db=0
|
||||||
# default Debian setting is 15 databases
|
# default Debian setting is 15 databases
|
||||||
for i in $(seq 0 "$max")
|
for i in $(seq 0 "$max"); do
|
||||||
do
|
if ! echo "$result" | grep -q "db$i"; then
|
||||||
if ! echo "$result" | grep -q "db$i"
|
db=$i
|
||||||
then
|
break 1
|
||||||
db=$i
|
fi
|
||||||
break 1
|
db=-1
|
||||||
fi
|
done
|
||||||
db=-1
|
|
||||||
done
|
|
||||||
|
|
||||||
test "$db" -eq -1 && ynh_die "No available Redis databases..."
|
test "$db" -eq -1 && ynh_die "No available Redis databases..."
|
||||||
|
|
||||||
echo "$db"
|
echo "$db"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a master password and set up global settings
|
# Create a master password and set up global settings
|
||||||
|
@ -34,6 +32,6 @@ ynh_redis_get_free_db() {
|
||||||
# usage: ynh_redis_remove_db database
|
# usage: ynh_redis_remove_db database
|
||||||
# | arg: database - the database to erase
|
# | arg: database - the database to erase
|
||||||
ynh_redis_remove_db() {
|
ynh_redis_remove_db() {
|
||||||
local db=$1
|
local db=$1
|
||||||
redis-cli -n "$db" flushdb
|
redis-cli -n "$db" flushdb
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ _ynh_load_ruby_in_path_and_other_tweaks() {
|
||||||
|
|
||||||
# Sets the local application-specific Ruby version
|
# Sets the local application-specific Ruby version
|
||||||
pushd ${install_dir}
|
pushd ${install_dir}
|
||||||
$RBENV_INSTALL_DIR/bin/rbenv local $ruby_version
|
$RBENV_INSTALL_DIR/bin/rbenv local $ruby_version
|
||||||
popd
|
popd
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ _ynh_load_ruby_in_path_and_other_tweaks() {
|
||||||
# - `$ruby_dir`, the directory containing the specific version of ruby, which may be used in the systemd config too (e.g. `ExecStart=__RUBY_DIR__/ruby foo bar`)
|
# - `$ruby_dir`, the directory containing the specific version of ruby, which may be used in the systemd config too (e.g. `ExecStart=__RUBY_DIR__/ruby foo bar`)
|
||||||
#
|
#
|
||||||
# This helper also creates a /etc/profile.d/rbenv.sh that configures PATH environment for rbenv
|
# This helper also creates a /etc/profile.d/rbenv.sh that configures PATH environment for rbenv
|
||||||
ynh_ruby_install () {
|
ynh_ruby_install() {
|
||||||
|
|
||||||
[[ -n "${ruby_version:-}" ]] || ynh_die "\$ruby_version should be defined prior to calling ynh_ruby_install"
|
[[ -n "${ruby_version:-}" ]] || ynh_die "\$ruby_version should be defined prior to calling ynh_ruby_install"
|
||||||
|
|
||||||
|
@ -59,31 +59,31 @@ ynh_ruby_install () {
|
||||||
rbenv="$(command -v rbenv $RBENV_INSTALL_DIR/bin/rbenv | grep "$RBENV_INSTALL_DIR/bin/rbenv" | head -1)"
|
rbenv="$(command -v rbenv $RBENV_INSTALL_DIR/bin/rbenv | grep "$RBENV_INSTALL_DIR/bin/rbenv" | head -1)"
|
||||||
if [ -n "$rbenv" ]; then
|
if [ -n "$rbenv" ]; then
|
||||||
pushd "${rbenv%/*/*}"
|
pushd "${rbenv%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/rbenv.git"; then
|
if git remote -v 2> /dev/null | grep "https://github.com/rbenv/rbenv.git"; then
|
||||||
echo "Updating rbenv..."
|
echo "Updating rbenv..."
|
||||||
git pull -q --tags origin master
|
git pull -q --tags origin master
|
||||||
_ynh_ruby_try_bash_extension
|
_ynh_ruby_try_bash_extension
|
||||||
else
|
else
|
||||||
echo "Reinstalling rbenv..."
|
echo "Reinstalling rbenv..."
|
||||||
cd ..
|
cd ..
|
||||||
ynh_safe_rm $RBENV_INSTALL_DIR
|
ynh_safe_rm $RBENV_INSTALL_DIR
|
||||||
mkdir -p $RBENV_INSTALL_DIR
|
mkdir -p $RBENV_INSTALL_DIR
|
||||||
cd $RBENV_INSTALL_DIR
|
cd $RBENV_INSTALL_DIR
|
||||||
git init -q
|
|
||||||
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
|
||||||
git checkout -q -b master origin/master
|
|
||||||
_ynh_ruby_try_bash_extension
|
|
||||||
rbenv=$RBENV_INSTALL_DIR/bin/rbenv
|
|
||||||
fi
|
|
||||||
popd
|
|
||||||
else
|
|
||||||
echo "Installing rbenv..."
|
|
||||||
pushd $RBENV_INSTALL_DIR
|
|
||||||
git init -q
|
git init -q
|
||||||
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||||
git checkout -q -b master origin/master
|
git checkout -q -b master origin/master
|
||||||
_ynh_ruby_try_bash_extension
|
_ynh_ruby_try_bash_extension
|
||||||
rbenv=$RBENV_INSTALL_DIR/bin/rbenv
|
rbenv=$RBENV_INSTALL_DIR/bin/rbenv
|
||||||
|
fi
|
||||||
|
popd
|
||||||
|
else
|
||||||
|
echo "Installing rbenv..."
|
||||||
|
pushd $RBENV_INSTALL_DIR
|
||||||
|
git init -q
|
||||||
|
git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1
|
||||||
|
git checkout -q -b master origin/master
|
||||||
|
_ynh_ruby_try_bash_extension
|
||||||
|
rbenv=$RBENV_INSTALL_DIR/bin/rbenv
|
||||||
popd
|
popd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -92,10 +92,10 @@ ynh_ruby_install () {
|
||||||
ruby_build="$(command -v "$RBENV_INSTALL_DIR"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
|
ruby_build="$(command -v "$RBENV_INSTALL_DIR"/plugins/*/bin/rbenv-install rbenv-install | head -1)"
|
||||||
if [ -n "$ruby_build" ]; then
|
if [ -n "$ruby_build" ]; then
|
||||||
pushd "${ruby_build%/*/*}"
|
pushd "${ruby_build%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
|
if git remote -v 2> /dev/null | grep "https://github.com/rbenv/ruby-build.git"; then
|
||||||
echo "Updating ruby-build..."
|
echo "Updating ruby-build..."
|
||||||
git pull -q origin master
|
git pull -q origin master
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
echo "Installing ruby-build..."
|
echo "Installing ruby-build..."
|
||||||
|
@ -105,10 +105,10 @@ ynh_ruby_install () {
|
||||||
rbenv_alias="$(command -v "$RBENV_INSTALL_DIR"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
|
rbenv_alias="$(command -v "$RBENV_INSTALL_DIR"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)"
|
||||||
if [ -n "$rbenv_alias" ]; then
|
if [ -n "$rbenv_alias" ]; then
|
||||||
pushd "${rbenv_alias%/*/*}"
|
pushd "${rbenv_alias%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then
|
if git remote -v 2> /dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then
|
||||||
echo "Updating rbenv-aliases..."
|
echo "Updating rbenv-aliases..."
|
||||||
git pull -q origin master
|
git pull -q origin master
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
echo "Installing rbenv-aliases..."
|
echo "Installing rbenv-aliases..."
|
||||||
|
@ -118,10 +118,10 @@ ynh_ruby_install () {
|
||||||
rbenv_latest="$(command -v "$RBENV_INSTALL_DIR"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
|
rbenv_latest="$(command -v "$RBENV_INSTALL_DIR"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)"
|
||||||
if [ -n "$rbenv_latest" ]; then
|
if [ -n "$rbenv_latest" ]; then
|
||||||
pushd "${rbenv_latest%/*/*}"
|
pushd "${rbenv_latest%/*/*}"
|
||||||
if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
if git remote -v 2> /dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then
|
||||||
echo "Updating xxenv-latest..."
|
echo "Updating xxenv-latest..."
|
||||||
git pull -q origin master
|
git pull -q origin master
|
||||||
fi
|
fi
|
||||||
popd
|
popd
|
||||||
else
|
else
|
||||||
echo "Installing xxenv-latest..."
|
echo "Installing xxenv-latest..."
|
||||||
|
@ -153,8 +153,7 @@ ynh_ruby_install () {
|
||||||
ruby_version=$final_ruby_version
|
ruby_version=$final_ruby_version
|
||||||
|
|
||||||
# Remove app virtualenv
|
# Remove app virtualenv
|
||||||
if rbenv alias --list | grep --quiet "$app "
|
if rbenv alias --list | grep --quiet "$app "; then
|
||||||
then
|
|
||||||
rbenv alias $app --remove
|
rbenv alias $app --remove
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -165,7 +164,7 @@ ynh_ruby_install () {
|
||||||
_ynh_ruby_cleanup
|
_ynh_ruby_cleanup
|
||||||
|
|
||||||
# Set environment for Ruby users
|
# Set environment for Ruby users
|
||||||
echo "#rbenv
|
echo "#rbenv
|
||||||
export RBENV_ROOT=$RBENV_INSTALL_DIR
|
export RBENV_ROOT=$RBENV_INSTALL_DIR
|
||||||
export PATH=\"$RBENV_INSTALL_DIR/bin:$PATH\"
|
export PATH=\"$RBENV_INSTALL_DIR/bin:$PATH\"
|
||||||
eval \"\$(rbenv init -)\"
|
eval \"\$(rbenv init -)\"
|
||||||
|
@ -182,7 +181,7 @@ eval \"\$(rbenv init -)\"
|
||||||
# This helper will also cleanup unused Ruby versions
|
# This helper will also cleanup unused Ruby versions
|
||||||
#
|
#
|
||||||
# usage: ynh_ruby_remove
|
# usage: ynh_ruby_remove
|
||||||
ynh_ruby_remove () {
|
ynh_ruby_remove() {
|
||||||
|
|
||||||
[[ -n "${ruby_version:-}" ]] || ynh_die "\$ruby_version should be defined prior to calling ynh_ruby_remove"
|
[[ -n "${ruby_version:-}" ]] || ynh_die "\$ruby_version should be defined prior to calling ynh_ruby_remove"
|
||||||
|
|
||||||
|
@ -208,34 +207,29 @@ ynh_ruby_remove () {
|
||||||
# This helper will check what Ruby version are no more required,
|
# This helper will check what Ruby version are no more required,
|
||||||
# and uninstall them
|
# and uninstall them
|
||||||
# If no app uses Ruby, rbenv will be also removed.
|
# If no app uses Ruby, rbenv will be also removed.
|
||||||
_ynh_ruby_cleanup () {
|
_ynh_ruby_cleanup() {
|
||||||
|
|
||||||
# List required Ruby versions
|
# List required Ruby versions
|
||||||
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$')
|
||||||
local required_ruby_versions=""
|
local required_ruby_versions=""
|
||||||
for installed_app in $installed_apps
|
for installed_app in $installed_apps; do
|
||||||
do
|
|
||||||
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version")
|
||||||
if [[ -n "$installed_app_ruby_version" ]]
|
if [[ -n "$installed_app_ruby_version" ]]; then
|
||||||
then
|
|
||||||
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Remove no more needed Ruby versions
|
# Remove no more needed Ruby versions
|
||||||
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/')
|
||||||
for installed_ruby_version in $installed_ruby_versions
|
for installed_ruby_version in $installed_ruby_versions; do
|
||||||
do
|
if ! echo ${required_ruby_versions} | grep -q "${installed_ruby_version}"; then
|
||||||
if ! echo ${required_ruby_versions} | grep -q "${installed_ruby_version}"
|
|
||||||
then
|
|
||||||
echo "Removing Ruby-$installed_ruby_version"
|
echo "Removing Ruby-$installed_ruby_version"
|
||||||
$RBENV_INSTALL_DIR/bin/rbenv uninstall --force $installed_ruby_version
|
$RBENV_INSTALL_DIR/bin/rbenv uninstall --force $installed_ruby_version
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# If none Ruby version is required
|
# If none Ruby version is required
|
||||||
if [[ -z "$required_ruby_versions" ]]
|
if [[ -z "$required_ruby_versions" ]]; then
|
||||||
then
|
|
||||||
# Remove rbenv environment configuration
|
# Remove rbenv environment configuration
|
||||||
echo "Removing rbenv"
|
echo "Removing rbenv"
|
||||||
ynh_safe_rm "$RBENV_INSTALL_DIR"
|
ynh_safe_rm "$RBENV_INSTALL_DIR"
|
||||||
|
@ -244,9 +238,9 @@ _ynh_ruby_cleanup () {
|
||||||
}
|
}
|
||||||
|
|
||||||
_ynh_ruby_try_bash_extension() {
|
_ynh_ruby_try_bash_extension() {
|
||||||
if [ -x src/configure ]; then
|
if [ -x src/configure ]; then
|
||||||
src/configure && make -C src 2>&1 || {
|
src/configure && make -C src 2>&1 || {
|
||||||
ynh_print_info "Optional bash extension failed to build, but things will still work normally."
|
ynh_print_info "Optional bash extension failed to build, but things will still work normally."
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ ynh_app_setting() {
|
||||||
# Trick to only re-enable debugging if it was set before
|
# Trick to only re-enable debugging if it was set before
|
||||||
local xtrace_enable=$(set +o | grep xtrace)
|
local xtrace_enable=$(set +o | grep xtrace)
|
||||||
set +o xtrace # set +x
|
set +o xtrace # set +x
|
||||||
ACTION="$1" APP="$2" KEY="$3" VALUE="${4:-}" python3 - <<EOF
|
ACTION="$1" APP="$2" KEY="$3" VALUE="${4:-}" python3 - << EOF
|
||||||
import os, yaml, sys
|
import os, yaml, sys
|
||||||
app, action = os.environ['APP'], os.environ['ACTION'].lower()
|
app, action = os.environ['APP'], os.environ['ACTION'].lower()
|
||||||
key, value = os.environ['KEY'], os.environ.get('VALUE', None)
|
key, value = os.environ['KEY'], os.environ.get('VALUE', None)
|
||||||
|
@ -125,15 +125,11 @@ EOF
|
||||||
|
|
||||||
# Legacy: auto-convert phpversion to php_version (for consistency with nodejs_version, ruby_version, ...)
|
# Legacy: auto-convert phpversion to php_version (for consistency with nodejs_version, ruby_version, ...)
|
||||||
# This has to be here and not in the "php" code file because ynh_app_setting_set/delete need to be defined @_@
|
# This has to be here and not in the "php" code file because ynh_app_setting_set/delete need to be defined @_@
|
||||||
if [[ -n "${app:-}" ]] && [[ -n "${phpversion:-}" ]]
|
if [[ -n "${app:-}" ]] && [[ -n "${phpversion:-}" ]]; then
|
||||||
then
|
if [[ -z "${php_version:-}" ]]; then
|
||||||
if [[ -z "${php_version:-}" ]]
|
|
||||||
then
|
|
||||||
php_version=$phpversion
|
php_version=$phpversion
|
||||||
ynh_app_setting_set --key=php_version --value=$php_version
|
ynh_app_setting_set --key=php_version --value=$php_version
|
||||||
fi
|
fi
|
||||||
ynh_app_setting_delete --key=phpversion
|
ynh_app_setting_delete --key=phpversion
|
||||||
unset phpversion
|
unset phpversion
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -74,8 +74,7 @@ ynh_setup_source() {
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
local sources_json=$(ynh_read_manifest "resources.sources[\"$source_id\"]")
|
local sources_json=$(ynh_read_manifest "resources.sources[\"$source_id\"]")
|
||||||
if jq -re ".url" <<< "$sources_json"
|
if jq -re ".url" <<< "$sources_json"; then
|
||||||
then
|
|
||||||
local arch_prefix=""
|
local arch_prefix=""
|
||||||
else
|
else
|
||||||
local arch_prefix=".$YNH_ARCH"
|
local arch_prefix=".$YNH_ARCH"
|
||||||
|
@ -93,25 +92,18 @@ ynh_setup_source() {
|
||||||
[[ -n "$src_url" ]] || ynh_die "No URL defined for source $source_id$arch_prefix ?"
|
[[ -n "$src_url" ]] || ynh_die "No URL defined for source $source_id$arch_prefix ?"
|
||||||
[[ -n "$src_sum" ]] || ynh_die "No sha256 sum defined for source $source_id$arch_prefix ?"
|
[[ -n "$src_sum" ]] || ynh_die "No sha256 sum defined for source $source_id$arch_prefix ?"
|
||||||
|
|
||||||
if [[ -z "$src_format" ]]
|
if [[ -z "$src_format" ]]; then
|
||||||
then
|
if [[ "$src_url" =~ ^.*\.zip$ ]] || [[ "$src_url" =~ ^.*/zipball/.*$ ]]; then
|
||||||
if [[ "$src_url" =~ ^.*\.zip$ ]] || [[ "$src_url" =~ ^.*/zipball/.*$ ]]
|
|
||||||
then
|
|
||||||
src_format="zip"
|
src_format="zip"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar\.gz$ ]] || [[ "$src_url" =~ ^.*\.tgz$ ]] || [[ "$src_url" =~ ^.*/tar\.gz/.*$ ]] || [[ "$src_url" =~ ^.*/tarball/.*$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar\.gz$ ]] || [[ "$src_url" =~ ^.*\.tgz$ ]] || [[ "$src_url" =~ ^.*/tar\.gz/.*$ ]] || [[ "$src_url" =~ ^.*/tarball/.*$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar.gz"
|
src_format="tar.gz"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar\.xz$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar\.xz$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar.xz"
|
src_format="tar.xz"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar\.bz2$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar\.bz2$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar.bz2"
|
src_format="tar.bz2"
|
||||||
elif [[ "$src_url" =~ ^.*\.tar$ ]]
|
elif [[ "$src_url" =~ ^.*\.tar$ ]]; then
|
||||||
then
|
|
||||||
src_format="tar"
|
src_format="tar"
|
||||||
elif [[ -z "$src_extract" ]]
|
elif [[ -z "$src_extract" ]]; then
|
||||||
then
|
|
||||||
src_extract="false"
|
src_extract="false"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -120,8 +112,7 @@ ynh_setup_source() {
|
||||||
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
src_format=$(echo "$src_format" | tr '[:upper:]' '[:lower:]')
|
||||||
src_extract=${src_extract:-true}
|
src_extract=${src_extract:-true}
|
||||||
|
|
||||||
if [[ "$src_extract" != "true" ]] && [[ "$src_extract" != "false" ]]
|
if [[ "$src_extract" != "true" ]] && [[ "$src_extract" != "false" ]]; then
|
||||||
then
|
|
||||||
ynh_die "For source $source_id, expected either 'true' or 'false' for the extract parameter"
|
ynh_die "For source $source_id, expected either 'true' or 'false' for the extract parameter"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -135,14 +126,12 @@ ynh_setup_source() {
|
||||||
[ -n "$src_url" ] || ynh_die "Couldn't parse SOURCE_URL from $src_file_path ?"
|
[ -n "$src_url" ] || ynh_die "Couldn't parse SOURCE_URL from $src_file_path ?"
|
||||||
|
|
||||||
# If the file was prefetched but somehow doesn't match the sum, rm and redownload it
|
# If the file was prefetched but somehow doesn't match the sum, rm and redownload it
|
||||||
if [ -e "$src_filename" ] && ! echo "${src_sum} ${src_filename}" | sha256sum --check --status
|
if [ -e "$src_filename" ] && ! echo "${src_sum} ${src_filename}" | sha256sum --check --status; then
|
||||||
then
|
|
||||||
rm -f "$src_filename"
|
rm -f "$src_filename"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Only redownload the file if it wasnt prefetched
|
# Only redownload the file if it wasnt prefetched
|
||||||
if [ ! -e "$src_filename" ]
|
if [ ! -e "$src_filename" ]; then
|
||||||
then
|
|
||||||
# NB. we have to declare the var as local first,
|
# NB. we have to declare the var as local first,
|
||||||
# otherwise 'local foo=$(false) || echo 'pwet'" does'nt work
|
# otherwise 'local foo=$(false) || echo 'pwet'" does'nt work
|
||||||
# because local always return 0 ...
|
# because local always return 0 ...
|
||||||
|
@ -153,8 +142,7 @@ ynh_setup_source() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check the control sum
|
# Check the control sum
|
||||||
if ! echo "${src_sum} ${src_filename}" | sha256sum --check --status
|
if ! echo "${src_sum} ${src_filename}" | sha256sum --check --status; then
|
||||||
then
|
|
||||||
local actual_sum="$(sha256sum ${src_filename} | cut --delimiter=' ' --fields=1)"
|
local actual_sum="$(sha256sum ${src_filename} | cut --delimiter=' ' --fields=1)"
|
||||||
local actual_size="$(du -hs ${src_filename} | cut --fields=1)"
|
local actual_size="$(du -hs ${src_filename} | cut --fields=1)"
|
||||||
rm -f ${src_filename}
|
rm -f ${src_filename}
|
||||||
|
@ -185,8 +173,7 @@ ynh_setup_source() {
|
||||||
mkdir --parents "$dest_dir"
|
mkdir --parents "$dest_dir"
|
||||||
|
|
||||||
if [[ "$src_extract" == "false" ]]; then
|
if [[ "$src_extract" == "false" ]]; then
|
||||||
if [[ -z "$src_rename" ]]
|
if [[ -z "$src_rename" ]]; then
|
||||||
then
|
|
||||||
mv $src_filename $dest_dir
|
mv $src_filename $dest_dir
|
||||||
else
|
else
|
||||||
mv $src_filename $dest_dir/$src_rename
|
mv $src_filename $dest_dir/$src_rename
|
||||||
|
@ -224,8 +211,8 @@ ynh_setup_source() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Apply patches
|
# Apply patches
|
||||||
local patches_folder=$(realpath "$YNH_APP_BASEDIR/patches/$source_id")
|
if [ -d "$YNH_APP_BASEDIR/patches/" ]; then
|
||||||
if [ -d "$patches_folder" ]; then
|
local patches_folder=$(realpath "$YNH_APP_BASEDIR/patches/$source_id")
|
||||||
pushd "$dest_dir"
|
pushd "$dest_dir"
|
||||||
for patchfile in "$patches_folder/"*.patch; do
|
for patchfile in "$patches_folder/"*.patch; do
|
||||||
echo "Applying $patchfile"
|
echo "Applying $patchfile"
|
||||||
|
|
|
@ -18,7 +18,7 @@ ynh_string_random() {
|
||||||
filter=${filter:-'A-Za-z0-9'}
|
filter=${filter:-'A-Za-z0-9'}
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
dd if=/dev/urandom bs=1 count=1000 2>/dev/null \
|
dd if=/dev/urandom bs=1 count=1000 2> /dev/null \
|
||||||
| tr --complement --delete "$filter" \
|
| tr --complement --delete "$filter" \
|
||||||
| sed --quiet 's/\(.\{'"$length"'\}\).*/\1/p'
|
| sed --quiet 's/\(.\{'"$length"'\}\).*/\1/p'
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,8 +68,7 @@ ynh_systemctl() {
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
# On CI, use length=100 because it's sometime hell to debug otherwise for super-long output
|
# On CI, use length=100 because it's sometime hell to debug otherwise for super-long output
|
||||||
if ynh_in_ci_tests && [ $length -le 20 ]
|
if ynh_in_ci_tests && [ $length -le 20 ]; then
|
||||||
then
|
|
||||||
length=100
|
length=100
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -84,12 +83,12 @@ ynh_systemctl() {
|
||||||
# Following the starting of the app in its log
|
# Following the starting of the app in its log
|
||||||
if [ "$log_path" == "systemd" ]; then
|
if [ "$log_path" == "systemd" ]; then
|
||||||
# Read the systemd journal
|
# Read the systemd journal
|
||||||
journalctl --unit=$service --follow --since=-0 --quiet >"$templog" &
|
journalctl --unit=$service --follow --since=-0 --quiet > "$templog" &
|
||||||
# Get the PID of the journalctl command
|
# Get the PID of the journalctl command
|
||||||
local pid_tail=$!
|
local pid_tail=$!
|
||||||
else
|
else
|
||||||
# Read the specified log file
|
# Read the specified log file
|
||||||
tail --follow=name --retry --lines=0 "$log_path" >"$templog" 2>&1 &
|
tail --follow=name --retry --lines=0 "$log_path" > "$templog" 2>&1 &
|
||||||
# Get the PID of the tail command
|
# Get the PID of the tail command
|
||||||
local pid_tail=$!
|
local pid_tail=$!
|
||||||
fi
|
fi
|
||||||
|
@ -139,8 +138,7 @@ ynh_systemctl() {
|
||||||
# Also check the timeout using actual timestamp, because sometimes for some reason,
|
# Also check the timeout using actual timestamp, because sometimes for some reason,
|
||||||
# journalctl may take a huge time to run, and we end up waiting literally an entire hour
|
# journalctl may take a huge time to run, and we end up waiting literally an entire hour
|
||||||
# instead of 5 min ...
|
# instead of 5 min ...
|
||||||
if [[ "$(( $(date +%s) - $starttime))" -gt "$timeout" ]]
|
if [[ "$(($(date +%s) - $starttime))" -gt "$timeout" ]]; then
|
||||||
then
|
|
||||||
i=$timeout
|
i=$timeout
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
@ -160,8 +158,7 @@ ynh_systemctl() {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# If we tried to reload/start/restart the service but systemctl consider it to be still inactive/broken, then handle it as a failure
|
# If we tried to reload/start/restart the service but systemctl consider it to be still inactive/broken, then handle it as a failure
|
||||||
if ([ "$action" == "reload" ] || [ "$action" == "start" ] || [ "$action" == "restart" ]) && ! systemctl --quiet is-active $service
|
if ([ "$action" == "reload" ] || [ "$action" == "start" ] || [ "$action" == "restart" ]) && ! systemctl --quiet is-active $service; then
|
||||||
then
|
|
||||||
_ynh_clean_check_starting
|
_ynh_clean_check_starting
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -12,7 +12,7 @@ ynh_system_user_exists() {
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
getent passwd "$username" &>/dev/null
|
getent passwd "$username" &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Check if a group exists on the system
|
# Check if a group exists on the system
|
||||||
|
@ -27,7 +27,7 @@ ynh_system_group_exists() {
|
||||||
ynh_handle_getopts_args "$@"
|
ynh_handle_getopts_args "$@"
|
||||||
# ===========================================
|
# ===========================================
|
||||||
|
|
||||||
getent group "$group" &>/dev/null
|
getent group "$group" &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create a system user
|
# Create a system user
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
# This option is meant for advanced use-cases where the "simple" templating
|
# This option is meant for advanced use-cases where the "simple" templating
|
||||||
# mode ain't enough because you need conditional blocks or loops.
|
# mode ain't enough because you need conditional blocks or loops.
|
||||||
#
|
#
|
||||||
# For a full documentation of jinja's syntax you can refer to:
|
# For a full documentation of jinja's syntax you can refer to:
|
||||||
# https://jinja.palletsprojects.com/en/3.1.x/templates/
|
# https://jinja.palletsprojects.com/en/3.1.x/templates/
|
||||||
#
|
#
|
||||||
# Note that in YunoHost context, all variables are from shell variables and therefore are strings
|
# Note that in YunoHost context, all variables are from shell variables and therefore are strings
|
||||||
|
@ -70,10 +70,9 @@ ynh_config_add() {
|
||||||
chmod 640 $destination
|
chmod 640 $destination
|
||||||
_ynh_apply_default_permissions $destination
|
_ynh_apply_default_permissions $destination
|
||||||
|
|
||||||
if [[ "$jinja" == 1 ]]
|
if [[ "$jinja" == 1 ]]; then
|
||||||
then
|
|
||||||
# This is ran in a subshell such that the "export" does not "contaminate" the main process
|
# This is ran in a subshell such that the "export" does not "contaminate" the main process
|
||||||
(
|
(
|
||||||
export $(compgen -v)
|
export $(compgen -v)
|
||||||
j2 "$template_path" -f env -o $destination
|
j2 "$template_path" -f env -o $destination
|
||||||
)
|
)
|
||||||
|
@ -216,7 +215,7 @@ ynh_read_var_in_file() {
|
||||||
var_part+='\s*'
|
var_part+='\s*'
|
||||||
|
|
||||||
# Extract the part after assignation sign
|
# Extract the part after assignation sign
|
||||||
local expression_with_comment="$((tail +$line_number ${file} | grep -i -o -P $var_part'\K.*$' || echo YNH_NULL) | head -n1)"
|
local expression_with_comment="$( (tail +$line_number ${file} | grep -i -o -P $var_part'\K.*$' || echo YNH_NULL) | head -n1)"
|
||||||
if [[ "$expression_with_comment" == "YNH_NULL" ]]; then
|
if [[ "$expression_with_comment" == "YNH_NULL" ]]; then
|
||||||
set -o xtrace # set -x
|
set -o xtrace # set -x
|
||||||
echo YNH_NULL
|
echo YNH_NULL
|
||||||
|
@ -292,7 +291,7 @@ ynh_write_var_in_file() {
|
||||||
var_part+='\s*'
|
var_part+='\s*'
|
||||||
|
|
||||||
# Extract the part after assignation sign
|
# Extract the part after assignation sign
|
||||||
local expression_with_comment="$((tail +$after_line_number ${file} | grep -i -o -P $var_part'\K.*$' || echo YNH_NULL) | head -n1)"
|
local expression_with_comment="$( (tail +$after_line_number ${file} | grep -i -o -P $var_part'\K.*$' || echo YNH_NULL) | head -n1)"
|
||||||
if [[ "$expression_with_comment" == "YNH_NULL" ]]; then
|
if [[ "$expression_with_comment" == "YNH_NULL" ]]; then
|
||||||
set -o xtrace # set -x
|
set -o xtrace # set -x
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -9,8 +9,7 @@ YNH_APP_BASEDIR=${YNH_APP_BASEDIR:-$(realpath ..)}
|
||||||
ynh_exit_properly() {
|
ynh_exit_properly() {
|
||||||
local exit_code=$?
|
local exit_code=$?
|
||||||
|
|
||||||
if [[ "${YNH_APP_ACTION:-}" =~ ^install$|^upgrade$|^restore$ ]]
|
if [[ "${YNH_APP_ACTION:-}" =~ ^install$|^upgrade$|^restore$ ]]; then
|
||||||
then
|
|
||||||
rm -rf "/var/cache/yunohost/download/"
|
rm -rf "/var/cache/yunohost/download/"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -47,8 +46,7 @@ ynh_abort_if_errors() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# When running an app script, auto-enable ynh_abort_if_errors except for remove script
|
# When running an app script, auto-enable ynh_abort_if_errors except for remove script
|
||||||
if [[ "${YNH_CONTEXT:-}" != "regenconf" ]] && [[ "${YNH_APP_ACTION}" != "remove" ]]
|
if [[ "${YNH_CONTEXT:-}" != "regenconf" ]] && [[ "${YNH_APP_ACTION}" != "remove" ]]; then
|
||||||
then
|
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -124,8 +122,7 @@ _acceptable_path_to_delete() {
|
||||||
local forbidden_paths=$(ls -d / /* /{var,home,usr}/* /etc/{default,sudoers.d,yunohost,cron*} /etc/yunohost/{apps,domains,hooks.d} /opt/yunohost 2> /dev/null)
|
local forbidden_paths=$(ls -d / /* /{var,home,usr}/* /etc/{default,sudoers.d,yunohost,cron*} /etc/yunohost/{apps,domains,hooks.d} /opt/yunohost 2> /dev/null)
|
||||||
|
|
||||||
# Legacy : A couple apps still have data in /home/$app ...
|
# Legacy : A couple apps still have data in /home/$app ...
|
||||||
if [[ -n "${app:-}" ]]
|
if [[ -n "${app:-}" ]]; then
|
||||||
then
|
|
||||||
forbidden_paths=$(echo "$forbidden_paths" | grep -v "/home/$app")
|
forbidden_paths=$(echo "$forbidden_paths" | grep -v "/home/$app")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -223,31 +220,27 @@ _ynh_apply_default_permissions() {
|
||||||
is_in_dir() {
|
is_in_dir() {
|
||||||
# Returns false if parent is empty
|
# Returns false if parent is empty
|
||||||
[ -n "$2" ] || return 1
|
[ -n "$2" ] || return 1
|
||||||
local child=$(realpath "$1" 2>/dev/null)
|
local child=$(realpath "$1" 2> /dev/null)
|
||||||
local parent=$(realpath "$2" 2>/dev/null)
|
local parent=$(realpath "$2" 2> /dev/null)
|
||||||
[[ "${child}" =~ ^$parent ]]
|
[[ "${child}" =~ ^$parent ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
# App files can have files of their own
|
# App files can have files of their own
|
||||||
if ynh_system_user_exists --username="$app"; then
|
if ynh_system_user_exists --username="$app"; then
|
||||||
# If this is a file in $install_dir or $data_dir : it should be owned and read+writable by $app only
|
# If this is a file in $install_dir or $data_dir : it should be owned and read+writable by $app only
|
||||||
if [ -f "$target" ] && (is_in_dir "$target" "${install_dir:-}" || is_in_dir "$target" "${data_dir:-}" || is_in_dir "$target" "/etc/$app")
|
if [ -f "$target" ] && (is_in_dir "$target" "${install_dir:-}" || is_in_dir "$target" "${data_dir:-}" || is_in_dir "$target" "/etc/$app"); then
|
||||||
then
|
|
||||||
chmod 600 "$target"
|
chmod 600 "$target"
|
||||||
chown "$app:$app" "$target"
|
chown "$app:$app" "$target"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
# If this is the install dir (so far this is the only way this helper is called with a directory)
|
# If this is the install dir (so far this is the only way this helper is called with a directory)
|
||||||
if [ "$target" == "${install_dir:-}" ]
|
if [ "$target" == "${install_dir:-}" ]; then
|
||||||
then
|
|
||||||
# Read the group from the install_dir manifest resource
|
# Read the group from the install_dir manifest resource
|
||||||
local group="$(ynh_read_manifest 'resources.install_dir.group' | sed 's/null//g' | sed "s/__APP__/$app/g" | cut -f1 -d:)"
|
local group="$(ynh_read_manifest 'resources.install_dir.group' | sed 's/null//g' | sed "s/__APP__/$app/g" | cut -f1 -d:)"
|
||||||
if [[ -z "$group" ]]
|
if [[ -z "$group" ]]; then
|
||||||
then
|
|
||||||
# We set the group to www-data for webapps that do serve static assets, which therefore need to be readable by nginx ...
|
# We set the group to www-data for webapps that do serve static assets, which therefore need to be readable by nginx ...
|
||||||
# The fact that the app needs this is infered by the existence of an nginx.conf and the presence of "alias" or "root" directive
|
# The fact that the app needs this is infered by the existence of an nginx.conf and the presence of "alias" or "root" directive
|
||||||
if grep -q '^\s*alias\s\|^\s*root\s' "$YNH_APP_BASEDIR/conf/nginx.conf" 2>/dev/null;
|
if grep -q '^\s*alias\s\|^\s*root\s' "$YNH_APP_BASEDIR/conf/nginx.conf" 2> /dev/null; then
|
||||||
then
|
|
||||||
group="www-data"
|
group="www-data"
|
||||||
# Or default to "$app"
|
# Or default to "$app"
|
||||||
else
|
else
|
||||||
|
@ -292,7 +285,7 @@ ynh_validate_ip() {
|
||||||
[ "$family" == "4" ] || [ "$family" == "6" ] || return 1
|
[ "$family" == "4" ] || [ "$family" == "6" ] || return 1
|
||||||
|
|
||||||
# http://stackoverflow.com/questions/319279/how-to-validate-ip-address-in-python#319298
|
# http://stackoverflow.com/questions/319279/how-to-validate-ip-address-in-python#319298
|
||||||
python3 /dev/stdin <<EOF
|
python3 /dev/stdin << EOF
|
||||||
import socket
|
import socket
|
||||||
import sys
|
import sys
|
||||||
family = { "4" : socket.AF_INET, "6" : socket.AF_INET6 }
|
family = { "4" : socket.AF_INET, "6" : socket.AF_INET6 }
|
||||||
|
@ -390,69 +383,201 @@ ynh_user_list() {
|
||||||
# from the app's service configuration file (defaults to $app.service, overridable by the packager with `service` setting).
|
# from the app's service configuration file (defaults to $app.service, overridable by the packager with `service` setting).
|
||||||
# If the app relies on a specific PHP version, then `php` will be aliased that version. The PHP command will also be appended with the `phpflags` settings.
|
# If the app relies on a specific PHP version, then `php` will be aliased that version. The PHP command will also be appended with the `phpflags` settings.
|
||||||
ynh_spawn_app_shell() {
|
ynh_spawn_app_shell() {
|
||||||
local app=$1
|
local app=$1
|
||||||
|
|
||||||
# Force Bash to be used to run this helper
|
# Force Bash to be used to run this helper
|
||||||
[[ $0 =~ \/?bash$ ]] || ynh_die "Please use Bash as shell"
|
[[ $0 =~ \/?bash$ ]] || ynh_die "Please use Bash as shell"
|
||||||
|
|
||||||
# Make sure the app is installed
|
# Make sure the app is installed
|
||||||
test -d /etc/yunohost/apps/$app || ynh_die "$app is not an installed app ?!"
|
test -d /etc/yunohost/apps/$app || ynh_die "$app is not an installed app ?!"
|
||||||
|
|
||||||
# Make sure the app has its own user
|
# Make sure the app has its own user
|
||||||
id -u "$app" &>/dev/null || ynh_die "There is no \"$app\" system user"
|
id -u "$app" &> /dev/null || ynh_die "There is no \"$app\" system user"
|
||||||
|
|
||||||
# Make sure the app has an install_dir setting
|
# Make sure the app has an install_dir setting
|
||||||
local install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
local install_dir=$(ynh_app_setting_get --app=$app --key=install_dir)
|
||||||
[ -n "$install_dir" ] || ynh_die "$app has no install_dir setting (does it use packaging format >=2?)"
|
[ -n "$install_dir" ] || ynh_die "$app has no install_dir setting (does it use packaging format >=2?)"
|
||||||
|
|
||||||
# Load the app's service name, or default to $app
|
# Load the app's service name, or default to $app
|
||||||
local service=$(ynh_app_setting_get --app=$app --key=service)
|
local service=$(ynh_app_setting_get --app=$app --key=service)
|
||||||
[ -z "$service" ] && service=$app;
|
[ -z "$service" ] && service=$app
|
||||||
|
|
||||||
# Export HOME variable
|
# Export HOME variable
|
||||||
export HOME=$install_dir;
|
export HOME=$install_dir
|
||||||
|
|
||||||
# Load the Environment variables from the app's service
|
# Load the Environment variables from the app's service
|
||||||
local env_var=$(systemctl show $service.service -p "Environment" --value)
|
local env_var=$(systemctl show $service.service -p "Environment" --value)
|
||||||
[ -n "$env_var" ] && export $env_var;
|
[ -n "$env_var" ] && export $env_var
|
||||||
|
|
||||||
# Force `php` to its intended version
|
# Force `php` to its intended version
|
||||||
# We use `eval`+`export` since `alias` is not propagated to subshells, even with `export`
|
# We use `eval`+`export` since `alias` is not propagated to subshells, even with `export`
|
||||||
local phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
local phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
local phpflags=$(ynh_app_setting_get --app=$app --key=phpflags)
|
local phpflags=$(ynh_app_setting_get --app=$app --key=phpflags)
|
||||||
if [ -n "$phpversion" ]
|
if [ -n "$phpversion" ]; then
|
||||||
then
|
eval "php() { php${phpversion} ${phpflags} \"\$@\"; }"
|
||||||
eval "php() { php${phpversion} ${phpflags} \"\$@\"; }"
|
export -f php
|
||||||
export -f php
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# Source the EnvironmentFiles from the app's service
|
# Source the EnvironmentFiles from the app's service
|
||||||
local env_files=($(systemctl show $service.service -p "EnvironmentFiles" --value))
|
local env_files=($(systemctl show $service.service -p "EnvironmentFiles" --value))
|
||||||
if [ ${#env_files[*]} -gt 0 ]
|
if [ ${#env_files[*]} -gt 0 ]; then
|
||||||
then
|
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
||||||
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
set -a
|
||||||
set -a
|
for file in ${env_files[*]}; do
|
||||||
for file in ${env_files[*]}
|
[[ $file = /* ]] && source $file
|
||||||
do
|
done
|
||||||
[[ $file = /* ]] && source $file
|
set +a
|
||||||
done
|
fi
|
||||||
set +a
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Activate the Python environment, if it exists
|
# Activate the Python environment, if it exists
|
||||||
if [ -f $install_dir/venv/bin/activate ]
|
if [ -f $install_dir/venv/bin/activate ]; then
|
||||||
then
|
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
||||||
# set -/+a enables and disables new variables being automatically exported. Needed when using `source`.
|
set -a
|
||||||
set -a
|
source $install_dir/venv/bin/activate
|
||||||
source $install_dir/venv/bin/activate
|
set +a
|
||||||
set +a
|
fi
|
||||||
fi
|
|
||||||
|
|
||||||
# cd into the WorkingDirectory set in the service, or default to the install_dir
|
# cd into the WorkingDirectory set in the service, or default to the install_dir
|
||||||
local env_dir=$(systemctl show $service.service -p "WorkingDirectory" --value)
|
local env_dir=$(systemctl show $service.service -p "WorkingDirectory" --value)
|
||||||
[ -z $env_dir ] && env_dir=$install_dir;
|
[ -z $env_dir ] && env_dir=$install_dir
|
||||||
cd $env_dir
|
cd $env_dir
|
||||||
|
|
||||||
# Spawn the app shell
|
# Spawn the app shell
|
||||||
su -s /bin/bash $app
|
su -s /bin/bash $app
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add swap
|
||||||
|
#
|
||||||
|
# usage: ynh_add_swap --size=SWAP in Mb
|
||||||
|
# | arg: -s, --size= - Amount of SWAP to add in Mb.
|
||||||
|
ynh_add_swap() {
|
||||||
|
if systemd-detect-virt --container --quiet; then
|
||||||
|
ynh_print_warn --message="You are inside a container/VM. swap will not be added, but that can cause troubles for the app $app. Please make sure you have enough RAM available."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
declare -Ar args_array=([s]=size=)
|
||||||
|
local size
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
|
local swap_max_size=$(($size * 1024))
|
||||||
|
|
||||||
|
local free_space=$(df --output=avail / | sed 1d)
|
||||||
|
# Because we don't want to fill the disk with a swap file, divide by 2 the available space.
|
||||||
|
local usable_space=$(($free_space / 2))
|
||||||
|
|
||||||
|
SD_CARD_CAN_SWAP=${SD_CARD_CAN_SWAP:-0}
|
||||||
|
|
||||||
|
# Swap on SD card only if it's is specified
|
||||||
|
if ynh_is_main_device_a_sd_card && [ "$SD_CARD_CAN_SWAP" == "0" ]; then
|
||||||
|
ynh_print_warn --message="The main mountpoint of your system '/' is on an SD card, swap will not be added to prevent some damage of this one, but that can cause troubles for the app $app. If you still want activate the swap, you can relaunch the command preceded by 'SD_CARD_CAN_SWAP=1'"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Compare the available space with the size of the swap.
|
||||||
|
# And set a acceptable size from the request
|
||||||
|
if [ $usable_space -ge $swap_max_size ]; then
|
||||||
|
local swap_size=$swap_max_size
|
||||||
|
elif [ $usable_space -ge $(($swap_max_size / 2)) ]; then
|
||||||
|
local swap_size=$(($swap_max_size / 2))
|
||||||
|
elif [ $usable_space -ge $(($swap_max_size / 3)) ]; then
|
||||||
|
local swap_size=$(($swap_max_size / 3))
|
||||||
|
elif [ $usable_space -ge $(($swap_max_size / 4)) ]; then
|
||||||
|
local swap_size=$(($swap_max_size / 4))
|
||||||
|
else
|
||||||
|
echo "Not enough space left for a swap file" >&2
|
||||||
|
local swap_size=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If there's enough space for a swap, and no existing swap here
|
||||||
|
if [ $swap_size -ne 0 ] && [ ! -e /swap_$app ]; then
|
||||||
|
# Create file
|
||||||
|
truncate -s 0 /swap_$app
|
||||||
|
|
||||||
|
# set the No_COW attribute on the swapfile with chattr
|
||||||
|
chattr +C /swap_$app
|
||||||
|
|
||||||
|
# Preallocate space for the swap file, fallocate may sometime not be used, use dd instead in this case
|
||||||
|
if ! fallocate -l ${swap_size}K /swap_$app; then
|
||||||
|
dd if=/dev/zero of=/swap_$app bs=1024 count=${swap_size}
|
||||||
|
fi
|
||||||
|
chmod 0600 /swap_$app
|
||||||
|
# Create the swap
|
||||||
|
mkswap /swap_$app
|
||||||
|
# And activate it
|
||||||
|
swapon /swap_$app
|
||||||
|
# Then add an entry in fstab to load this swap at each boot.
|
||||||
|
echo -e "/swap_$app swap swap defaults 0 0 #Swap added by $app" >> /etc/fstab
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
ynh_del_swap() {
|
||||||
|
# If there a swap at this place
|
||||||
|
if [ -e /swap_$app ]; then
|
||||||
|
# Clean the fstab
|
||||||
|
sed -i "/#Swap added by $app/d" /etc/fstab
|
||||||
|
# Desactive the swap file
|
||||||
|
swapoff /swap_$app
|
||||||
|
# And remove it
|
||||||
|
rm /swap_$app
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check if the device of the main mountpoint "/" is an SD card
|
||||||
|
#
|
||||||
|
# [internal]
|
||||||
|
#
|
||||||
|
# return 0 if it's an SD card, else 1
|
||||||
|
ynh_is_main_device_a_sd_card() {
|
||||||
|
if [ "$(systemd-detect-virt)" != "none" ]; then
|
||||||
|
# Assume virtualization does not take place on SD card
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
local main_device=$(lsblk --output PKNAME --noheadings $(findmnt / --nofsroot --uniq --output source --noheadings --first-only))
|
||||||
|
|
||||||
|
if echo $main_device | grep --quiet "mmc" && [ $(tail -n1 /sys/block/$main_device/queue/rotational) == "0" ]; then
|
||||||
|
return 0
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Check available space before creating a temp directory.
|
||||||
|
#
|
||||||
|
# usage: ynh_smart_mktemp --min_size="Min size"
|
||||||
|
#
|
||||||
|
# | arg: -s, --min_size= - Minimal size needed for the temporary directory, in Mb
|
||||||
|
ynh_smart_mktemp() {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
declare -Ar args_array=([s]=min_size=)
|
||||||
|
local min_size
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
|
min_size="${min_size:-300}"
|
||||||
|
# Transform the minimum size from megabytes to kilobytes
|
||||||
|
min_size=$(($min_size * 1024))
|
||||||
|
|
||||||
|
# Check if there's enough free space in a directory
|
||||||
|
is_there_enough_space() {
|
||||||
|
local free_space=$(df --output=avail "$1" | sed 1d)
|
||||||
|
test $free_space -ge $min_size
|
||||||
|
}
|
||||||
|
|
||||||
|
if is_there_enough_space /tmp; then
|
||||||
|
local tmpdir=/tmp
|
||||||
|
elif is_there_enough_space /var; then
|
||||||
|
local tmpdir=/var
|
||||||
|
elif is_there_enough_space /; then
|
||||||
|
local tmpdir=/
|
||||||
|
elif is_there_enough_space /home; then
|
||||||
|
local tmpdir=/home
|
||||||
|
else
|
||||||
|
ynh_die "Insufficient free space to continue..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "$(mktemp --directory --tmpdir="$tmpdir")"
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ YNH_CWD="${YNH_BACKUP_DIR%/}/conf/manually_modified_files"
|
||||||
mkdir -p "$YNH_CWD"
|
mkdir -p "$YNH_CWD"
|
||||||
cd "$YNH_CWD"
|
cd "$YNH_CWD"
|
||||||
|
|
||||||
yunohost tools shell -c "from yunohost.regenconf import manually_modified_files; print('\n'.join(manually_modified_files()))" >./manually_modified_files_list
|
yunohost tools shell -c "from yunohost.regenconf import manually_modified_files; print('\n'.join(manually_modified_files()))" > ./manually_modified_files_list
|
||||||
|
|
||||||
ynh_backup --src_path="./manually_modified_files_list"
|
ynh_backup --src_path="./manually_modified_files_list"
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ do_init_regen() {
|
||||||
|
|
||||||
# set default current_host
|
# set default current_host
|
||||||
[[ -f /etc/yunohost/current_host ]] \
|
[[ -f /etc/yunohost/current_host ]] \
|
||||||
|| echo "yunohost.org" >/etc/yunohost/current_host
|
|| echo "yunohost.org" > /etc/yunohost/current_host
|
||||||
|
|
||||||
# copy default services and firewall
|
# copy default services and firewall
|
||||||
[[ -f /etc/yunohost/firewall.yml ]] \
|
[[ -f /etc/yunohost/firewall.yml ]] \
|
||||||
|
@ -45,7 +45,7 @@ do_init_regen() {
|
||||||
chown root:root /home/yunohost.backup/archives # This is later changed to root:admins once the admins group exists
|
chown root:root /home/yunohost.backup/archives # This is later changed to root:admins once the admins group exists
|
||||||
|
|
||||||
# Empty ssowat json persistent conf
|
# Empty ssowat json persistent conf
|
||||||
echo "{}" >'/etc/ssowat/conf.json.persistent'
|
echo "{}" > '/etc/ssowat/conf.json.persistent'
|
||||||
chmod 644 /etc/ssowat/conf.json.persistent
|
chmod 644 /etc/ssowat/conf.json.persistent
|
||||||
chown root:root /etc/ssowat/conf.json.persistent
|
chown root:root /etc/ssowat/conf.json.persistent
|
||||||
|
|
||||||
|
@ -74,8 +74,7 @@ do_init_regen() {
|
||||||
|
|
||||||
# Change dpkg vendor
|
# Change dpkg vendor
|
||||||
# see https://wiki.debian.org/Derivatives/Guidelines#Vendor
|
# see https://wiki.debian.org/Derivatives/Guidelines#Vendor
|
||||||
if readlink -f /etc/dpkg/origins/default | grep -q debian;
|
if readlink -f /etc/dpkg/origins/default | grep -q debian; then
|
||||||
then
|
|
||||||
rm -f /etc/dpkg/origins/default
|
rm -f /etc/dpkg/origins/default
|
||||||
ln -s /etc/dpkg/origins/yunohost /etc/dpkg/origins/default
|
ln -s /etc/dpkg/origins/yunohost /etc/dpkg/origins/default
|
||||||
fi
|
fi
|
||||||
|
@ -93,19 +92,19 @@ do_pre_regen() {
|
||||||
# add cron job for diagnosis to be ran at 7h and 19h + a random delay between
|
# add cron job for diagnosis to be ran at 7h and 19h + a random delay between
|
||||||
# 0 and 20min, meant to avoid every instances running their diagnosis at
|
# 0 and 20min, meant to avoid every instances running their diagnosis at
|
||||||
# exactly the same time, which may overload the diagnosis server.
|
# exactly the same time, which may overload the diagnosis server.
|
||||||
cat >$pending_dir/etc/cron.d/yunohost-diagnosis <<EOF
|
cat > $pending_dir/etc/cron.d/yunohost-diagnosis << EOF
|
||||||
SHELL=/bin/bash
|
SHELL=/bin/bash
|
||||||
0 7,19 * * * root : YunoHost Automatic Diagnosis; sleep \$((RANDOM\\%1200)); yunohost diagnosis run --email > /dev/null 2>/dev/null || echo "Running the automatic diagnosis failed miserably"
|
0 7,19 * * * root : YunoHost Automatic Diagnosis; sleep \$((RANDOM\\%1200)); yunohost diagnosis run --email > /dev/null 2>/dev/null || echo "Running the automatic diagnosis failed miserably"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Cron job that upgrade the app list everyday
|
# Cron job that upgrade the app list everyday
|
||||||
cat >$pending_dir/etc/cron.daily/yunohost-fetch-apps-catalog <<EOF
|
cat > $pending_dir/etc/cron.daily/yunohost-fetch-apps-catalog << EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
sleep \$((RANDOM%3600)); yunohost tools update apps > /dev/null
|
sleep \$((RANDOM%3600)); yunohost tools update apps > /dev/null
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
# Cron job that renew lets encrypt certificates if there's any that needs renewal
|
# Cron job that renew lets encrypt certificates if there's any that needs renewal
|
||||||
cat >$pending_dir/etc/cron.daily/yunohost-certificate-renew <<EOF
|
cat > $pending_dir/etc/cron.daily/yunohost-certificate-renew << EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
yunohost domain cert renew --email
|
yunohost domain cert renew --email
|
||||||
EOF
|
EOF
|
||||||
|
@ -113,8 +112,8 @@ EOF
|
||||||
# If we subscribed to a dyndns domain, add the corresponding cron
|
# If we subscribed to a dyndns domain, add the corresponding cron
|
||||||
# - delay between 0 and 60 secs to spread the check over a 1 min window
|
# - delay between 0 and 60 secs to spread the check over a 1 min window
|
||||||
# - do not run the command if some process already has the lock, to avoid queuing hundreds of commands...
|
# - do not run the command if some process already has the lock, to avoid queuing hundreds of commands...
|
||||||
if ls -l /etc/yunohost/dyndns/K*.key 2>/dev/null; then
|
if ls -l /etc/yunohost/dyndns/K*.key 2> /dev/null; then
|
||||||
cat >$pending_dir/etc/cron.d/yunohost-dyndns <<EOF
|
cat > $pending_dir/etc/cron.d/yunohost-dyndns << EOF
|
||||||
SHELL=/bin/bash
|
SHELL=/bin/bash
|
||||||
# Every 10 minutes,
|
# Every 10 minutes,
|
||||||
# - (sleep random 60 is here to spread requests over a 1-min window)
|
# - (sleep random 60 is here to spread requests over a 1-min window)
|
||||||
|
@ -129,10 +128,9 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Skip ntp if inside a container (inspired from the conf of systemd-timesyncd)
|
# Skip ntp if inside a container (inspired from the conf of systemd-timesyncd)
|
||||||
if systemctl | grep -q 'ntp.service'
|
if systemctl | grep -q 'ntp.service'; then
|
||||||
then
|
|
||||||
mkdir -p ${pending_dir}/etc/systemd/system/ntp.service.d/
|
mkdir -p ${pending_dir}/etc/systemd/system/ntp.service.d/
|
||||||
cat >${pending_dir}/etc/systemd/system/ntp.service.d/ynh-override.conf <<EOF
|
cat > ${pending_dir}/etc/systemd/system/ntp.service.d/ynh-override.conf << EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
ConditionCapability=CAP_SYS_TIME
|
ConditionCapability=CAP_SYS_TIME
|
||||||
ConditionVirtualization=!container
|
ConditionVirtualization=!container
|
||||||
|
@ -141,7 +139,7 @@ EOF
|
||||||
|
|
||||||
# Make nftable conflict with yunohost-firewall
|
# Make nftable conflict with yunohost-firewall
|
||||||
mkdir -p ${pending_dir}/etc/systemd/system/nftables.service.d/
|
mkdir -p ${pending_dir}/etc/systemd/system/nftables.service.d/
|
||||||
cat >${pending_dir}/etc/systemd/system/nftables.service.d/ynh-override.conf <<EOF
|
cat > ${pending_dir}/etc/systemd/system/nftables.service.d/ynh-override.conf << EOF
|
||||||
[Unit]
|
[Unit]
|
||||||
# yunohost-firewall and nftables conflict with each other
|
# yunohost-firewall and nftables conflict with each other
|
||||||
Conflicts=yunohost-firewall.service
|
Conflicts=yunohost-firewall.service
|
||||||
|
@ -151,7 +149,7 @@ EOF
|
||||||
|
|
||||||
# Don't suspend computer on LidSwitch
|
# Don't suspend computer on LidSwitch
|
||||||
mkdir -p ${pending_dir}/etc/systemd/logind.conf.d/
|
mkdir -p ${pending_dir}/etc/systemd/logind.conf.d/
|
||||||
cat >${pending_dir}/etc/systemd/logind.conf.d/ynh-override.conf <<EOF
|
cat > ${pending_dir}/etc/systemd/logind.conf.d/ynh-override.conf << EOF
|
||||||
[Login]
|
[Login]
|
||||||
HandleLidSwitch=ignore
|
HandleLidSwitch=ignore
|
||||||
HandleLidSwitchDocked=ignore
|
HandleLidSwitchDocked=ignore
|
||||||
|
@ -192,8 +190,7 @@ do_post_regen() {
|
||||||
find /etc/systemd/system/*.service -type f | xargs -r chown root:root
|
find /etc/systemd/system/*.service -type f | xargs -r chown root:root
|
||||||
find /etc/systemd/system/*.service -type f | xargs -r chmod 0644
|
find /etc/systemd/system/*.service -type f | xargs -r chmod 0644
|
||||||
|
|
||||||
if ls -l /etc/php/*/fpm/pool.d/*.conf
|
if ls -l /etc/php/*/fpm/pool.d/*.conf; then
|
||||||
then
|
|
||||||
chown root:root /etc/php/*/fpm/pool.d/*.conf
|
chown root:root /etc/php/*/fpm/pool.d/*.conf
|
||||||
chmod 644 /etc/php/*/fpm/pool.d/*.conf
|
chmod 644 /etc/php/*/fpm/pool.d/*.conf
|
||||||
fi
|
fi
|
||||||
|
@ -222,8 +219,8 @@ do_post_regen() {
|
||||||
mkdir -p /etc/yunohost/domains
|
mkdir -p /etc/yunohost/domains
|
||||||
|
|
||||||
# Misc configuration / state files
|
# Misc configuration / state files
|
||||||
chown root:root $(ls /etc/yunohost/{*.yml,*.yaml,*.json,mysql,psql} 2>/dev/null | grep -vw mdns.yml)
|
chown root:root $(ls /etc/yunohost/{*.yml,*.yaml,*.json,mysql,psql} 2> /dev/null | grep -vw mdns.yml)
|
||||||
chmod 600 $(ls /etc/yunohost/{*.yml,*.yaml,*.json,mysql,psql} 2>/dev/null)
|
chmod 600 $(ls /etc/yunohost/{*.yml,*.yaml,*.json,mysql,psql} 2> /dev/null)
|
||||||
|
|
||||||
# Apps folder, custom hooks folder
|
# Apps folder, custom hooks folder
|
||||||
[[ ! -e /etc/yunohost/hooks.d ]] || (chown root /etc/yunohost/hooks.d && chmod 700 /etc/yunohost/hooks.d)
|
[[ ! -e /etc/yunohost/hooks.d ]] || (chown root /etc/yunohost/hooks.d && chmod 700 /etc/yunohost/hooks.d)
|
||||||
|
@ -235,15 +232,14 @@ do_post_regen() {
|
||||||
grep -q '^sftp.app:' /etc/group || groupadd sftp.app
|
grep -q '^sftp.app:' /etc/group || groupadd sftp.app
|
||||||
|
|
||||||
# Propagates changes in systemd service config overrides
|
# Propagates changes in systemd service config overrides
|
||||||
if systemctl | grep -q 'ntp.service'
|
if systemctl | grep -q 'ntp.service'; then
|
||||||
then
|
|
||||||
[[ ! "$regen_conf_files" =~ "ntp.service.d/ynh-override.conf" ]] || {
|
[[ ! "$regen_conf_files" =~ "ntp.service.d/ynh-override.conf" ]] || {
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl restart ntp
|
systemctl restart ntp
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
[[ ! "$regen_conf_files" =~ "nftables.service.d/ynh-override.conf" ]] || systemctl daemon-reload
|
[[ ! "$regen_conf_files" =~ "nftables.service.d/ynh-override.conf" ]] || systemctl daemon-reload
|
||||||
[[ ! "$regen_conf_files" =~ "login.conf.d/ynh-override.conf" ]] || {
|
[[ ! "$regen_conf_files" =~ "login.conf.d/ynh-override.conf" ]] || {
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl restart systemd-logind
|
systemctl restart systemd-logind
|
||||||
}
|
}
|
||||||
|
@ -263,14 +259,12 @@ do_post_regen() {
|
||||||
|
|
||||||
# Change dpkg vendor
|
# Change dpkg vendor
|
||||||
# see https://wiki.debian.org/Derivatives/Guidelines#Vendor
|
# see https://wiki.debian.org/Derivatives/Guidelines#Vendor
|
||||||
if readlink -f /etc/dpkg/origins/default | grep -q debian;
|
if readlink -f /etc/dpkg/origins/default | grep -q debian; then
|
||||||
then
|
|
||||||
rm -f /etc/dpkg/origins/default
|
rm -f /etc/dpkg/origins/default
|
||||||
ln -s /etc/dpkg/origins/yunohost /etc/dpkg/origins/default
|
ln -s /etc/dpkg/origins/yunohost /etc/dpkg/origins/default
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -e /etc/yunohost/installed && test -e /etc/profile.d/check_yunohost_is_installed.sh
|
if test -e /etc/yunohost/installed && test -e /etc/profile.d/check_yunohost_is_installed.sh; then
|
||||||
then
|
|
||||||
rm /etc/profile.d/check_yunohost_is_installed.sh
|
rm /etc/profile.d/check_yunohost_is_installed.sh
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ regen_local_ca() {
|
||||||
# (Update the serial so that it's specific to this very instance)
|
# (Update the serial so that it's specific to this very instance)
|
||||||
# N.B. : the weird RANDFILE thing comes from:
|
# N.B. : the weird RANDFILE thing comes from:
|
||||||
# https://stackoverflow.com/questions/94445/using-openssl-what-does-unable-to-write-random-state-mean
|
# https://stackoverflow.com/questions/94445/using-openssl-what-does-unable-to-write-random-state-mean
|
||||||
RANDFILE=.rnd openssl rand -hex 19 >serial
|
RANDFILE=.rnd openssl rand -hex 19 > serial
|
||||||
rm -f index.txt
|
rm -f index.txt
|
||||||
touch index.txt
|
touch index.txt
|
||||||
cp ${template_dir}/openssl.cnf openssl.ca.cnf
|
cp ${template_dir}/openssl.cnf openssl.ca.cnf
|
||||||
|
@ -51,7 +51,7 @@ regen_local_ca() {
|
||||||
do_init_regen() {
|
do_init_regen() {
|
||||||
|
|
||||||
LOGFILE=/tmp/yunohost-ssl-init
|
LOGFILE=/tmp/yunohost-ssl-init
|
||||||
echo "" >$LOGFILE
|
echo "" > $LOGFILE
|
||||||
chown root:root $LOGFILE
|
chown root:root $LOGFILE
|
||||||
chmod 640 $LOGFILE
|
chmod 640 $LOGFILE
|
||||||
|
|
||||||
|
@ -61,24 +61,24 @@ do_init_regen() {
|
||||||
|
|
||||||
# create default certificates
|
# create default certificates
|
||||||
if [[ ! -f "$ynh_ca" ]]; then
|
if [[ ! -f "$ynh_ca" ]]; then
|
||||||
regen_local_ca yunohost.org >>$LOGFILE
|
regen_local_ca yunohost.org >> $LOGFILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f "$ynh_crt" ]]; then
|
if [[ ! -f "$ynh_crt" ]]; then
|
||||||
echo -e "\n# Creating initial key and certificate \n" >>$LOGFILE
|
echo -e "\n# Creating initial key and certificate \n" >> $LOGFILE
|
||||||
|
|
||||||
openssl req -new \
|
openssl req -new \
|
||||||
-config "${ssl_dir}/openssl.cnf" \
|
-config "${ssl_dir}/openssl.cnf" \
|
||||||
-out "${ssl_dir}/certs/yunohost_csr.pem" \
|
-out "${ssl_dir}/certs/yunohost_csr.pem" \
|
||||||
-keyout "${ssl_dir}/certs/yunohost_key.pem" \
|
-keyout "${ssl_dir}/certs/yunohost_key.pem" \
|
||||||
-nodes -batch &>>$LOGFILE
|
-nodes -batch &>> $LOGFILE
|
||||||
|
|
||||||
openssl ca \
|
openssl ca \
|
||||||
-config "${ssl_dir}/openssl.cnf" \
|
-config "${ssl_dir}/openssl.cnf" \
|
||||||
-days 730 \
|
-days 730 \
|
||||||
-in "${ssl_dir}/certs/yunohost_csr.pem" \
|
-in "${ssl_dir}/certs/yunohost_csr.pem" \
|
||||||
-out "${ssl_dir}/certs/yunohost_crt.pem" \
|
-out "${ssl_dir}/certs/yunohost_crt.pem" \
|
||||||
-batch &>>$LOGFILE
|
-batch &>> $LOGFILE
|
||||||
|
|
||||||
chmod 640 "${ssl_dir}/certs/yunohost_key.pem"
|
chmod 640 "${ssl_dir}/certs/yunohost_key.pem"
|
||||||
chmod 640 "${ssl_dir}/certs/yunohost_crt.pem"
|
chmod 640 "${ssl_dir}/certs/yunohost_crt.pem"
|
||||||
|
@ -104,10 +104,9 @@ do_post_regen() {
|
||||||
|
|
||||||
current_local_ca_domain=$(openssl x509 -in $ynh_ca -text | tr ',' '\n' | grep Issuer | awk '{print $4}')
|
current_local_ca_domain=$(openssl x509 -in $ynh_ca -text | tr ',' '\n' | grep Issuer | awk '{print $4}')
|
||||||
main_domain=$(cat /etc/yunohost/current_host)
|
main_domain=$(cat /etc/yunohost/current_host)
|
||||||
|
|
||||||
# Automigrate legacy folder
|
# Automigrate legacy folder
|
||||||
if [ -e /usr/share/yunohost/yunohost-config/ssl/yunoCA ]
|
if [ -e /usr/share/yunohost/yunohost-config/ssl/yunoCA ]; then
|
||||||
then
|
|
||||||
mv /usr/share/yunohost/yunohost-config/ssl/yunoCA/* ${ssl_dir}
|
mv /usr/share/yunohost/yunohost-config/ssl/yunoCA/* ${ssl_dir}
|
||||||
rm -rf /usr/share/yunohost/yunohost-config
|
rm -rf /usr/share/yunohost/yunohost-config
|
||||||
# Overwrite openssl.cnf because it may still contain references to the old yunoCA dir
|
# Overwrite openssl.cnf because it may still contain references to the old yunoCA dir
|
||||||
|
@ -120,7 +119,7 @@ do_post_regen() {
|
||||||
chown root:root ${ssl_dir}
|
chown root:root ${ssl_dir}
|
||||||
chmod 750 ${ssl_dir}
|
chmod 750 ${ssl_dir}
|
||||||
chmod -R o-rwx ${ssl_dir}
|
chmod -R o-rwx ${ssl_dir}
|
||||||
chmod o+x ${ssl_dir}/certs
|
chmod o+x ${ssl_dir}/certs
|
||||||
chmod o+r ${ssl_dir}/certs/yunohost_crt.pem
|
chmod o+r ${ssl_dir}/certs/yunohost_crt.pem
|
||||||
|
|
||||||
if [[ "$current_local_ca_domain" != "$main_domain" ]]; then
|
if [[ "$current_local_ca_domain" != "$main_domain" ]]; then
|
||||||
|
|
|
@ -12,7 +12,7 @@ do_pre_regen() {
|
||||||
# do not listen to IPv6 if unavailable
|
# do not listen to IPv6 if unavailable
|
||||||
[[ -f /proc/net/if_inet6 ]] && ipv6_enabled=true || ipv6_enabled=false
|
[[ -f /proc/net/if_inet6 ]] && ipv6_enabled=true || ipv6_enabled=false
|
||||||
|
|
||||||
ssh_keys=$(ls /etc/ssh/ssh_host_{ed25519,rsa,ecdsa}_key 2>/dev/null || true)
|
ssh_keys=$(ls /etc/ssh/ssh_host_{ed25519,rsa,ecdsa}_key 2> /dev/null || true)
|
||||||
|
|
||||||
# Support different strategy for security configurations
|
# Support different strategy for security configurations
|
||||||
export compatibility="$(yunohost settings get 'security.ssh.ssh_compatibility')"
|
export compatibility="$(yunohost settings get 'security.ssh.ssh_compatibility')"
|
||||||
|
|
|
@ -20,7 +20,7 @@ do_init_regen() {
|
||||||
rm -rf /var/backups/*.ldapdb
|
rm -rf /var/backups/*.ldapdb
|
||||||
rm -rf /var/backups/slapd-*
|
rm -rf /var/backups/slapd-*
|
||||||
|
|
||||||
debconf-set-selections <<EOF
|
debconf-set-selections << EOF
|
||||||
slapd slapd/password1 password yunohost
|
slapd slapd/password1 password yunohost
|
||||||
slapd slapd/password2 password yunohost
|
slapd slapd/password2 password yunohost
|
||||||
slapd slapd/domain string yunohost.org
|
slapd slapd/domain string yunohost.org
|
||||||
|
@ -87,13 +87,13 @@ do_pre_regen() {
|
||||||
rm -f "$tmp_backup_dir_file"
|
rm -f "$tmp_backup_dir_file"
|
||||||
|
|
||||||
# Define if we need to migrate from hdb to mdb
|
# Define if we need to migrate from hdb to mdb
|
||||||
curr_backend=$(grep '^database' /etc/ldap/slapd.conf 2>/dev/null | awk '{print $2}')
|
curr_backend=$(grep '^database' /etc/ldap/slapd.conf 2> /dev/null | awk '{print $2}')
|
||||||
if [ -e /etc/ldap/slapd.conf ] && [ -n "$curr_backend" ] \
|
if [ -e /etc/ldap/slapd.conf ] && [ -n "$curr_backend" ] \
|
||||||
&& [ $curr_backend != 'mdb' ]; then
|
&& [ $curr_backend != 'mdb' ]; then
|
||||||
backup_dir="/var/backups/dc=yunohost,dc=org-${curr_backend}-$(date +%s)"
|
backup_dir="/var/backups/dc=yunohost,dc=org-${curr_backend}-$(date +%s)"
|
||||||
mkdir -p "$backup_dir"
|
mkdir -p "$backup_dir"
|
||||||
slapcat -b dc=yunohost,dc=org -l "${backup_dir}/dc=yunohost-dc=org.ldif"
|
slapcat -b dc=yunohost,dc=org -l "${backup_dir}/dc=yunohost-dc=org.ldif"
|
||||||
echo "$backup_dir" >"$tmp_backup_dir_file"
|
echo "$backup_dir" > "$tmp_backup_dir_file"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# create needed directories
|
# create needed directories
|
||||||
|
@ -155,7 +155,7 @@ objectClass: top"
|
||||||
_regenerate_slapd_conf
|
_regenerate_slapd_conf
|
||||||
|
|
||||||
# If there's a backup, re-import its data
|
# If there's a backup, re-import its data
|
||||||
backup_dir=$(cat "$tmp_backup_dir_file" 2>/dev/null || true)
|
backup_dir=$(cat "$tmp_backup_dir_file" 2> /dev/null || true)
|
||||||
if [[ -n "$backup_dir" && -f "${backup_dir}/dc=yunohost-dc=org.ldif" ]]; then
|
if [[ -n "$backup_dir" && -f "${backup_dir}/dc=yunohost-dc=org.ldif" ]]; then
|
||||||
# regenerate LDAP config directory and import database as root
|
# regenerate LDAP config directory and import database as root
|
||||||
echo "Import the database using slapadd"
|
echo "Import the database using slapadd"
|
||||||
|
|
|
@ -17,14 +17,14 @@ do_pre_regen() {
|
||||||
echo "
|
echo "
|
||||||
Package: php-common
|
Package: php-common
|
||||||
Pin: origin \"packages.sury.org\"
|
Pin: origin \"packages.sury.org\"
|
||||||
Pin-Priority: 500" >>"${pending_dir}/etc/apt/preferences.d/extra_php_version"
|
Pin-Priority: 500" >> "${pending_dir}/etc/apt/preferences.d/extra_php_version"
|
||||||
|
|
||||||
packages_to_refuse_from_sury="php php-* openssl libssl1.1 libssl-dev"
|
packages_to_refuse_from_sury="php php-* openssl libssl1.1 libssl-dev"
|
||||||
for package in $packages_to_refuse_from_sury; do
|
for package in $packages_to_refuse_from_sury; do
|
||||||
echo "
|
echo "
|
||||||
Package: $package
|
Package: $package
|
||||||
Pin: origin \"packages.sury.org\"
|
Pin: origin \"packages.sury.org\"
|
||||||
Pin-Priority: -1" >>"${pending_dir}/etc/apt/preferences.d/extra_php_version"
|
Pin-Priority: -1" >> "${pending_dir}/etc/apt/preferences.d/extra_php_version"
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "
|
echo "
|
||||||
|
@ -54,8 +54,7 @@ Pin-Priority: -1
|
||||||
Package: bind9
|
Package: bind9
|
||||||
Pin: release *
|
Pin: release *
|
||||||
Pin-Priority: -1
|
Pin-Priority: -1
|
||||||
" >>"${pending_dir}/etc/apt/preferences.d/ban_packages"
|
" >> "${pending_dir}/etc/apt/preferences.d/ban_packages"
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,19 +62,17 @@ do_post_regen() {
|
||||||
regen_conf_files=$1
|
regen_conf_files=$1
|
||||||
|
|
||||||
# Purge expired keys (such as sury 95BD4743)
|
# Purge expired keys (such as sury 95BD4743)
|
||||||
EXPIRED_KEYS="$(LC_ALL='en_US.UTF-8' apt-key list 2>/dev/null | grep -A1 'expired:' | grep -v 'expired\|^-' | sed 's/\s//g')"
|
EXPIRED_KEYS="$(LC_ALL='en_US.UTF-8' apt-key list 2> /dev/null | grep -A1 'expired:' | grep -v 'expired\|^-' | sed 's/\s//g')"
|
||||||
for KEY in $EXPIRED_KEYS; do apt-key del $KEY 2>/dev/null; done
|
for KEY in $EXPIRED_KEYS; do apt-key del $KEY 2> /dev/null; done
|
||||||
|
|
||||||
# Add sury key
|
# Add sury key
|
||||||
# We do this only at the post regen and if the key doesn't already exists, because we don't want the regenconf to fuck everything up if the regenconf runs while the network is down
|
# We do this only at the post regen and if the key doesn't already exists, because we don't want the regenconf to fuck everything up if the regenconf runs while the network is down
|
||||||
if [[ ! -s /etc/apt/trusted.gpg.d/extra_php_version.gpg ]]
|
if [[ ! -s /etc/apt/trusted.gpg.d/extra_php_version.gpg ]]; then
|
||||||
then
|
wget --timeout 900 --quiet "https://packages.sury.org/php/apt.gpg" --output-document=- | gpg --dearmor > "/etc/apt/trusted.gpg.d/extra_php_version.gpg"
|
||||||
wget --timeout 900 --quiet "https://packages.sury.org/php/apt.gpg" --output-document=- | gpg --dearmor >"/etc/apt/trusted.gpg.d/extra_php_version.gpg"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure php7.4 is the default version when using php in cli
|
# Make sure php7.4 is the default version when using php in cli
|
||||||
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
if test -e /usr/bin/php$YNH_DEFAULT_PHP_VERSION; then
|
||||||
then
|
|
||||||
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
update-alternatives --set php /usr/bin/php$YNH_DEFAULT_PHP_VERSION
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,7 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if ! dpkg --list | grep -q 'ii *metronome '
|
if ! dpkg --list | grep -q 'ii *metronome '; then
|
||||||
then
|
|
||||||
echo 'metronome is not installed, skipping'
|
echo 'metronome is not installed, skipping'
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
@ -24,7 +23,7 @@ do_pre_regen() {
|
||||||
# install main conf file
|
# install main conf file
|
||||||
cat metronome.cfg.lua \
|
cat metronome.cfg.lua \
|
||||||
| sed "s/{{ main_domain }}/${main_domain}/g" \
|
| sed "s/{{ main_domain }}/${main_domain}/g" \
|
||||||
>"${metronome_dir}/metronome.cfg.lua"
|
> "${metronome_dir}/metronome.cfg.lua"
|
||||||
|
|
||||||
# Trick such that old conf files are flagged as to remove
|
# Trick such that old conf files are flagged as to remove
|
||||||
for domain in $YNH_DOMAINS; do
|
for domain in $YNH_DOMAINS; do
|
||||||
|
@ -36,7 +35,7 @@ do_pre_regen() {
|
||||||
for domain in $domain_list; do
|
for domain in $domain_list; do
|
||||||
cat domain.tpl.cfg.lua \
|
cat domain.tpl.cfg.lua \
|
||||||
| sed "s/{{ domain }}/${domain}/g" \
|
| sed "s/{{ domain }}/${domain}/g" \
|
||||||
>"${metronome_conf_dir}/${domain}.cfg.lua"
|
> "${metronome_conf_dir}/${domain}.cfg.lua"
|
||||||
done
|
done
|
||||||
|
|
||||||
# remove old domain conf files
|
# remove old domain conf files
|
||||||
|
@ -74,16 +73,13 @@ do_post_regen() {
|
||||||
chown -R metronome: /var/lib/metronome/
|
chown -R metronome: /var/lib/metronome/
|
||||||
chown -R metronome: /etc/metronome/conf.d/
|
chown -R metronome: /etc/metronome/conf.d/
|
||||||
|
|
||||||
if [[ -z "$(ls /etc/metronome/conf.d/*.cfg.lua 2>/dev/null)" ]]
|
if [[ -z "$(ls /etc/metronome/conf.d/*.cfg.lua 2> /dev/null)" ]]; then
|
||||||
then
|
if systemctl is-enabled metronome &> /dev/null; then
|
||||||
if systemctl is-enabled metronome &>/dev/null
|
systemctl disable metronome --now 2> /dev/null
|
||||||
then
|
|
||||||
systemctl disable metronome --now 2>/dev/null
|
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if ! systemctl is-enabled metronome &>/dev/null
|
if ! systemctl is-enabled metronome &> /dev/null; then
|
||||||
then
|
systemctl enable metronome --now 2> /dev/null
|
||||||
systemctl enable metronome --now 2>/dev/null
|
|
||||||
sleep 3
|
sleep 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ do_init_regen() {
|
||||||
cp "redirect_to_admin.conf" $nginx_conf_dir/default.d/
|
cp "redirect_to_admin.conf" $nginx_conf_dir/default.d/
|
||||||
|
|
||||||
# Restart nginx if conf looks good, otherwise display error and exit unhappy
|
# Restart nginx if conf looks good, otherwise display error and exit unhappy
|
||||||
nginx -t 2>/dev/null || {
|
nginx -t 2> /dev/null || {
|
||||||
nginx -t
|
nginx -t
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ do_pre_regen() {
|
||||||
# remove the panel overlay if this is specified in settings
|
# remove the panel overlay if this is specified in settings
|
||||||
panel_overlay=$(yunohost settings get 'misc.portal.ssowat_panel_overlay_enabled' | int_to_bool)
|
panel_overlay=$(yunohost settings get 'misc.portal.ssowat_panel_overlay_enabled' | int_to_bool)
|
||||||
if [ "$panel_overlay" == "False" ]; then
|
if [ "$panel_overlay" == "False" ]; then
|
||||||
echo "#" >"${nginx_conf_dir}/yunohost_panel.conf.inc"
|
echo "#" > "${nginx_conf_dir}/yunohost_panel.conf.inc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# retrieve variables
|
# retrieve variables
|
||||||
|
@ -86,22 +86,19 @@ do_pre_regen() {
|
||||||
export domain_cert_ca=$(echo $cert_status \
|
export domain_cert_ca=$(echo $cert_status \
|
||||||
| jq ".certificates.\"$domain\".CA_type" \
|
| jq ".certificates.\"$domain\".CA_type" \
|
||||||
| tr -d '"')
|
| tr -d '"')
|
||||||
if echo "$xmpp_domain_list" | grep -q "^$domain$"
|
if echo "$xmpp_domain_list" | grep -q "^$domain$"; then
|
||||||
then
|
|
||||||
export xmpp_enabled="True"
|
export xmpp_enabled="True"
|
||||||
else
|
else
|
||||||
export xmpp_enabled="False"
|
export xmpp_enabled="False"
|
||||||
fi
|
fi
|
||||||
if echo "$mail_domain_list" | grep -q "^$domain$"
|
if echo "$mail_domain_list" | grep -q "^$domain$"; then
|
||||||
then
|
|
||||||
export mail_enabled="True"
|
export mail_enabled="True"
|
||||||
else
|
else
|
||||||
export mail_enabled="False"
|
export mail_enabled="False"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_render_template "server.tpl.conf" "${nginx_conf_dir}/${domain}.conf"
|
ynh_render_template "server.tpl.conf" "${nginx_conf_dir}/${domain}.conf"
|
||||||
if [ $mail_enabled == "True" ]
|
if [ $mail_enabled == "True" ]; then
|
||||||
then
|
|
||||||
ynh_render_template "autoconfig.tpl.xml" "${mail_autoconfig_dir}/config-v1.1.xml"
|
ynh_render_template "autoconfig.tpl.xml" "${mail_autoconfig_dir}/config-v1.1.xml"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -129,7 +126,7 @@ do_pre_regen() {
|
||||||
done
|
done
|
||||||
|
|
||||||
# remove old mail-autoconfig files
|
# remove old mail-autoconfig files
|
||||||
autoconfig_files=$(ls -1 /var/www/.well-known/*/autoconfig/mail/config-v1.1.xml 2>/dev/null || true)
|
autoconfig_files=$(ls -1 /var/www/.well-known/*/autoconfig/mail/config-v1.1.xml 2> /dev/null || true)
|
||||||
for file in $autoconfig_files; do
|
for file in $autoconfig_files; do
|
||||||
domain=$(basename $(readlink -f $(dirname $file)/../..))
|
domain=$(basename $(readlink -f $(dirname $file)/../..))
|
||||||
[[ $YNH_DOMAINS =~ $domain ]] \
|
[[ $YNH_DOMAINS =~ $domain ]] \
|
||||||
|
@ -144,8 +141,7 @@ do_pre_regen() {
|
||||||
do_post_regen() {
|
do_post_regen() {
|
||||||
regen_conf_files=$1
|
regen_conf_files=$1
|
||||||
|
|
||||||
if ls -l /etc/nginx/conf.d/*.d/*.conf
|
if ls -l /etc/nginx/conf.d/*.d/*.conf; then
|
||||||
then
|
|
||||||
chown root:root /etc/nginx/conf.d/*.d/*.conf
|
chown root:root /etc/nginx/conf.d/*.d/*.conf
|
||||||
chmod 644 /etc/nginx/conf.d/*.d/*.conf
|
chmod 644 /etc/nginx/conf.d/*.d/*.conf
|
||||||
fi
|
fi
|
||||||
|
@ -158,7 +154,7 @@ do_post_regen() {
|
||||||
done
|
done
|
||||||
|
|
||||||
# Reload nginx if conf looks good, otherwise display error and exit unhappy
|
# Reload nginx if conf looks good, otherwise display error and exit unhappy
|
||||||
nginx -t 2>/dev/null || {
|
nginx -t 2> /dev/null || {
|
||||||
nginx -t
|
nginx -t
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ do_pre_regen() {
|
||||||
chown postfix ${pending_dir}/etc/postfix
|
chown postfix ${pending_dir}/etc/postfix
|
||||||
chown postfix ${pending_dir}/etc/postfix/sasl_passwd
|
chown postfix ${pending_dir}/etc/postfix/sasl_passwd
|
||||||
|
|
||||||
cat <<<"[${relay_host}]:${relay_port} ${relay_user}:${relay_password}" >${postfix_dir}/sasl_passwd
|
cat <<< "[${relay_host}]:${relay_port} ${relay_user}:${relay_password}" > ${postfix_dir}/sasl_passwd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use this postfix server as a backup MX
|
# Use this postfix server as a backup MX
|
||||||
|
@ -51,10 +51,8 @@ do_pre_regen() {
|
||||||
export backup_mx_emails="$(yunohost settings get 'email.smtp.smtp_backup_mx_emails_whitelisted' | sed "s/,/ /g")"
|
export backup_mx_emails="$(yunohost settings get 'email.smtp.smtp_backup_mx_emails_whitelisted' | sed "s/,/ /g")"
|
||||||
rm -f ${postfix_dir}/relay_recipients
|
rm -f ${postfix_dir}/relay_recipients
|
||||||
touch ${postfix_dir}/relay_recipients
|
touch ${postfix_dir}/relay_recipients
|
||||||
if [ -n "${backup_mx_domains}" ] && [ -n "${backup_mx_emails}" ]
|
if [ -n "${backup_mx_domains}" ] && [ -n "${backup_mx_emails}" ]; then
|
||||||
then
|
for mail in ${backup_mx_emails}; do
|
||||||
for mail in ${backup_mx_emails}
|
|
||||||
do
|
|
||||||
echo "$mail OK" >> ${postfix_dir}/relay_recipients
|
echo "$mail OK" >> ${postfix_dir}/relay_recipients
|
||||||
done
|
done
|
||||||
postmap ${postfix_dir}/relay_recipients
|
postmap ${postfix_dir}/relay_recipients
|
||||||
|
@ -68,7 +66,7 @@ do_pre_regen() {
|
||||||
cat postsrsd \
|
cat postsrsd \
|
||||||
| sed "s/{{ main_domain }}/${main_domain}/g" \
|
| sed "s/{{ main_domain }}/${main_domain}/g" \
|
||||||
| sed "s/{{ domain_list }}/${domain_list}/g" \
|
| sed "s/{{ domain_list }}/${domain_list}/g" \
|
||||||
>"${default_dir}/postsrsd"
|
> "${default_dir}/postsrsd"
|
||||||
|
|
||||||
# adapt it for IPv4-only hosts
|
# adapt it for IPv4-only hosts
|
||||||
ipv6="$(yunohost settings get 'email.smtp.smtp_allow_ipv6' | int_to_bool)"
|
ipv6="$(yunohost settings get 'email.smtp.smtp_allow_ipv6' | int_to_bool)"
|
||||||
|
|
|
@ -41,7 +41,7 @@ do_post_regen() {
|
||||||
mkdir -p "/etc/dovecot/yunohost.d/post-ext.d"
|
mkdir -p "/etc/dovecot/yunohost.d/post-ext.d"
|
||||||
|
|
||||||
# create vmail user
|
# create vmail user
|
||||||
id vmail >/dev/null 2>&1 \
|
id vmail > /dev/null 2>&1 \
|
||||||
|| adduser --system --ingroup mail --uid 500 vmail --home /var/vmail --no-create-home
|
|| adduser --system --ingroup mail --uid 500 vmail --home /var/vmail --no-create-home
|
||||||
|
|
||||||
# Delete legacy home for vmail that existed in the past but was empty, poluting /home/
|
# Delete legacy home for vmail that existed in the past but was empty, poluting /home/
|
||||||
|
|
|
@ -13,8 +13,8 @@ do_pre_regen() {
|
||||||
"${pending_dir}/etc/rspamd/local.d/dkim_signing.conf"
|
"${pending_dir}/etc/rspamd/local.d/dkim_signing.conf"
|
||||||
install -D -m 644 rspamd.sieve \
|
install -D -m 644 rspamd.sieve \
|
||||||
"${pending_dir}/etc/dovecot/global_script/rspamd.sieve"
|
"${pending_dir}/etc/dovecot/global_script/rspamd.sieve"
|
||||||
install -D -m 644 redis.conf \
|
install -D -m 644 redis.conf \
|
||||||
"${pending_dir}/etc/rspamd/local.d/redis.conf"
|
"${pending_dir}/etc/rspamd/local.d/redis.conf"
|
||||||
}
|
}
|
||||||
|
|
||||||
do_post_regen() {
|
do_post_regen() {
|
||||||
|
|
|
@ -3,8 +3,7 @@
|
||||||
set -e
|
set -e
|
||||||
. /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
if ! dpkg --list | grep -q 'ii *mariadb-server '
|
if ! dpkg --list | grep -q 'ii *mariadb-server '; then
|
||||||
then
|
|
||||||
echo 'mysql/mariadb is not installed, skipping'
|
echo 'mysql/mariadb is not installed, skipping'
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -3,42 +3,42 @@
|
||||||
set -e
|
set -e
|
||||||
. /usr/share/yunohost/helpers
|
. /usr/share/yunohost/helpers
|
||||||
|
|
||||||
if ! dpkg --list | grep -q "ii *postgresql-$PSQL_VERSION "
|
if ! dpkg --list | grep -q "ii *postgresql-$PSQL_VERSION "; then
|
||||||
then
|
|
||||||
echo 'postgresql is not installed, skipping'
|
echo 'postgresql is not installed, skipping'
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -e "/etc/postgresql/$PSQL_VERSION" ]
|
if [ ! -e "/etc/postgresql/$PSQL_VERSION" ]; then
|
||||||
then
|
|
||||||
ynh_die --message="It looks like postgresql was not properly configured ? /etc/postgresql/$PSQL_VERSION is missing ... Could be due to a locale issue, c.f.https://serverfault.com/questions/426989/postgresql-etc-postgresql-doesnt-exist"
|
ynh_die --message="It looks like postgresql was not properly configured ? /etc/postgresql/$PSQL_VERSION is missing ... Could be due to a locale issue, c.f.https://serverfault.com/questions/426989/postgresql-etc-postgresql-doesnt-exist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
do_pre_regen() {
|
do_pre_regen() {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
do_post_regen() {
|
do_post_regen() {
|
||||||
#regen_conf_files=$1
|
#regen_conf_files=$1
|
||||||
|
|
||||||
# Make sure postgresql is started and enabled
|
# Make sure postgresql is started and enabled
|
||||||
# (N.B. : to check the active state, we check the cluster state because
|
# (N.B. : to check the active state, we check the cluster state because
|
||||||
# postgresql could be flagged as active even though the cluster is in
|
# postgresql could be flagged as active even though the cluster is in
|
||||||
# failed state because of how the service is configured..)
|
# failed state because of how the service is configured..)
|
||||||
systemctl is-active postgresql@$PSQL_VERSION-main -q || ynh_systemd_action --service_name=postgresql --action=restart
|
systemctl is-active postgresql@$PSQL_VERSION-main -q || ynh_systemd_action --service_name=postgresql --action=restart
|
||||||
systemctl is-enabled postgresql -q || systemctl enable postgresql --quiet
|
systemctl is-enabled postgresql -q || systemctl enable postgresql --quiet
|
||||||
|
|
||||||
# If this is the very first time, we define the root password
|
# If this is the very first time, we define the root password
|
||||||
# and configure a few things
|
# and configure a few things
|
||||||
if [ ! -f "$PSQL_ROOT_PWD_FILE" ] || [ -z "$(cat $PSQL_ROOT_PWD_FILE)" ]; then
|
if [ ! -f "$PSQL_ROOT_PWD_FILE" ] || [ -z "$(cat $PSQL_ROOT_PWD_FILE)" ]; then
|
||||||
ynh_string_random >$PSQL_ROOT_PWD_FILE
|
ynh_string_random > $PSQL_ROOT_PWD_FILE
|
||||||
fi
|
fi
|
||||||
|
|
||||||
[ ! -e $PSQL_ROOT_PWD_FILE ] || { chown root:postgres $PSQL_ROOT_PWD_FILE; chmod 440 $PSQL_ROOT_PWD_FILE; }
|
[ ! -e $PSQL_ROOT_PWD_FILE ] || {
|
||||||
|
chown root:postgres $PSQL_ROOT_PWD_FILE
|
||||||
|
chmod 440 $PSQL_ROOT_PWD_FILE
|
||||||
|
}
|
||||||
|
|
||||||
sudo --login --user=postgres psql -c"ALTER user postgres WITH PASSWORD '$(cat $PSQL_ROOT_PWD_FILE)'" postgres
|
sudo --login --user=postgres psql -c"ALTER user postgres WITH PASSWORD '$(cat $PSQL_ROOT_PWD_FILE)'" postgres
|
||||||
|
|
||||||
# force all user to connect to local databases using hashed passwords
|
# force all user to connect to local databases using hashed passwords
|
||||||
# https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html#EXAMPLE-PG-HBA.CONF
|
# https://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html#EXAMPLE-PG-HBA.CONF
|
||||||
# Note: we can't use peer since YunoHost create users with nologin
|
# Note: we can't use peer since YunoHost create users with nologin
|
||||||
|
|
|
@ -5,8 +5,7 @@ set -e
|
||||||
_generate_config() {
|
_generate_config() {
|
||||||
echo "domains:"
|
echo "domains:"
|
||||||
# Add yunohost.local (only if yunohost.local ain't already in ynh_domains)
|
# Add yunohost.local (only if yunohost.local ain't already in ynh_domains)
|
||||||
if ! echo "$YNH_DOMAINS" | tr ' ' '\n' | grep -q --line-regexp 'yunohost.local'
|
if ! echo "$YNH_DOMAINS" | tr ' ' '\n' | grep -q --line-regexp 'yunohost.local'; then
|
||||||
then
|
|
||||||
echo " - yunohost.local"
|
echo " - yunohost.local"
|
||||||
fi
|
fi
|
||||||
for domain in $YNH_DOMAINS; do
|
for domain in $YNH_DOMAINS; do
|
||||||
|
@ -15,10 +14,8 @@ _generate_config() {
|
||||||
[[ "$domain" =~ ^[^.]+\.local$ ]] || continue
|
[[ "$domain" =~ ^[^.]+\.local$ ]] || continue
|
||||||
echo " - $domain"
|
echo " - $domain"
|
||||||
done
|
done
|
||||||
if [[ -e /etc/yunohost/mdns.aliases ]]
|
if [[ -e /etc/yunohost/mdns.aliases ]]; then
|
||||||
then
|
for localalias in $(cat /etc/yunohost/mdns.aliases | grep -v "^ *$"); do
|
||||||
for localalias in $(cat /etc/yunohost/mdns.aliases | grep -v "^ *$")
|
|
||||||
do
|
|
||||||
echo " - $localalias.local"
|
echo " - $localalias.local"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -37,10 +34,10 @@ do_pre_regen() {
|
||||||
mkdir -p ${pending_dir}/etc/systemd/system/
|
mkdir -p ${pending_dir}/etc/systemd/system/
|
||||||
cp yunomdns.service ${pending_dir}/etc/systemd/system/
|
cp yunomdns.service ${pending_dir}/etc/systemd/system/
|
||||||
|
|
||||||
getent passwd mdns &>/dev/null || useradd --no-create-home --shell /usr/sbin/nologin --system --user-group mdns
|
getent passwd mdns &> /dev/null || useradd --no-create-home --shell /usr/sbin/nologin --system --user-group mdns
|
||||||
|
|
||||||
mkdir -p ${pending_dir}/etc/yunohost
|
mkdir -p ${pending_dir}/etc/yunohost
|
||||||
_generate_config >${pending_dir}/etc/yunohost/mdns.yml
|
_generate_config > ${pending_dir}/etc/yunohost/mdns.yml
|
||||||
}
|
}
|
||||||
|
|
||||||
do_post_regen() {
|
do_post_regen() {
|
||||||
|
|
|
@ -18,12 +18,12 @@ do_pre_regen() {
|
||||||
cp plain/etcdefault ${pending_dir}/etc/default/dnsmasq
|
cp plain/etcdefault ${pending_dir}/etc/default/dnsmasq
|
||||||
|
|
||||||
# add resolver file
|
# add resolver file
|
||||||
cat plain/resolv.dnsmasq.conf | grep "^nameserver" | shuf >${pending_dir}/etc/resolv.dnsmasq.conf
|
cat plain/resolv.dnsmasq.conf | grep "^nameserver" | shuf > ${pending_dir}/etc/resolv.dnsmasq.conf
|
||||||
|
|
||||||
# retrieve variables
|
# retrieve variables
|
||||||
ipv4=$(curl --max-time 10 -s -4 https://ip.yunohost.org 2>/dev/null || true)
|
ipv4=$(curl --max-time 10 -s -4 https://ip.yunohost.org 2> /dev/null || true)
|
||||||
ynh_validate_ip4 "$ipv4" || ipv4='127.0.0.1'
|
ynh_validate_ip4 "$ipv4" || ipv4='127.0.0.1'
|
||||||
ipv6=$(curl --max-time 10 -s -6 https://ip6.yunohost.org 2>/dev/null || true)
|
ipv6=$(curl --max-time 10 -s -6 https://ip6.yunohost.org 2> /dev/null || true)
|
||||||
ynh_validate_ip6 "$ipv6" || ipv6=''
|
ynh_validate_ip6 "$ipv6" || ipv6=''
|
||||||
interfaces="$(ip -j addr show | jq -r '[.[].ifname]|join(" ")')"
|
interfaces="$(ip -j addr show | jq -r '[.[].ifname]|join(" ")')"
|
||||||
wireless_interfaces="lo"
|
wireless_interfaces="lo"
|
||||||
|
@ -51,8 +51,7 @@ do_pre_regen() {
|
||||||
conf_files=$(ls -1 /etc/dnsmasq.d \
|
conf_files=$(ls -1 /etc/dnsmasq.d \
|
||||||
| awk '/^[^\.]+\.[^\.]+.*$/ { print $1 }')
|
| awk '/^[^\.]+\.[^\.]+.*$/ { print $1 }')
|
||||||
for domain in $conf_files; do
|
for domain in $conf_files; do
|
||||||
if [[ ! $YNH_DOMAINS =~ $domain ]] && [[ ! $domain =~ \.local$ ]]
|
if [[ ! $YNH_DOMAINS =~ $domain ]] && [[ ! $domain =~ \.local$ ]]; then
|
||||||
then
|
|
||||||
touch "${dnsmasq_dir}/${domain}"
|
touch "${dnsmasq_dir}/${domain}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -68,27 +67,27 @@ do_post_regen() {
|
||||||
# Fuck it, those domain/search entries from dhclient are usually annoying
|
# Fuck it, those domain/search entries from dhclient are usually annoying
|
||||||
# lying shit from the ISP trying to MiTM
|
# lying shit from the ISP trying to MiTM
|
||||||
if grep -q -E "^ *(domain|search)" /run/resolvconf/resolv.conf; then
|
if grep -q -E "^ *(domain|search)" /run/resolvconf/resolv.conf; then
|
||||||
if grep -q -E "^ *(domain|search)" /run/resolvconf/interface/*.dhclient 2>/dev/null; then
|
if grep -q -E "^ *(domain|search)" /run/resolvconf/interface/*.dhclient 2> /dev/null; then
|
||||||
sed -E "s/^(domain|search)/#\1/g" -i /run/resolvconf/interface/*.dhclient
|
sed -E "s/^(domain|search)/#\1/g" -i /run/resolvconf/interface/*.dhclient
|
||||||
fi
|
fi
|
||||||
|
|
||||||
grep -q '^supersede domain-name "";' /etc/dhcp/dhclient.conf 2>/dev/null || echo 'supersede domain-name "";' >>/etc/dhcp/dhclient.conf
|
grep -q '^supersede domain-name "";' /etc/dhcp/dhclient.conf 2> /dev/null || echo 'supersede domain-name "";' >> /etc/dhcp/dhclient.conf
|
||||||
grep -q '^supersede domain-search "";' /etc/dhcp/dhclient.conf 2>/dev/null || echo 'supersede domain-search "";' >>/etc/dhcp/dhclient.conf
|
grep -q '^supersede domain-search "";' /etc/dhcp/dhclient.conf 2> /dev/null || echo 'supersede domain-search "";' >> /etc/dhcp/dhclient.conf
|
||||||
grep -q '^supersede search "";' /etc/dhcp/dhclient.conf 2>/dev/null || echo 'supersede search "";' >>/etc/dhcp/dhclient.conf
|
grep -q '^supersede search "";' /etc/dhcp/dhclient.conf 2> /dev/null || echo 'supersede search "";' >> /etc/dhcp/dhclient.conf
|
||||||
systemctl restart resolvconf
|
systemctl restart resolvconf
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Some stupid things like rabbitmq-server used by onlyoffice won't work if
|
# Some stupid things like rabbitmq-server used by onlyoffice won't work if
|
||||||
# the *short* hostname doesn't exists in /etc/hosts -_-
|
# the *short* hostname doesn't exists in /etc/hosts -_-
|
||||||
short_hostname=$(hostname -s)
|
short_hostname=$(hostname -s)
|
||||||
grep -q "127.0.0.1.*$short_hostname" /etc/hosts || echo -e "\n127.0.0.1\t$short_hostname" >>/etc/hosts
|
grep -q "127.0.0.1.*$short_hostname" /etc/hosts || echo -e "\n127.0.0.1\t$short_hostname" >> /etc/hosts
|
||||||
|
|
||||||
[[ -n "$regen_conf_files" ]] || return 0
|
[[ -n "$regen_conf_files" ]] || return 0
|
||||||
|
|
||||||
# Remove / disable services likely to conflict with dnsmasq
|
# Remove / disable services likely to conflict with dnsmasq
|
||||||
for SERVICE in systemd-resolved bind9; do
|
for SERVICE in systemd-resolved bind9; do
|
||||||
systemctl is-enabled $SERVICE &>/dev/null && systemctl disable $SERVICE 2>/dev/null
|
systemctl is-enabled $SERVICE &> /dev/null && systemctl disable $SERVICE 2> /dev/null
|
||||||
systemctl is-active $SERVICE &>/dev/null && systemctl stop $SERVICE
|
systemctl is-active $SERVICE &> /dev/null && systemctl stop $SERVICE
|
||||||
done
|
done
|
||||||
|
|
||||||
systemctl restart dnsmasq
|
systemctl restart dnsmasq
|
||||||
|
|
|
@ -24,8 +24,7 @@ do_pre_regen() {
|
||||||
do_post_regen() {
|
do_post_regen() {
|
||||||
regen_conf_files=$1
|
regen_conf_files=$1
|
||||||
|
|
||||||
if ls -l /etc/fail2ban/jail.d/*.conf
|
if ls -l /etc/fail2ban/jail.d/*.conf; then
|
||||||
then
|
|
||||||
chown root:root /etc/fail2ban/jail.d/*.conf
|
chown root:root /etc/fail2ban/jail.d/*.conf
|
||||||
chmod 644 /etc/fail2ban/jail.d/*.conf
|
chmod 644 /etc/fail2ban/jail.d/*.conf
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,4 +1,12 @@
|
||||||
{
|
{
|
||||||
"password_too_simple_1": "Ο κωδικός πρόσβασης πρέπει να έχει τουλάχιστον 8 χαρακτήρες",
|
"password_too_simple_1": "Ο κωδικός πρόσβασης πρέπει να έχει τουλάχιστον 8 χαρακτήρες",
|
||||||
"aborting": "Ματαίωση."
|
"aborting": "Ματαίωση.",
|
||||||
}
|
"action_invalid": "Μη έγκυρη ενέργεια '{action}'",
|
||||||
|
"app_action_broke_system": "Αυτή η ενέργεια φαίνεται να έχει προκαλέσει προβλήματα σε αυτές τις σημαντικές υπηρεσίες: {services}",
|
||||||
|
"app_already_installed": "Η φαρμογή {app} είναι ήδη εγκατεστημένη",
|
||||||
|
"admin_password": "Κωδικός διαχείρισης",
|
||||||
|
"all_users": "Όλοι οι χρήστες YunoHost",
|
||||||
|
"admins": "Διαχειριστές",
|
||||||
|
"app_action_failed": "Αποτυχία εκτέλεσης ενέργειας {action} για την εφαρμογή {app}",
|
||||||
|
"already_up_to_date": "Δεν υπάρχει τίποτα να γίνει. Όλα είναι επικαιροποιημένα."
|
||||||
|
}
|
||||||
|
|
|
@ -461,7 +461,7 @@
|
||||||
"user_import_success": "Erabiltzaileak arazorik gabe inportatu dira",
|
"user_import_success": "Erabiltzaileak arazorik gabe inportatu dira",
|
||||||
"yunohost_already_installed": "YunoHost instalatuta dago dagoeneko",
|
"yunohost_already_installed": "YunoHost instalatuta dago dagoeneko",
|
||||||
"migrations_success_forward": "{id} migrazioak amaitu du",
|
"migrations_success_forward": "{id} migrazioak amaitu du",
|
||||||
"migrations_to_be_ran_manually": "{id} migrazioa eskuz abiarazi behar da. Joan Tresnak → Migrazioak atalera administrazio-atarian edo bestela exekutatu 'yunohost tools migrations run'.",
|
"migrations_to_be_ran_manually": "{id} migrazioa eskuz abiarazi behar da. Joan Tresnak → Migrazioak atalera administrazio-gunean edo bestela exekutatu 'yunohost tools migrations run'.",
|
||||||
"permission_currently_allowed_for_all_users": "Baimen hau erabiltzaile guztiei esleitzen zaie eta baita beste talde batzuei ere. Litekeena da 'all users' baimena edo esleituta duten taldeei baimena kendu nahi izatea.",
|
"permission_currently_allowed_for_all_users": "Baimen hau erabiltzaile guztiei esleitzen zaie eta baita beste talde batzuei ere. Litekeena da 'all users' baimena edo esleituta duten taldeei baimena kendu nahi izatea.",
|
||||||
"permission_require_account": "'{permission}' baimena zerbitzarian kontua duten erabiltzaileentzat da eta, beraz, ezin da gaitu bisitarientzat.",
|
"permission_require_account": "'{permission}' baimena zerbitzarian kontua duten erabiltzaileentzat da eta, beraz, ezin da gaitu bisitarientzat.",
|
||||||
"postinstall_low_rootfsspace": "'root' fitxategi-sistemak 10 GB edo espazio gutxiago dauka, kezkatzekoa dena! Litekeena da espaziorik gabe geratzea aurki! Gomendagarria da 'root' fitxategi-sistemak gutxienez 16 GB libre izatea. Jakinarazpen honen ondoren YunoHost instalatzen jarraitu nahi baduzu, berrabiarazi agindua '--force-diskspace' gehituz",
|
"postinstall_low_rootfsspace": "'root' fitxategi-sistemak 10 GB edo espazio gutxiago dauka, kezkatzekoa dena! Litekeena da espaziorik gabe geratzea aurki! Gomendagarria da 'root' fitxategi-sistemak gutxienez 16 GB libre izatea. Jakinarazpen honen ondoren YunoHost instalatzen jarraitu nahi baduzu, berrabiarazi agindua '--force-diskspace' gehituz",
|
||||||
|
@ -579,7 +579,7 @@
|
||||||
"port_already_opened": "{port}. ataka dagoeneko irekita dago {ip_version} konexioetarako",
|
"port_already_opened": "{port}. ataka dagoeneko irekita dago {ip_version} konexioetarako",
|
||||||
"user_home_creation_failed": "Ezin izan da erabiltzailearentzat '{home}' direktorioa sortu",
|
"user_home_creation_failed": "Ezin izan da erabiltzailearentzat '{home}' direktorioa sortu",
|
||||||
"user_unknown": "Erabiltzaile ezezaguna: {user}",
|
"user_unknown": "Erabiltzaile ezezaguna: {user}",
|
||||||
"yunohost_postinstall_end_tip": "Instalazio ondorengo prozesua amaitu da! Sistemaren konfigurazioa bukatzeko:\n- erabili 'Diagnostikoak' gunea ohiko arazoei aurre hartzeko. Administrazio-atarian abiarazi edo 'yunohost diagnosis run' exekutatu;\n- irakurri 'Finalizing your setup' eta 'Getting to know YunoHost' atalak. Dokumentazioan aurki ditzakezu: https://yunohost.org/admindoc.",
|
"yunohost_postinstall_end_tip": "Instalazio ondorengo prozesua amaitu da! Sistemaren konfigurazioa bukatzeko:\n- erabili 'Diagnostikoak' gunea ohiko arazoei aurre hartzeko. Abiarazi administrazio-gunean edo exekutatu 'yunohost diagnosis run';\n- irakurri 'Finalizing your setup' eta 'Getting to know YunoHost' atalak. Dokumentazioan aurki ditzakezu: https://yunohost.org/admindoc.",
|
||||||
"yunohost_not_installed": "YunoHost ez da zuzen instalatu. Exekutatu 'yunohost tools postinstall'",
|
"yunohost_not_installed": "YunoHost ez da zuzen instalatu. Exekutatu 'yunohost tools postinstall'",
|
||||||
"unlimit": "Mugarik ez",
|
"unlimit": "Mugarik ez",
|
||||||
"restore_already_installed_apps": "Ondorengo aplikazioak ezin dira lehengoratu dagoeneko instalatuta daudelako: {apps}",
|
"restore_already_installed_apps": "Ondorengo aplikazioak ezin dira lehengoratu dagoeneko instalatuta daudelako: {apps}",
|
||||||
|
@ -620,7 +620,7 @@
|
||||||
"service_description_redis-server": "Datuak bizkor atzitzeko, zereginak lerratzeko eta programen arteko komunikaziorako datubase berezi bat da",
|
"service_description_redis-server": "Datuak bizkor atzitzeko, zereginak lerratzeko eta programen arteko komunikaziorako datubase berezi bat da",
|
||||||
"service_description_rspamd": "Spama bahetu eta posta elektronikoarekin zerikusia duten bestelako futzioen ardura dauka",
|
"service_description_rspamd": "Spama bahetu eta posta elektronikoarekin zerikusia duten bestelako futzioen ardura dauka",
|
||||||
"service_description_slapd": "Erabiltzaileak, domeinuak eta hauei lotutako informazioa gordetzen du",
|
"service_description_slapd": "Erabiltzaileak, domeinuak eta hauei lotutako informazioa gordetzen du",
|
||||||
"service_description_yunohost-api": "YunoHosten web-atariaren eta sistemaren arteko hartuemana kudeatzen du",
|
"service_description_yunohost-api": "YunoHosten web-interfazearen eta sistemaren arteko hartuemana kudeatzen du",
|
||||||
"domain_config_default_app": "Lehenetsitako aplikazioa",
|
"domain_config_default_app": "Lehenetsitako aplikazioa",
|
||||||
"tools_upgrade": "Sistemaren paketeak eguneratzen",
|
"tools_upgrade": "Sistemaren paketeak eguneratzen",
|
||||||
"tools_upgrade_failed": "Ezin izan dira paketeak eguneratu: {packages_list}",
|
"tools_upgrade_failed": "Ezin izan dira paketeak eguneratu: {packages_list}",
|
||||||
|
@ -654,8 +654,8 @@
|
||||||
"global_settings_setting_ssh_password_authentication_help": "Baimendu pasahitz bidezko autentikazioa SSHrako",
|
"global_settings_setting_ssh_password_authentication_help": "Baimendu pasahitz bidezko autentikazioa SSHrako",
|
||||||
"global_settings_setting_ssh_port": "SSH ataka",
|
"global_settings_setting_ssh_port": "SSH ataka",
|
||||||
"global_settings_setting_webadmin_allowlist_help": "Administrazio-atarira sar daitezken IP helbideak. CIDR notazioa ahalbidetzen da.",
|
"global_settings_setting_webadmin_allowlist_help": "Administrazio-atarira sar daitezken IP helbideak. CIDR notazioa ahalbidetzen da.",
|
||||||
"global_settings_setting_webadmin_allowlist_enabled_help": "Baimendu IP zehatz batzuk bakarrik administrazio-atarian.",
|
"global_settings_setting_webadmin_allowlist_enabled_help": "Baimendu IP zehatz batzuk bakarrik administrazio-gunerako.",
|
||||||
"global_settings_setting_smtp_allow_ipv6_help": "Baimendu IPv6 posta elektronikoa jaso eta bidaltzeko",
|
"global_settings_setting_smtp_allow_ipv6_help": "Gaitu IPv6 posta elektronikoa jaso eta bidaltzeko",
|
||||||
"global_settings_setting_smtp_relay_enabled_help": "YunoHosten ordez posta elektronikoa bidaltzeko SMTP relay helbidea. Erabilgarri izan daiteke egoera hauetan: operadore edo VPS enpresak 25. ataka blokeatzen badu, DUHLen zure etxeko IPa ageri bada, ezin baduzu alderantzizko DNSa ezarri edo zerbitzari hau ez badago zuzenean internetera konektatuta baina posta elektronikoa bidali nahi baduzu.",
|
"global_settings_setting_smtp_relay_enabled_help": "YunoHosten ordez posta elektronikoa bidaltzeko SMTP relay helbidea. Erabilgarri izan daiteke egoera hauetan: operadore edo VPS enpresak 25. ataka blokeatzen badu, DUHLen zure etxeko IPa ageri bada, ezin baduzu alderantzizko DNSa ezarri edo zerbitzari hau ez badago zuzenean internetera konektatuta baina posta elektronikoa bidali nahi baduzu.",
|
||||||
"migration_0024_rebuild_python_venv_broken_app": "{app} aplikazioari ez ikusiarena egin zaio ezin delako ingurune birtuala modu errazean birsortu. Horren ordez, aplikazioaren eguneraketa behartzen saia zaitezke `yunohost app upgrade --force {app}` arazoa konpontzeko.",
|
"migration_0024_rebuild_python_venv_broken_app": "{app} aplikazioari ez ikusiarena egin zaio ezin delako ingurune birtuala modu errazean birsortu. Horren ordez, aplikazioaren eguneraketa behartzen saia zaitezke `yunohost app upgrade --force {app}` arazoa konpontzeko.",
|
||||||
"migration_0024_rebuild_python_venv_disclaimer_rebuild": "Ondorengo aplikazioen virtualenv-a birsortzeko saiakera egingo da (eragiketak luze jo dezake!): {rebuild_apps}",
|
"migration_0024_rebuild_python_venv_disclaimer_rebuild": "Ondorengo aplikazioen virtualenv-a birsortzeko saiakera egingo da (eragiketak luze jo dezake!): {rebuild_apps}",
|
||||||
|
@ -695,7 +695,7 @@
|
||||||
"diagnosis_using_stable_codename": "<cmd>apt</cmd> (sistemaren pakete kudeatzailea) 'stable' (egonkorra) izen kodea duten paketeak instalatzeko ezarrita dago une honetan, eta ez uneko Debianen bertsioaren (bullseye) izen kodea.",
|
"diagnosis_using_stable_codename": "<cmd>apt</cmd> (sistemaren pakete kudeatzailea) 'stable' (egonkorra) izen kodea duten paketeak instalatzeko ezarrita dago une honetan, eta ez uneko Debianen bertsioaren (bullseye) izen kodea.",
|
||||||
"diagnosis_using_yunohost_testing": "<cmd>apt</cmd> (sistemaren pakete kudeatzailea) YunoHosten muinerako 'testing' (proba) izen kodea duten paketeak instalatzeko ezarrita dago une honetan.",
|
"diagnosis_using_yunohost_testing": "<cmd>apt</cmd> (sistemaren pakete kudeatzailea) YunoHosten muinerako 'testing' (proba) izen kodea duten paketeak instalatzeko ezarrita dago une honetan.",
|
||||||
"diagnosis_using_yunohost_testing_details": "Ez dago arazorik zertan ari zaren baldin badakizu, baina arretaz irakurri oharrak YunoHosten eguneraketak instalatu baino lehen! 'testing' (proba) bertsioak ezgaitu nahi badituzu, kendu <cmd>testing</cmd> gakoa <cmd>/etc/apt/sources.list.d/yunohost.list</cmd> fitxategitik.",
|
"diagnosis_using_yunohost_testing_details": "Ez dago arazorik zertan ari zaren baldin badakizu, baina arretaz irakurri oharrak YunoHosten eguneraketak instalatu baino lehen! 'testing' (proba) bertsioak ezgaitu nahi badituzu, kendu <cmd>testing</cmd> gakoa <cmd>/etc/apt/sources.list.d/yunohost.list</cmd> fitxategitik.",
|
||||||
"global_settings_setting_smtp_allow_ipv6": "Baimendu IPv6",
|
"global_settings_setting_smtp_allow_ipv6": "Gaitu IPv6",
|
||||||
"global_settings_setting_smtp_relay_host": "SMTP errele-ostatatzailea",
|
"global_settings_setting_smtp_relay_host": "SMTP errele-ostatatzailea",
|
||||||
"domain_config_acme_eligible": "ACME hautagarritasuna",
|
"domain_config_acme_eligible": "ACME hautagarritasuna",
|
||||||
"domain_config_acme_eligible_explain": "Ez dirudi domeinu hau Let's Encrypt ziurtagirirako prest dagoenik. Egiaztatu DNS ezarpenak eta zerbitzariaren HTTP irisgarritasuna. <a href='#/diagnosis'>Diagnostikoen guneko</a> 'DNS erregistroak' eta 'Web' atalek zer dagoen gaizki ulertzen lagun zaitzakete.",
|
"domain_config_acme_eligible_explain": "Ez dirudi domeinu hau Let's Encrypt ziurtagirirako prest dagoenik. Egiaztatu DNS ezarpenak eta zerbitzariaren HTTP irisgarritasuna. <a href='#/diagnosis'>Diagnostikoen guneko</a> 'DNS erregistroak' eta 'Web' atalek zer dagoen gaizki ulertzen lagun zaitzakete.",
|
||||||
|
@ -720,7 +720,7 @@
|
||||||
"global_settings_setting_ssh_password_authentication": "Pasahitz bidezko autentifikazioa",
|
"global_settings_setting_ssh_password_authentication": "Pasahitz bidezko autentifikazioa",
|
||||||
"global_settings_setting_user_strength_help": "Betekizun hauek lehenbizikoz sortzerakoan edo pasahitza aldatzerakoan bete behar dira soilik",
|
"global_settings_setting_user_strength_help": "Betekizun hauek lehenbizikoz sortzerakoan edo pasahitza aldatzerakoan bete behar dira soilik",
|
||||||
"global_settings_setting_webadmin_allowlist": "Administrazio-atarira sartzeko baimendutako IPak",
|
"global_settings_setting_webadmin_allowlist": "Administrazio-atarira sartzeko baimendutako IPak",
|
||||||
"global_settings_setting_webadmin_allowlist_enabled": "Gaitu administrazio-ataria sartzeko baimendutako IPak",
|
"global_settings_setting_webadmin_allowlist_enabled": "Gaitu administrazio-gunera sartzeko baimendutako IPak",
|
||||||
"invalid_credentials": "Pasahitz edo erabiltzaile-izen baliogabea",
|
"invalid_credentials": "Pasahitz edo erabiltzaile-izen baliogabea",
|
||||||
"log_resource_snippet": "Baliabide bat eguneratzen / eskuratzen / eskuragarritasuna uzten",
|
"log_resource_snippet": "Baliabide bat eguneratzen / eskuratzen / eskuragarritasuna uzten",
|
||||||
"log_settings_set": "Aplikatu ezarpenak",
|
"log_settings_set": "Aplikatu ezarpenak",
|
||||||
|
@ -810,4 +810,4 @@
|
||||||
"global_settings_setting_smtp_backup_mx_emails_whitelisted_help": "Bigarren mailako MX gisa jarduten duenean, baimendutako hartzaileen posta elektronikoko helbideen zerrenda zehatza eman beharko da (bestela, mezuak ukatu eta baztertuko dira). Hainbat sarrera eman daitezke, komaz bereizita.",
|
"global_settings_setting_smtp_backup_mx_emails_whitelisted_help": "Bigarren mailako MX gisa jarduten duenean, baimendutako hartzaileen posta elektronikoko helbideen zerrenda zehatza eman beharko da (bestela, mezuak ukatu eta baztertuko dira). Hainbat sarrera eman daitezke, komaz bereizita.",
|
||||||
"diagnosis_rfkill_wifi_details": "Ohartarazpena komando askotan ageri da, aplikazio batzuk hautsiz. Herrialdearen kodea zehaztuz konpon daiteke <code>sudo raspi-config</code> komandoaren bidez. Hau da errorea:<br>{rfkill_wifi_error}",
|
"diagnosis_rfkill_wifi_details": "Ohartarazpena komando askotan ageri da, aplikazio batzuk hautsiz. Herrialdearen kodea zehaztuz konpon daiteke <code>sudo raspi-config</code> komandoaren bidez. Hau da errorea:<br>{rfkill_wifi_error}",
|
||||||
"diagnosis_rfkill_wifi": "Wi-Fi txartela ezgaituta dago eta sistemaren ohartarazpen batek aplikazioen instalazioak eragotzi ditzake"
|
"diagnosis_rfkill_wifi": "Wi-Fi txartela ezgaituta dago eta sistemaren ohartarazpen batek aplikazioen instalazioak eragotzi ditzake"
|
||||||
}
|
}
|
||||||
|
|
|
@ -809,5 +809,5 @@
|
||||||
"global_settings_setting_smtp_backup_mx_domains": "Domaines à utiliser comme MX secondaire pour",
|
"global_settings_setting_smtp_backup_mx_domains": "Domaines à utiliser comme MX secondaire pour",
|
||||||
"global_settings_setting_smtp_backup_mx_emails_whitelisted": "Sauvegarde SMTP des emails sur liste blanche du MX",
|
"global_settings_setting_smtp_backup_mx_emails_whitelisted": "Sauvegarde SMTP des emails sur liste blanche du MX",
|
||||||
"global_settings_setting_smtp_backup_mx_emails_whitelisted_help": "Dans le cas d'un MX secondaire, la liste exhaustive des adresses électroniques des destinataires autorisés doit être fournie (sinon les courriers seront refusés et rejetés). Plusieurs entrées peuvent être fournies, séparées par des virgules.",
|
"global_settings_setting_smtp_backup_mx_emails_whitelisted_help": "Dans le cas d'un MX secondaire, la liste exhaustive des adresses électroniques des destinataires autorisés doit être fournie (sinon les courriers seront refusés et rejetés). Plusieurs entrées peuvent être fournies, séparées par des virgules.",
|
||||||
"global_settings_setting_smtp_backup_mx_domains_help": "Autorise ce serveur à agir en tant que domaine MX *secondaire* de secours pour le domaine listé. Cela signifie que si le MX principal pour le domaine n'est pas accessible (par exemple à cause d'une panne), les courriers électroniques seront quand même envoyés à ce serveur, qui les conservera pendant un maximum de 20 jours et essaiera de les relayer vers la destination réelle une fois qu'il sera rétabli. Plusieurs domaines peuvent être fournis, séparés par des virgules."
|
"global_settings_setting_smtp_backup_mx_domains_help": "Autoriser ce serveur à agir en tant que domaine MX *secondaire* de secours pour le domaine listé. Cela signifie que si le MX principal pour le domaine n'est pas accessible (par exemple à cause d'une panne), les courriers électroniques seront quand même envoyés à ce serveur, qui les conservera pendant un maximum de 20 jours et essaiera de les relayer vers la destination réelle une fois qu'il sera rétabli. Plusieurs domaines peuvent être fournis, séparés par des virgules."
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@
|
||||||
"backup_permission": "Permiso de copia para {app}",
|
"backup_permission": "Permiso de copia para {app}",
|
||||||
"backup_output_symlink_dir_broken": "O directorio de arquivo '{path}' é unha ligazón simbólica rota. Pode ser que esqueceses re/montar ou conectar o medio de almacenaxe ao que apunta.",
|
"backup_output_symlink_dir_broken": "O directorio de arquivo '{path}' é unha ligazón simbólica rota. Pode ser que esqueceses re/montar ou conectar o medio de almacenaxe ao que apunta.",
|
||||||
"backup_output_directory_required": "Debes proporcionar un directorio de saída para a copia",
|
"backup_output_directory_required": "Debes proporcionar un directorio de saída para a copia",
|
||||||
"backup_output_directory_not_empty": "Debes elexir un directorio de saída baleiro",
|
"backup_output_directory_not_empty": "Debes elixir un directorio de saída baleiro",
|
||||||
"backup_output_directory_forbidden": "Elixe un directorio de saída diferente. As copias non poden crearse en /bin, /boot, /dev, /etc, /lib, /root, /sbin, /sys, /usr, /var ou subcartafoles de /home/yunohost.backup/archives",
|
"backup_output_directory_forbidden": "Elixe un directorio de saída diferente. As copias non poden crearse en /bin, /boot, /dev, /etc, /lib, /root, /sbin, /sys, /usr, /var ou subcartafoles de /home/yunohost.backup/archives",
|
||||||
"backup_nothings_done": "Nada que gardar",
|
"backup_nothings_done": "Nada que gardar",
|
||||||
"backup_no_uncompress_archive_dir": "Non hai tal directorio do arquivo descomprimido",
|
"backup_no_uncompress_archive_dir": "Non hai tal directorio do arquivo descomprimido",
|
||||||
|
@ -781,7 +781,7 @@
|
||||||
"log_dyndns_unsubscribe": "Retirar subscrición para o subdominio YunoHost '{}'",
|
"log_dyndns_unsubscribe": "Retirar subscrición para o subdominio YunoHost '{}'",
|
||||||
"ask_dyndns_recovery_password_explain_unavailable": "Este dominio DynDNS xa está rexistrado. Se es a persoa que o rexistrou orixinalmente, podes escribir o código de recuperación para reclamar o dominio.",
|
"ask_dyndns_recovery_password_explain_unavailable": "Este dominio DynDNS xa está rexistrado. Se es a persoa que o rexistrou orixinalmente, podes escribir o código de recuperación para reclamar o dominio.",
|
||||||
"dyndns_too_many_requests": "O servicio dyndns de YunoHost recibeu demasiadas peticións do teu sistema, agarda 1 hora e volve intentalo.",
|
"dyndns_too_many_requests": "O servicio dyndns de YunoHost recibeu demasiadas peticións do teu sistema, agarda 1 hora e volve intentalo.",
|
||||||
"global_settings_setting_ssh_port_help": "É recomendable un porto inferior a 1024 para evitar os intentos de apropiación por parte de servizos de non-administración na máquina remota. Tamén deberías evitar elexir un porto que xa está sendo utilizado, como 80 ou 443.",
|
"global_settings_setting_ssh_port_help": "É recomendable un porto inferior a 1024 para evitar os intentos de apropiación por parte de servizos de non-administración na máquina remota. Tamén deberías evitar elixir un porto que xa está sendo utilizado, como 80 ou 443.",
|
||||||
"diagnosis_ignore_criteria_error": "Os criterios deben ter o formato key=value (ex. domain=yolo.test)",
|
"diagnosis_ignore_criteria_error": "Os criterios deben ter o formato key=value (ex. domain=yolo.test)",
|
||||||
"diagnosis_ignore_already_filtered": "(Xa existe un filtro de diagnóstico de {category} con estes criterios)",
|
"diagnosis_ignore_already_filtered": "(Xa existe un filtro de diagnóstico de {category} con estes criterios)",
|
||||||
"diagnosis_ignore_filter_removed": "Eliminouse o filtro do diagnóstico para {category}",
|
"diagnosis_ignore_filter_removed": "Eliminouse o filtro do diagnóstico para {category}",
|
||||||
|
@ -803,5 +803,11 @@
|
||||||
"migration_0027_modified_files": "Detectamos que os seguintes ficheiros semella foron modificados manualmente e poderían ser sobreescritos durante a actualización: {manually_modified_files}",
|
"migration_0027_modified_files": "Detectamos que os seguintes ficheiros semella foron modificados manualmente e poderían ser sobreescritos durante a actualización: {manually_modified_files}",
|
||||||
"migration_0027_not_enough_free_space": "Hai moi pouco espazo en /var/! Deberías ter polo menos 1GB libre para realizar a migración.",
|
"migration_0027_not_enough_free_space": "Hai moi pouco espazo en /var/! Deberías ter polo menos 1GB libre para realizar a migración.",
|
||||||
"migration_0027_patch_yunohost_conflicts": "Aplicando a solución para resolver o problema conflictivo…",
|
"migration_0027_patch_yunohost_conflicts": "Aplicando a solución para resolver o problema conflictivo…",
|
||||||
"migration_0027_system_not_fully_up_to_date": "O teu sistema non está totalmente actualizado. Fai unha actualización corrente antes de iniciar a migración a Bookworm."
|
"migration_0027_system_not_fully_up_to_date": "O teu sistema non está totalmente actualizado. Fai unha actualización corrente antes de iniciar a migración a Bookworm.",
|
||||||
}
|
"global_settings_setting_smtp_backup_mx_domains": "Dominios que actúan como MX secundario para",
|
||||||
|
"global_settings_setting_smtp_backup_mx_emails_whitelisted": "Lista de enderezos para apoio MX de SMTP",
|
||||||
|
"diagnosis_rfkill_wifi": "A tarxeta Wi-Fi está desactivada e un aviso do sistema podería previr a instalación de apps",
|
||||||
|
"diagnosis_rfkill_wifi_details": "Este aviso aparece na saída de varias ordes, estragando algunhas apps. Normalmente require indicar o código de país coa orde <code>sudo raspi-config</code>. Aquí tes o erro:<br>{rfkill_wifi_error}",
|
||||||
|
"global_settings_setting_smtp_backup_mx_domains_help": "Permitir a este servidor actuar como un dominio MX *secundario* de apoio para o dominio da lista. Así se o MX principal para o dominio non está accesible (por exemplo por quedar ser electricidade), os correos seguirán enviándose ao servidor, que os gardará un máximo de 20 días e intentará entregalos ao destino real unha vez volva ser accesible. Pódense indicar varios dominios, separados por comas.",
|
||||||
|
"global_settings_setting_smtp_backup_mx_emails_whitelisted_help": "Para actuar como MX secundario, hai que proporcionar unha lista detallada de enderezos de correspondentes permitidos (doutro xeito os correos serán rexeitados e desbotados). Pódense indicar varias entradas, separadas por comas."
|
||||||
|
}
|
||||||
|
|
|
@ -469,7 +469,7 @@
|
||||||
"config_unknown_filter_key": "Kunci filter '{filter_key}' tidak sesuai.",
|
"config_unknown_filter_key": "Kunci filter '{filter_key}' tidak sesuai.",
|
||||||
"backup_permission": "Izin pencadangan untuk {app}",
|
"backup_permission": "Izin pencadangan untuk {app}",
|
||||||
"config_forbidden_keyword": "Kata kunci '{keyword}' sudah ada, Anda tidak dapat membuat atau menggunakan panel konfigurasi disertai pertanyaan dengan id ini.",
|
"config_forbidden_keyword": "Kata kunci '{keyword}' sudah ada, Anda tidak dapat membuat atau menggunakan panel konfigurasi disertai pertanyaan dengan id ini.",
|
||||||
"good_practices_about_user_password": "Sekarang Anda akan menentukan kata sandi pengguna baru. Kata sandi harus terdiri dari minimal 8 karakter - meskipun sebaiknya menggunakan kata sandi yang lebih panjang (misalnya parafrasa) dan/atau menggunakan beragam karakter (huruf besar, huruf kecil, angka, dan karakter khusus).",
|
"good_practices_about_user_password": "Sekarang Anda akan menentukan kata sandi pengguna baru. Kata sandi harus terdiri dari minimal 8 karakter—meskipun sebaiknya menggunakan kata sandi yang lebih panjang (misalnya parafrasa) dan/atau menggunakan beragam karakter (huruf besar, huruf kecil, angka, dan karakter khusus).",
|
||||||
"domain_dns_push_failed_to_authenticate": "Autentikasi gagal pada API registrar untuk domain '{domain}'. Besar kemungkinan karena kredensial tidak sesuai? (Galat: {error})",
|
"domain_dns_push_failed_to_authenticate": "Autentikasi gagal pada API registrar untuk domain '{domain}'. Besar kemungkinan karena kredensial tidak sesuai? (Galat: {error})",
|
||||||
"certmanager_domain_dns_ip_differs_from_public_ip": "Rekaman DNS untuk domain '{domain}' berbeda dengan IP server ini. Silakan periksa kategori 'Catatan DNS' (dasar) dalam diagnosis untuk info lebih lanjut. Jika Anda baru saja memodifikasi rekaman A, silakan menunggu hingga rekaman tersebut disebarkan (beberapa pemeriksa sebaran DNS tersedia online). (Jika Anda tahu apa yang Anda lakukan, gunakan '--no-checks' untuk mematikan pemeriksaan ini.)",
|
"certmanager_domain_dns_ip_differs_from_public_ip": "Rekaman DNS untuk domain '{domain}' berbeda dengan IP server ini. Silakan periksa kategori 'Catatan DNS' (dasar) dalam diagnosis untuk info lebih lanjut. Jika Anda baru saja memodifikasi rekaman A, silakan menunggu hingga rekaman tersebut disebarkan (beberapa pemeriksa sebaran DNS tersedia online). (Jika Anda tahu apa yang Anda lakukan, gunakan '--no-checks' untuk mematikan pemeriksaan ini.)",
|
||||||
"certmanager_hit_rate_limit": "Terlalu banyak sertifikat yang telah diterbitkan untuk kumpulan domain {domain} ini baru-baru ini. Silakan coba lagi nanti. Lihat https://letsencrypt.org/docs/rate-limits/ untuk detail lebih lanjut",
|
"certmanager_hit_rate_limit": "Terlalu banyak sertifikat yang telah diterbitkan untuk kumpulan domain {domain} ini baru-baru ini. Silakan coba lagi nanti. Lihat https://letsencrypt.org/docs/rate-limits/ untuk detail lebih lanjut",
|
||||||
|
@ -483,7 +483,7 @@
|
||||||
"config_cant_set_value_on_section": "Anda tidak dapat menetapkan satu nilai pun di seluruh bagian konfigurasi.",
|
"config_cant_set_value_on_section": "Anda tidak dapat menetapkan satu nilai pun di seluruh bagian konfigurasi.",
|
||||||
"backup_applying_method_custom": "Memanggil metode pencadangan khusus '{method}'…",
|
"backup_applying_method_custom": "Memanggil metode pencadangan khusus '{method}'…",
|
||||||
"backup_ask_for_copying_if_needed": "Apakah Anda ingin melakukan pencadangan menggunakan {size}MB untuk sementara? (Cara ini digunakan karena beberapa berkas tidak dapat disiapkan menggunakan metode yang lebih efisien.)",
|
"backup_ask_for_copying_if_needed": "Apakah Anda ingin melakukan pencadangan menggunakan {size}MB untuk sementara? (Cara ini digunakan karena beberapa berkas tidak dapat disiapkan menggunakan metode yang lebih efisien.)",
|
||||||
"good_practices_about_admin_password": "Sekarang Anda akan menentukan kata sandi administrasi baru. Kata sandi harus terdiri dari minimal 8 karakter - meskipun sebaiknya menggunakan kata sandi yang lebih panjang (misalnya parafrasa) dan/atau menggunakan beragam karakter (huruf besar, huruf kecil, angka, dan karakter khusus).",
|
"good_practices_about_admin_password": "Sekarang Anda akan menentukan kata sandi administrasi baru. Kata sandi harus terdiri dari minimal 8 karakter—meskipun sebaiknya menggunakan kata sandi yang lebih panjang (misalnya parafrasa) dan/atau menggunakan beragam karakter (huruf besar, huruf kecil, angka, dan karakter khusus).",
|
||||||
"certmanager_acme_not_configured_for_domain": "Tantangan ACME tidak dapat dijalankan untuk {domain} saat ini karena konfigurasi pada nginx tidak memiliki potongan kode yang sesuai… Pastikan konfigurasi nginx Anda mutakhir menggunakan `yunohost tools regen-conf nginx --dry-run --with-diff`.",
|
"certmanager_acme_not_configured_for_domain": "Tantangan ACME tidak dapat dijalankan untuk {domain} saat ini karena konfigurasi pada nginx tidak memiliki potongan kode yang sesuai… Pastikan konfigurasi nginx Anda mutakhir menggunakan `yunohost tools regen-conf nginx --dry-run --with-diff`.",
|
||||||
"diagnosis_http_special_use_tld": "Domain {domain} berdasarkan pada domain tingkat atas (TLD) penggunaan khusus seperti .local atau .test dan oleh karena itu tidak diharapkan untuk diekspos di luar jaringan lokal.",
|
"diagnosis_http_special_use_tld": "Domain {domain} berdasarkan pada domain tingkat atas (TLD) penggunaan khusus seperti .local atau .test dan oleh karena itu tidak diharapkan untuk diekspos di luar jaringan lokal.",
|
||||||
"certmanager_self_ca_conf_file_not_found": "Tidak dapat menemukan berkas konfigurasi untuk otoritas teken mandiri (berkas: {file})",
|
"certmanager_self_ca_conf_file_not_found": "Tidak dapat menemukan berkas konfigurasi untuk otoritas teken mandiri (berkas: {file})",
|
||||||
|
@ -803,5 +803,11 @@
|
||||||
"service_description_redis-server": "Basis data khusus yang digunakan untuk akses data cepat, antrian tugas, dan komunikasi antar program",
|
"service_description_redis-server": "Basis data khusus yang digunakan untuk akses data cepat, antrian tugas, dan komunikasi antar program",
|
||||||
"update_apt_cache_warning": "Ada yang tidak sesuai saat memperbarui cache APT (manajer paket Debian). Berikut ini adalah kumpulan baris source.list, yang mungkin membantu mengidentifikasi baris yang bermasalah:\n{sourceslist}",
|
"update_apt_cache_warning": "Ada yang tidak sesuai saat memperbarui cache APT (manajer paket Debian). Berikut ini adalah kumpulan baris source.list, yang mungkin membantu mengidentifikasi baris yang bermasalah:\n{sourceslist}",
|
||||||
"user_import_missing_columns": "Kehilangan kolom berikut: {columns}",
|
"user_import_missing_columns": "Kehilangan kolom berikut: {columns}",
|
||||||
"user_import_nothing_to_do": "Tidak ada pengguna yang perlu diimpor"
|
"user_import_nothing_to_do": "Tidak ada pengguna yang perlu diimpor",
|
||||||
}
|
"global_settings_setting_smtp_backup_mx_domains": "Domain yang digunakan sebagai MX sekunder",
|
||||||
|
"global_settings_setting_smtp_backup_mx_domains_help": "Izinkan server ini digunakan sebagai domain MX *sekunder* cadangan pada domain yang terdaftar. Ini berarti bahwa jika MX utama untuk domain tersebut tidak dapat dijangkau (misalnya karena gangguan), surel akan tetap dikirim ke server ini, yang akan menyimpannya selama maksimal 20 hari dan mencoba meneruskannya ke tujuan yang sebenarnya setelah kembali aktif. Beberapa domain dapat disediakan, dipisahkan dengan koma.",
|
||||||
|
"global_settings_setting_smtp_backup_mx_emails_whitelisted": "Daftar surel yang diperbolehkan sebagai MX cadangan SMTP",
|
||||||
|
"diagnosis_rfkill_wifi": "Kartu Wi-Fi dinonaktifkan dan peringatan sistem mungkin akan mencegah pemasangan aplikasi",
|
||||||
|
"diagnosis_rfkill_wifi_details": "Peringatan ini muncul di banyak keluaran perintah, sehingga merusak beberapa aplikasi. Biasanya Anda diminta untuk menentukan kode negara dengan perintah <code>sudo raspi-config</code>. Galat yang muncul:<br>{rfkill_wifi_error}",
|
||||||
|
"global_settings_setting_smtp_backup_mx_emails_whitelisted_help": "Bila digunakan sebagai MX sekunder, daftar lengkap alamat surel penerima yang diizinkan harus disediakan (sebaliknya surel akan ditolak dan dibuang). Beberapa alamat dapat diberikan, dipisahkan dengan koma."
|
||||||
|
}
|
||||||
|
|
16
maintenance/shfmt.sh
Executable file
16
maintenance/shfmt.sh
Executable file
|
@ -0,0 +1,16 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -Eeuo pipefail
|
||||||
|
|
||||||
|
shfmt_args=(
|
||||||
|
--indent 4
|
||||||
|
--keep-padding # keep column alignment paddings
|
||||||
|
--space-redirects # redirect operators will be followed by a space
|
||||||
|
--binary-next-line # binary ops like && and | may start a line
|
||||||
|
--case-indent # switch cases will be indented
|
||||||
|
)
|
||||||
|
|
||||||
|
shfmt "${shfmt_args[@]}" "$@" \
|
||||||
|
helpers/helpers \
|
||||||
|
helpers/helpers.v2.1.d/* \
|
||||||
|
helpers/helpers.v2.d/* \
|
||||||
|
hooks/*
|
119
src/app.py
119
src/app.py
|
@ -328,10 +328,7 @@ def app_map(app=None, raw=False, user=None):
|
||||||
result = {}
|
result = {}
|
||||||
|
|
||||||
if app is not None:
|
if app is not None:
|
||||||
if not _is_installed(app):
|
_assert_is_installed(app)
|
||||||
raise YunohostValidationError(
|
|
||||||
"app_not_installed", app=app, all_apps=_get_all_installed_apps_id()
|
|
||||||
)
|
|
||||||
apps = [
|
apps = [
|
||||||
app,
|
app,
|
||||||
]
|
]
|
||||||
|
@ -1424,10 +1421,7 @@ def app_remove(operation_logger, app, purge=False, force_workdir=None):
|
||||||
)
|
)
|
||||||
from yunohost.domain import domain_list, domain_config_get, domain_config_set
|
from yunohost.domain import domain_list, domain_config_get, domain_config_set
|
||||||
|
|
||||||
if not _is_installed(app):
|
_assert_is_installed(app)
|
||||||
raise YunohostValidationError(
|
|
||||||
"app_not_installed", app=app, all_apps=_get_all_installed_apps_id()
|
|
||||||
)
|
|
||||||
|
|
||||||
operation_logger.start()
|
operation_logger.start()
|
||||||
|
|
||||||
|
@ -2004,6 +1998,7 @@ ynh_app_config_run $1
|
||||||
"install_dir": settings.get("install_dir", ""),
|
"install_dir": settings.get("install_dir", ""),
|
||||||
"YNH_APP_BASEDIR": os.path.join(APPS_SETTING_PATH, app),
|
"YNH_APP_BASEDIR": os.path.join(APPS_SETTING_PATH, app),
|
||||||
"YNH_APP_PACKAGING_FORMAT": str(manifest["packaging_format"]),
|
"YNH_APP_PACKAGING_FORMAT": str(manifest["packaging_format"]),
|
||||||
|
"YNH_APP_CONFIG_PANEL_OPTIONS_TYPES_AND_BINDS": self._dump_options_types_and_binds(),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
app_script_env = _make_environment_for_app_script(app)
|
app_script_env = _make_environment_for_app_script(app)
|
||||||
|
@ -2022,8 +2017,68 @@ ynh_app_config_run $1
|
||||||
raise YunohostError("app_action_failed", action=action, app=app)
|
raise YunohostError("app_action_failed", action=action, app=app)
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
def _get_config_panel(self):
|
||||||
|
|
||||||
def _get_app_settings(app):
|
ret = super()._get_config_panel()
|
||||||
|
|
||||||
|
self._compute_binds()
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|
||||||
|
def _compute_binds(self):
|
||||||
|
"""
|
||||||
|
This compute the 'bind' statement for every option
|
||||||
|
In particular to handle __FOOBAR__ syntax
|
||||||
|
and to handle the fact that bind statements may be defined panel-wide or section-wide
|
||||||
|
"""
|
||||||
|
|
||||||
|
settings = _get_app_settings(self.entity)
|
||||||
|
|
||||||
|
for panel, section, option in self._iterate():
|
||||||
|
|
||||||
|
bind_panel = panel.get("bind")
|
||||||
|
|
||||||
|
bind_section = section.get("bind")
|
||||||
|
if not bind_section:
|
||||||
|
bind_section = bind_panel
|
||||||
|
elif bind_section[-1] == ":" and bind_panel and ":" in bind_panel:
|
||||||
|
selector, bind_panel_file = bind_panel.split(":")
|
||||||
|
if ">" in bind_section:
|
||||||
|
bind_section = bind_section + bind_panel_file
|
||||||
|
else:
|
||||||
|
bind_section = selector + bind_section + bind_panel_file
|
||||||
|
|
||||||
|
bind = option.get("bind")
|
||||||
|
if not bind:
|
||||||
|
if bind_section:
|
||||||
|
bind = bind_section
|
||||||
|
else:
|
||||||
|
bind = "settings"
|
||||||
|
elif bind[-1] == ":" and bind_section and ":" in bind_section:
|
||||||
|
selector, bind_file = bind_section.split(":")
|
||||||
|
if ">" in bind:
|
||||||
|
bind = bind + bind_file
|
||||||
|
else:
|
||||||
|
bind = selector + bind + bind_file
|
||||||
|
if bind == "settings" and option.get("type", "string") == "file":
|
||||||
|
bind = "null"
|
||||||
|
|
||||||
|
option["bind"] = _hydrate_app_template(bind, settings)
|
||||||
|
|
||||||
|
def _dump_options_types_and_binds(self):
|
||||||
|
lines = []
|
||||||
|
for _, _, option in self._iterate():
|
||||||
|
lines.append(
|
||||||
|
"|".join([option["id"], option.get("type", "string"), option["bind"]])
|
||||||
|
)
|
||||||
|
return "\n".join(lines)
|
||||||
|
|
||||||
|
|
||||||
|
app_settings_cache: Dict[str, Dict[str, Any]] = {}
|
||||||
|
app_settings_cache_timestamp: Dict[str, float] = {}
|
||||||
|
|
||||||
|
|
||||||
|
def _get_app_settings(app: str) -> Dict[str, Any]:
|
||||||
"""
|
"""
|
||||||
Get settings of an installed app
|
Get settings of an installed app
|
||||||
|
|
||||||
|
@ -2031,12 +2086,22 @@ def _get_app_settings(app):
|
||||||
app -- The app id (like nextcloud__2)
|
app -- The app id (like nextcloud__2)
|
||||||
|
|
||||||
"""
|
"""
|
||||||
if not _is_installed(app):
|
_assert_is_installed(app)
|
||||||
raise YunohostValidationError(
|
|
||||||
"app_not_installed", app=app, all_apps=_get_all_installed_apps_id()
|
global app_settings_cache
|
||||||
)
|
global app_settings_cache_timestamp
|
||||||
|
|
||||||
|
app_setting_path = os.path.join(APPS_SETTING_PATH, app, "settings.yml")
|
||||||
|
app_setting_timestamp = os.path.getmtime(app_setting_path)
|
||||||
|
|
||||||
|
# perf: app settings are cached using the settings.yml's modification date,
|
||||||
|
# such that we don't have to worry too much about calling this function
|
||||||
|
# too many times (because ultimately parsing yml is not free)
|
||||||
|
if app_settings_cache_timestamp.get(app) == app_setting_timestamp:
|
||||||
|
return app_settings_cache[app].copy()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(APPS_SETTING_PATH, app, "settings.yml")) as f:
|
with open(app_setting_path) as f:
|
||||||
settings = yaml.safe_load(f) or {}
|
settings = yaml.safe_load(f) or {}
|
||||||
# If label contains unicode char, this may later trigger issues when building strings...
|
# If label contains unicode char, this may later trigger issues when building strings...
|
||||||
# FIXME: this should be propagated to read_yaml so that this fix applies everywhere I think...
|
# FIXME: this should be propagated to read_yaml so that this fix applies everywhere I think...
|
||||||
|
@ -2068,8 +2133,15 @@ def _get_app_settings(app):
|
||||||
# Make the app id available as $app too
|
# Make the app id available as $app too
|
||||||
settings["app"] = app
|
settings["app"] = app
|
||||||
|
|
||||||
if app == settings["id"]:
|
# FIXME: it's not clear why this code exists... Shouldn't we hard-define 'id' as $app ...?
|
||||||
return settings
|
if app != settings["id"]:
|
||||||
|
return {}
|
||||||
|
|
||||||
|
# Cache the settings
|
||||||
|
app_settings_cache[app] = settings.copy()
|
||||||
|
app_settings_cache_timestamp[app] = app_setting_timestamp
|
||||||
|
|
||||||
|
return settings
|
||||||
except (IOError, TypeError, KeyError):
|
except (IOError, TypeError, KeyError):
|
||||||
logger.error(m18n.n("app_not_correctly_installed", app=app))
|
logger.error(m18n.n("app_not_correctly_installed", app=app))
|
||||||
return {}
|
return {}
|
||||||
|
@ -2087,6 +2159,11 @@ def _set_app_settings(app, settings):
|
||||||
with open(os.path.join(APPS_SETTING_PATH, app, "settings.yml"), "w") as f:
|
with open(os.path.join(APPS_SETTING_PATH, app, "settings.yml"), "w") as f:
|
||||||
yaml.safe_dump(settings, f, default_flow_style=False)
|
yaml.safe_dump(settings, f, default_flow_style=False)
|
||||||
|
|
||||||
|
if app in app_settings_cache_timestamp:
|
||||||
|
del app_settings_cache_timestamp[app]
|
||||||
|
if app in app_settings_cache:
|
||||||
|
del app_settings_cache[app]
|
||||||
|
|
||||||
|
|
||||||
def _get_manifest_of_app(path):
|
def _get_manifest_of_app(path):
|
||||||
"Get app manifest stored in json or in toml"
|
"Get app manifest stored in json or in toml"
|
||||||
|
@ -2694,16 +2771,6 @@ def _list_upgradable_apps():
|
||||||
|
|
||||||
|
|
||||||
def _is_installed(app: str) -> bool:
|
def _is_installed(app: str) -> bool:
|
||||||
"""
|
|
||||||
Check if application is installed
|
|
||||||
|
|
||||||
Keyword arguments:
|
|
||||||
app -- id of App to check
|
|
||||||
|
|
||||||
Returns:
|
|
||||||
Boolean
|
|
||||||
|
|
||||||
"""
|
|
||||||
return os.path.isdir(APPS_SETTING_PATH + app)
|
return os.path.isdir(APPS_SETTING_PATH + app)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue