mirror of
https://github.com/YunoHost-Apps/rainloop_ynh.git
synced 2024-09-03 20:16:18 +02:00
Applying example_ynh on install
This commit is contained in:
parent
f409efa890
commit
0e08080457
8 changed files with 83 additions and 79 deletions
|
@ -2,11 +2,11 @@
|
|||
auto_remove=1
|
||||
; Manifest
|
||||
domain="domain.tld" (DOMAIN)
|
||||
path="/rainloop" (PATH)
|
||||
is_public="No" (PUBLIC|public=Yes|private=No)
|
||||
password="password" (PASSWORD)
|
||||
path="/path" (PATH)
|
||||
language="fr"
|
||||
is_public=1 (PUBLIC|public=1|private=0)
|
||||
password="pass"
|
||||
ldap="Yes"
|
||||
lang="English"
|
||||
; Checks
|
||||
pkg_linter=1
|
||||
setup_sub_dir=1
|
||||
|
@ -17,21 +17,22 @@
|
|||
upgrade=1
|
||||
backup_restore=1
|
||||
multi_instance=1
|
||||
wrong_user=0
|
||||
wrong_path=1
|
||||
incorrect_path=1
|
||||
corrupt_source=0
|
||||
fail_download_source=0
|
||||
port_already_use=0
|
||||
final_path_already_use=0
|
||||
port_already_use=0
|
||||
change_url=0
|
||||
;;; Levels
|
||||
Level 1=auto
|
||||
Level 2=auto
|
||||
Level 3=auto
|
||||
Level 4=1
|
||||
Level 5=1
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it.
|
||||
# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well.
|
||||
Level 4=1
|
||||
Level 5=auto
|
||||
Level 6=auto
|
||||
Level 7=auto
|
||||
Level 8=0
|
||||
Level 9=0
|
||||
Level 10=0
|
||||
;;; Options
|
||||
Email=
|
||||
Notification=none
|
||||
|
|
|
@ -17,10 +17,10 @@ allow_themes = On
|
|||
allow_user_background = Off
|
||||
|
||||
; Language used by default
|
||||
language = "LANGTOCHANGE"
|
||||
language = "__LANGUAGE__"
|
||||
|
||||
; Admin Panel interface language
|
||||
language_admin = "LANGTOCHANGE"
|
||||
language_admin = "__LANGUAGE__"
|
||||
|
||||
; Allow language selection on settings screen
|
||||
allow_languages_on_settings = On
|
||||
|
@ -58,9 +58,9 @@ allow_sharing = On
|
|||
allow_sync = On
|
||||
sync_interval = 20
|
||||
type = "mysql"
|
||||
pdo_dsn = "mysql:host=127.0.0.1;port=3306;dbname=MYSQLUSER"
|
||||
pdo_user = "MYSQLUSER"
|
||||
pdo_password = "MYSQLPASSWORD"
|
||||
pdo_dsn = "mysql:host=127.0.0.1;port=3306;dbname=__DB_NAME__"
|
||||
pdo_user = "__DB_NAME__"
|
||||
pdo_password = "__DB_PWD__"
|
||||
suggestions_limit = 30
|
||||
|
||||
[security]
|
||||
|
@ -114,7 +114,7 @@ messagelist_actions = On
|
|||
attachments_actions = On
|
||||
|
||||
[login]
|
||||
default_domain = "domain.tld"
|
||||
default_domain = "__DOMAIN__"
|
||||
|
||||
; Allow language selection on webmail login screen
|
||||
allow_languages_on_login = On
|
||||
|
@ -138,7 +138,7 @@ sign_me_auto = "DefaultOff"
|
|||
enable = On
|
||||
|
||||
; List of enabled plugins
|
||||
enabled_list = "PLUGINSTOENABLE"
|
||||
enabled_list = "__PLUGINS__"
|
||||
|
||||
[defaults]
|
||||
; Editor mode used by default (Plain, Html, HtmlForced or PlainForced)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
app='rainloop' # This could never work with multi-instance. Need to find a better way
|
||||
domain=$1
|
||||
rainloop_path=/var/www/$app/app
|
||||
final_path=/var/www/$app/app
|
||||
|
||||
echo '
|
||||
imap_host = "localhost"
|
||||
|
@ -21,4 +21,4 @@ smtp_short_login = On
|
|||
smtp_auth = On
|
||||
smtp_php_mail = Off
|
||||
white_list = ""
|
||||
' | sudo tee --append $rainloop_path/data/_data_/_default_/domains/$domain.ini > /dev/null
|
||||
' | sudo tee --append $final_path/data/_data_/_default_/domains/$domain.ini > /dev/null
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
app='rainloop' # This could never work with multi-instance. Need to find a better way
|
||||
domain=$1
|
||||
rainloop_path=/var/www/$app/app
|
||||
final_path=/var/www/$app/app
|
||||
|
||||
sudo rm $rainloop_path/data/_data_/_default_/domains/$domain.ini
|
||||
sudo rm $final_path/data/_data_/_default_/domains/$domain.ini
|
||||
|
|
|
@ -37,7 +37,6 @@ is_public=$YNH_APP_ARG_IS_PUBLIC
|
|||
language=$YNH_APP_ARG_LANGUAGE
|
||||
password=$YNH_APP_ARG_PASSWORD
|
||||
ldap=$YNH_APP_ARG_LDAP
|
||||
999 lang=$YNH_APP_ARG_LANG => to language
|
||||
|
||||
### If it's a multi-instance app, meaning it can be installed several times independently
|
||||
### The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||
|
@ -136,13 +135,6 @@ ynh_app_setting_set $app final_path $final_path
|
|||
# Download, check integrity, uncompress and patch the source from app.src
|
||||
ynh_setup_source "$final_path"
|
||||
|
||||
|
||||
# Install plugins
|
||||
sudo mkdir -p $rainloop_path/data/_data_/_default_/plugins
|
||||
sudo cp -rf ../sources/plugins/auto-domain-grab $rainloop_path/data/_data_/_default_/plugins/.
|
||||
sudo cp -rf ../sources/plugins/ynh-login-mapping $rainloop_path/data/_data_/_default_/plugins/.
|
||||
sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $rainloop_path/data/_data_/_default_/plugins/.
|
||||
|
||||
#=================================================
|
||||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
@ -183,58 +175,37 @@ ynh_add_fpm_config
|
|||
# ...
|
||||
#=================================================
|
||||
|
||||
# Install plugins
|
||||
sudo mkdir -p $final_path/data/_data_/_default_/plugins
|
||||
sudo cp -rf ../sources/plugins/auto-domain-grab $final_path/data/_data_/_default_/plugins/.
|
||||
sudo cp -rf ../sources/plugins/ynh-login-mapping $final_path/data/_data_/_default_/plugins/.
|
||||
sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $final_path/data/_data_/_default_/plugins/.
|
||||
|
||||
# Autoconfig
|
||||
sudo mkdir -p $final_path/data/_data_/_default_/configs/
|
||||
application_file=$final_path/data/_data_/_default_/configs/application.ini
|
||||
|
||||
|
||||
|
||||
# Set plugins
|
||||
plugins="ynh-login-mapping,auto-domain-grab" # This plugin is trying to automatically grab unknown domains if users want to add external email accounts
|
||||
if [ "$ldap" = "Yes" ];
|
||||
then
|
||||
plugins="$plugins,ynh-ldap-suggestions" # This plugin is to suggest YunoHost users in recipients list
|
||||
fi
|
||||
ynh_app_setting_set "$app" plugins "$plugins"
|
||||
|
||||
sudo cp ../conf/data/configs/application.ini $application_file
|
||||
sudo sed -i "s@domain.tld@$domain@g" $application_file
|
||||
sudo sed -i "s@MYSQLUSER@$dbuser@g" $application_file
|
||||
sudo sed -i "s@MYSQLPASSWORD@$dbpass@g" $application_file
|
||||
sudo sed -i "s@LANGTOCHANGE@$language@g" $application_file
|
||||
sudo sed -i "s@PLUGINSTOENABLE@$plugins@g" $application_file
|
||||
|
||||
# Set admin password
|
||||
sudo php ../conf/config.php --index="$rainloop_path/index.php" --password="$password"
|
||||
sudo php ../conf/config.php --index="$final_path/index.php" --password="$password"
|
||||
ynh_app_setting_set "$app" password "$password"
|
||||
|
||||
# Add default domain configs by looping through all the domains already added
|
||||
sudo mkdir -p $rainloop_path/data/_data_/_default_/domains/
|
||||
sudo mkdir -p $final_path/data/_data_/_default_/domains/
|
||||
# get list of ldap domains
|
||||
alldomains=`ldapsearch -LLL -x -b ou=domains,dc=yunohost,dc=org -s one "objectclass=top" virtualdomain | grep -v "dn:" | sed "s/virtualdomain://" `
|
||||
for ldomain in $alldomains ; do
|
||||
sudo cp ../conf/data/domains/domain.tld.ini $rainloop_path/data/_data_/_default_/domains/$ldomain.ini
|
||||
sudo cp ../conf/data/domains/domain.tld.ini $final_path/data/_data_/_default_/domains/$ldomain.ini
|
||||
done
|
||||
# Add wildcard domain for auto-grab
|
||||
sudo cp ../conf/data/domains/default.ini $rainloop_path/data/_data_/_default_/domains/default.ini
|
||||
sudo cp ../conf/data/domains/default.ini $final_path/data/_data_/_default_/domains/default.ini
|
||||
|
||||
# install SSO - at the moment the index is the SSO and rainloop is installed in /app
|
||||
# Install SSO - at the moment the index is the SSO and rainloop is installed in /app
|
||||
sudo cp ../sources/sso/sso.php $final_path/index.php
|
||||
sudo sed -i "s@domain.tld@$domain@g" $final_path/index.php
|
||||
sudo sed -i "s@ALIASTOCHANGE@$final_path@g" $final_path/index.php
|
||||
if [ $path = "/" ]; then
|
||||
sudo sed -i "s@ROOTTOCHANGE@@g" $final_path/index.php
|
||||
else
|
||||
sudo sed -i "s@ROOTTOCHANGE@$path@g" $final_path/index.php
|
||||
fi
|
||||
|
||||
|
||||
# Install PGPback by chtixof to allow users to backup/restore their PGP private keys on the server
|
||||
sudo cp -rf ../sources/pgpback $final_path/.
|
||||
|
||||
# Set permissions to rainloop directory
|
||||
sudo find $final_path/. -type d -exec chmod 755 {} \;
|
||||
sudo find $final_path/. -type f -exec chmod 644 {} \;
|
||||
sudo chown -R www-data:www-data $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP SYSTEMD
|
||||
|
@ -292,6 +263,25 @@ ynh_add_fpm_config
|
|||
|
||||
#ynh_replace_string "match_string" "replace_string" "$final_path/CONFIG_FILE"
|
||||
|
||||
# Set plugins
|
||||
plugins="ynh-login-mapping,auto-domain-grab" # This plugin is trying to automatically grab unknown domains if users want to add external email accounts
|
||||
if [ "$ldap" = "Yes" ];
|
||||
then
|
||||
plugins="$plugins,ynh-ldap-suggestions" # This plugin is to suggest YunoHost users in recipients list
|
||||
fi
|
||||
ynh_app_setting_set "$app" plugins "$plugins"
|
||||
|
||||
# Autoconfig
|
||||
ynh_replace_string "__LANGUAGE__" $language "$application_file"
|
||||
ynh_replace_string "__DOMAIN__" $domain "$application_file"
|
||||
ynh_replace_string "__DB_NAME__" $db_name "$application_file"
|
||||
ynh_replace_string "__DB_PWD__" $db_pwd "$application_file"
|
||||
ynh_replace_string "__PLUGINS__" $plugins "$application_file"
|
||||
|
||||
# Configure SSO
|
||||
ynh_replace_string "__URL__" $domain$path_url $final_path/index.php
|
||||
ynh_replace_string "__FINAL_PATH__" $final_path $final_path/index.php
|
||||
|
||||
#=================================================
|
||||
# STORE THE CONFIG FILE CHECKSUM
|
||||
#=================================================
|
||||
|
@ -302,6 +292,8 @@ ynh_add_fpm_config
|
|||
|
||||
# Calculate and store the config file checksum into the app settings
|
||||
#ynh_store_file_checksum "$final_path/CONFIG_FILE"
|
||||
ynh_store_file_checksum "$application_file"
|
||||
ynh_store_file_checksum "$final_path/index.php"
|
||||
|
||||
#=================================================
|
||||
# GENERIC FINALIZATION
|
||||
|
@ -316,6 +308,11 @@ ynh_add_fpm_config
|
|||
# Set permissions to app files
|
||||
#chown -R root: $final_path
|
||||
|
||||
# Set permissions to rainloop directory
|
||||
sudo find $final_path/. -type d -exec chmod 755 {} \;
|
||||
sudo find $final_path/. -type f -exec chmod 644 {} \;
|
||||
sudo chown -R www-data:www-data $final_path
|
||||
|
||||
#=================================================
|
||||
# SETUP LOGROTATE
|
||||
#=================================================
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
is_public=$(ynh_app_setting_get "$app" is_public)
|
||||
password=$(ynh_app_setting_get "$app" password)
|
||||
ldap=$(ynh_app_setting_get "$app" ldap)
|
||||
lang=$(ynh_app_setting_get "$app" lang)
|
||||
language=$(ynh_app_setting_get "$app" language)
|
||||
dp_pwd=$(ynh_app_setting_get "$app" mysqlpwd)
|
||||
db_user=$app
|
||||
plugins=$(ynh_app_setting_get "$app" plugins)
|
||||
|
@ -42,8 +42,8 @@ CHECK_PATH
|
|||
|
||||
# Copy the new sources
|
||||
final_path=/var/www/$app
|
||||
rainloop_path=${final_path}/app
|
||||
sudo rm -rf $rainloop_path/rainloop # Remove the previous Rainloop files except data
|
||||
final_path=${final_path}/app
|
||||
sudo rm -rf $final_path/rainloop # Remove the previous Rainloop files except data
|
||||
|
||||
# Download sources and keys
|
||||
sudo wget -q https://github.com/RainLoop/rainloop-webmail/releases/download/v${rainloop_version}/rainloop-community-${rainloop_version}.zip
|
||||
|
@ -54,13 +54,13 @@ CHECK_PATH
|
|||
sudo gpg --verify --quiet rainloop-community-${rainloop_version}.zip.asc rainloop-community-${rainloop_version}.zip
|
||||
sudo gpg --batch --delete-key --yes Rainloop
|
||||
# Unzip and overwrite
|
||||
sudo unzip -qq -o rainloop-community-${rainloop_version}.zip -d $rainloop_path/
|
||||
sudo unzip -qq -o rainloop-community-${rainloop_version}.zip -d $final_path/
|
||||
|
||||
# Update ynh plugins:
|
||||
sudo mkdir -p $rainloop_path/data/_data_/_default_/plugins
|
||||
sudo cp -rf ../sources/plugins/auto-domain-grab $rainloop_path/data/_data_/_default_/plugins/.
|
||||
sudo cp -rf ../sources/plugins/ynh-login-mapping $rainloop_path/data/_data_/_default_/plugins/.
|
||||
sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $rainloop_path/data/_data_/_default_/plugins/.
|
||||
sudo mkdir -p $final_path/data/_data_/_default_/plugins
|
||||
sudo cp -rf ../sources/plugins/auto-domain-grab $final_path/data/_data_/_default_/plugins/.
|
||||
sudo cp -rf ../sources/plugins/ynh-login-mapping $final_path/data/_data_/_default_/plugins/.
|
||||
sudo cp -rf ../sources/plugins/ynh-ldap-suggestions $final_path/data/_data_/_default_/plugins/.
|
||||
|
||||
# update SSO
|
||||
sudo cp ../sources/sso/sso.php $final_path/index.php
|
||||
|
|
|
@ -12,6 +12,10 @@
|
|||
|
||||
class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin
|
||||
{
|
||||
|
||||
private $imap_prefix = "mail.";
|
||||
private $smtp_prefix = "mail.";
|
||||
|
||||
public function Init()
|
||||
{
|
||||
$this->addHook('filter.smtp-credentials', 'FilterSmtpCredentials');
|
||||
|
@ -31,7 +35,8 @@ class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
// Check for mail.$DOMAIN as entered value in RL settings
|
||||
if (!empty($aImapCredentials['Host']) && 'auto' === $aImapCredentials['Host'])
|
||||
{
|
||||
$aImapCredentials['Host'] = \MailSo\Base\Utils::GetDomainFromEmail($oAccount->Email());
|
||||
$domain = substr(strrchr($oAccount->Email(), "@"), 1);
|
||||
$aImapCredentials['Host'] = $this->imap_prefix.$domain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +54,8 @@ class AutoDomainGrabPlugin extends \RainLoop\Plugins\AbstractPlugin
|
|||
// Check for mail.$DOMAIN as entered value in RL settings
|
||||
if (!empty($aSmtpCredentials['Host']) && 'auto' === $aSmtpCredentials['Host'])
|
||||
{
|
||||
$aSmtpCredentials['Host'] = \MailSo\Base\Utils::GetDomainFromEmail($oAccount->Email());
|
||||
$domain = substr(strrchr($oAccount->Email(), "@"), 1);
|
||||
$aSmtpCredentials['Host'] = $this->smtp_prefix.$domain;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// Enable RainLoop Api and include index file
|
||||
$_ENV['RAINLOOP_INCLUDE_AS_API'] = true;
|
||||
include 'ALIASTOCHANGE/app/index.php';
|
||||
include '__FINAL_PATH__/app/index.php';
|
||||
|
||||
// Retrieve email and password
|
||||
if (isset($_SERVER['HTTP_EMAIL']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
||||
|
@ -11,8 +11,8 @@ if (isset($_SERVER['HTTP_EMAIL']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
|||
$ssoHash = \RainLoop\Api::GetUserSsoHash($email, $password);
|
||||
|
||||
// redirect to webmail sso url
|
||||
\header('Location: https://domain.tldROOTTOCHANGE/app/index.php?sso&hash='.$ssoHash);
|
||||
\header('Location: https://__URL__app/index.php?sso&hash='.$ssoHash);
|
||||
}
|
||||
else {
|
||||
\header('Location: https://domain.tldROOTTOCHANGE/app/index.php');
|
||||
\header('Location: https://__URL__app/index.php');
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue