diff --git a/README.md b/README.md index 2684827..6290e75 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ Rainloop is a lightweight webmail. To configure it, go to http://DOMAIN.TLD/rainloop/app/?admin -- The default login is : user chosen during install -- The default password is : 12345 +- The default login is : admin +- The default password is : Password chosen during install Each user can add a remote carddav server from their own parameters interface. If you use baikal, the CardDav address is : @@ -24,8 +24,8 @@ Rainloop est un webmail simple et léger. Pour le configurer après l'installation, veuillez vous rendre sur http://DOMAIN.TLD/rainloop/app/?admin -- Le nom d'utilisateur admin par défaut est : utilisateur choisi lors de l'installation -- Le mot de passe admin par défaut est : 12345 +- Le nom d'utilisateur admin par défaut est : admin +- Le mot de passe admin par défaut est : Mot de passe choisi lors de l'installation Chaque utilisateur peut ajouter un carnet d'adresse distant CardDav via leur propre paramètres. Si vous utilisez Baikal, l'adresse à renseigner est du type : diff --git a/conf/config.php b/conf/config.php new file mode 100644 index 0000000..f5a61c7 --- /dev/null +++ b/conf/config.php @@ -0,0 +1,9 @@ +SetPassword('ADMINPASSWORD'); +echo $oConfig->Save() ? 'Admin password updated' : 'Admin password not updated'; + +?> \ No newline at end of file diff --git a/conf/data/configs/application.ini b/conf/data/configs/application.ini index 3c9fb54..40d5054 100644 --- a/conf/data/configs/application.ini +++ b/conf/data/configs/application.ini @@ -17,10 +17,10 @@ allow_themes = On allow_user_background = Off ; Language used by default -language = "en" +language = "LANGTOCHANGE" ; Admin Panel interface language -language_admin = "en" +language_admin = "LANGTOCHANGE" ; Allow language selection on settings screen allow_languages_on_settings = On @@ -147,7 +147,7 @@ view_editor_type = "Html" ; layout: 0 - no preview, 1 - side preview, 2 - bottom preview view_layout = 1 view_use_checkboxes = On -autologout = 30 +autologout = Off show_images = Off contacts_autosave = On mail_use_threads = Off diff --git a/conf/nginx.conf b/conf/nginx.conf index c7d5d44..b21ed87 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -5,6 +5,10 @@ location PATHTOCHANGE { rewrite ^ https://$server_name$request_uri? permanent; } + location ^~ PATHTOCHANGEapp/data { + deny all; + } + client_max_body_size 10G; index index.php; try_files $uri $uri/ index.php; diff --git a/conf/sso.php b/conf/sso.php index 88c8a3e..0764943 100644 --- a/conf/sso.php +++ b/conf/sso.php @@ -2,7 +2,7 @@ // Enable RainLoop Api and include index file $_ENV['RAINLOOP_INCLUDE_AS_API'] = true; -include '/var/www/rainloop/index.php'; +include '/var/www/rainloop/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.tldPATHTOCHANGE/index.php?sso&hash='.$ssoHash); + \header('Location: https://domain.tldPATHTOCHANGE/app/index.php?sso&hash='.$ssoHash); } else { - \header('Location: https://domain.tldPATHTOCHANGE/index.php'); + \header('Location: https://domain.tldPATHTOCHANGE/app/index.php'); } diff --git a/manifest.json b/manifest.json index f243e5e..c95de22 100644 --- a/manifest.json +++ b/manifest.json @@ -42,13 +42,12 @@ "default": "No" }, { - "name": "admin", - "type": "user", + "name": "password", + "type": "password", "ask": { - "en": "Choose the Rainloop administrator (must be an existing YunoHost user)", - "fr": "Choisissez l'administrateur Rainloop (doit être un utilisateur YunoHost déjà existant)" - }, - "example": "homer" + "en": "Choose a strong password for the 'admin' user", + "fr": "Choisissez un mot de passe fort pour l'administrateur 'admin'" + } } ] } diff --git a/scripts/install b/scripts/install index 5d1cd8c..408915b 100644 --- a/scripts/install +++ b/scripts/install @@ -6,7 +6,7 @@ app=rainloop domain=$1 path=$2 is_public=$3 -user=$4 +password=$4 # Check user parameter sudo yunohost user list --json | grep -qi "\"username\": \"$user\"" \ @@ -26,8 +26,6 @@ else path=${path%/} fi - - # Check domain/path availability sudo yunohost app checkurl $domain$path -a rainloop if [[ ! $? -eq 0 ]]; then @@ -48,40 +46,51 @@ sudo yunohost app setting rainloop mysqlpwd -v $db_pwd # Copy files to the right place final_path=/var/www/$app +rainloop_path=${final_path}/app + sudo rm -rf $final_path sudo mkdir -p $final_path +sudo mkdir -p $rainloop_path + # Use of latest community edition -sudo wget http://repository.rainloop.net/v2/webmail/rainloop-community-latest.zip -O $final_path/rainloop.zip -sudo unzip $final_path/rainloop.zip -d $final_path/ -sudo rm $final_path/rainloop.zip +sudo wget http://repository.rainloop.net/v2/webmail/rainloop-community-latest.zip -O $rainloop_path/rainloop.zip +sudo unzip $rainloop_path/rainloop.zip -d $rainloop_path/ +sudo rm $rainloop_path/rainloop.zip # Autoconfig -sudo mkdir -p $final_path/data/_data_/_default_/configs/ +sudo mkdir -p $rainloop_path/data/_data_/_default_/configs/ sed -i "s@domain.tld@$domain@g" ../conf/data/configs/application.ini -sed -i "s@ADMINUSER@$user@g" ../conf/data/configs/application.ini -sed -i "s@ADMINPASSWORD@12345@g" ../conf/data/configs/application.ini sed -i "s@MYSQLUSER@db_user@g" ../conf/data/configs/application.ini sed -i "s@MYSQLPASSWORD@$db_pwd@g" ../conf/data/configs/application.ini -sudo cp ../conf/data/configs/application.ini $final_path/data/_data_/_default_/configs/application.ini +if [ $(echo $LANG | cut -c1-2) == "fr" ] +then + lang=fr +else + lang=en +fi +sed -i "s@LANGTOCHANGE@$lang@g" ../conf/data/configs/application.ini +sudo cp ../conf/data/configs/application.ini $rainloop_path/data/_data_/_default_/configs/application.ini -# Add default domain config -sudo mkdir -p $final_path/data/_data_/_default_/domains/ -sed -i "s@domain.tld@$domain@g" ../conf/data/domains/domain.tld.ini -sudo cp ../conf/data/domains/domain.tld.ini $final_path/data/_data_/_default_/domains/$domain.ini -sudo cp ../conf/data/domains/disabled $final_path/data/_data_/_default_/domains/disabled +# Set admin password +sed -i "s@ADMINPASSWORD@$password@g" ../conf/data/config.php +sudo php ../conf/data/config.php + +# Add default domain configs by looping through all the domains already added +sudo mkdir -p $rainloop_path/data/_data_/_default_/domains/ +sudo yunohost domain list | sed -e '1d' | while read -r line ; do + domain=${line//- } + sed -i "s@domain.tld@$domain@g" ../conf/data/domains/domain.tld.ini + sudo cp ../conf/data/domains/domain.tld.ini $rainloop_path/data/_data_/_default_/domains/$domain.ini + sed -i "s@$domain@domain.tld@g" ../conf/data/domains/domain.tld.ini +done +sudo cp ../conf/data/domains/disabled $rainloop_path/data/_data_/_default_/domains/disabled + +# Hooks for domains are not implemented yet, so new domains will not be added automatically # SSO sed -i "s@domain.tld@$domain@g" ../conf/sso.php sed -i "s@PATHTOCHANGE@$path@g" ../conf/sso.php -sudo cp ../conf/sso.php $final_path/sso.php - -# Temporary workaround until someone finds a way to setup NGINX properly... -sudo mkdir -p $final_path/app -sudo mv $final_path/index.php $final_path/app/index.php -sudo mv $final_path/data $final_path/app/data -sudo mv $final_path/rainloop $final_path/app/rainloop -sudo sed -i "s@index.php@app/index.php@g" $final_path/sso.php -sudo mv $final_path/sso.php $final_path/index.php +sudo cp ../conf/sso.php $final_path/index.php # Set permissions to rainloop directory # sudo mkdir -p $final_path/logs diff --git a/scripts/upgrade b/scripts/upgrade index 7439145..0d5f237 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -16,14 +16,18 @@ sudo yunohost app initdb $db_user -p $db_pwd # Copy files to the right place final_path=/var/www/$app -#sudo rm -rf $final_path/* -# Use of latest community edition -sudo wget http://repository.rainloop.net/v2/webmail/rainloop-community-latest.zip -O $final_path/rainloop.zip -sudo unzip -ou $final_path/rainloop.zip -d $final_path/ -sudo rm $final_path/rainloop.zip +rainloop_path=${final_path}/app + +sudo rm -rf $final_path +sudo mkdir -p $final_path +sudo mkdir -p $rainloop_path + +# Use of latest community edition +sudo wget http://repository.rainloop.net/v2/webmail/rainloop-community-latest.zip -O $rainloop_path/rainloop.zip +sudo unzip $rainloop_path/rainloop.zip -d $rainloop_path/ +sudo rm $rainloop_path/rainloop.zip + -# Set permissions to rainloop directory -sudo chown -R www-data:www-data /var/www/$app # Modify Nginx configuration file and copy it to Nginx conf directory sed -i "s@PATHTOCHANGE@$path@g" ../conf/nginx.conf @@ -40,15 +44,10 @@ sudo chmod 644 $finalphpconf # SSO sed -i "s@domain.tld@$domain@g" ../conf/sso.php sed -i "s@PATHTOCHANGE@$path@g" ../conf/sso.php -sudo cp ../conf/sso.php $final_path/sso.php +sudo cp ../conf/sso.php $final_path/index.php -# Temporary workaround until someone finds a way to setup NGINX properly... -sudo mkdir -p $final_path/app -sudo mv $final_path/index.php $final_path/app/index.php -sudo mv $final_path/data $final_path/app/data -sudo mv $final_path/rainloop $final_path/app/rainloop -sudo sed -i "s@index.php@app/index.php@g" $final_path/sso.php -sudo mv $final_path/sso.php $final_path/index.php +# Set permissions to rainloop directory +sudo chown -R www-data:www-data $final_path # Make app public if necessary sudo yunohost app setting $app is_public -v "$is_public"