mirror of
https://github.com/YunoHost-Apps/jeedom_ynh.git
synced 2024-09-03 19:26:26 +02:00
commit
11bf4d19e6
13 changed files with 309 additions and 150 deletions
|
@ -13,6 +13,7 @@
|
||||||
setup_private=1
|
setup_private=1
|
||||||
setup_public=0
|
setup_public=0
|
||||||
upgrade=1
|
upgrade=1
|
||||||
|
upgrade=1 from_commit=7c7a55f99f8a593078fc37d2200bd6ca86766233
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=0
|
multi_instance=0
|
||||||
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
||||||
|
@ -26,8 +27,5 @@
|
||||||
Email=
|
Email=
|
||||||
Notification=none
|
Notification=none
|
||||||
;;; Upgrade options
|
;;; Upgrade options
|
||||||
; commit=CommitHash
|
; commit=7c7a55f99f8a593078fc37d2200bd6ca86766233
|
||||||
name=Name and date of the commit.
|
name=3.3.45~ynh1
|
||||||
manifest_arg=domain=DOMAIN&path=PATH&admin=USER&language=fr&is_public=1&password=pass&port=666&
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,9 @@ $CONFIG = array(
|
||||||
'db' => array(
|
'db' => array(
|
||||||
'host' => 'localhost',
|
'host' => 'localhost',
|
||||||
'port' => '3306',
|
'port' => '3306',
|
||||||
'dbname' => '#DBNAME#',
|
'dbname' => '__DB_NAME__',
|
||||||
'username' => '#USERNAME#',
|
'username' => '__DB_USER__',
|
||||||
'password' => '#PASSWORD#',
|
'password' => '__DB_PWD__',
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
?>
|
|
||||||
|
|
1
conf/cronjeedom
Normal file
1
conf/cronjeedom
Normal file
|
@ -0,0 +1 @@
|
||||||
|
* * * * * www-data /usr/bin/php__PHPVERSION__ -f __FINALPATH__/core/php/jeeCron.php"
|
1
conf/cronjeedom_watchdog
Normal file
1
conf/cronjeedom_watchdog
Normal file
|
@ -0,0 +1 @@
|
||||||
|
* * * * * root /usr/bin/php__PHPVERSION__ -f __FINALPATH__/core/php/watchdog.php
|
|
@ -21,10 +21,10 @@ location __PATH__/ {
|
||||||
|
|
||||||
fastcgi_index index.php;
|
fastcgi_index index.php;
|
||||||
include fastcgi_params;
|
include fastcgi_params;
|
||||||
fastcgi_buffer_size 128k;
|
fastcgi_buffer_size 128k;
|
||||||
fastcgi_buffers 4 256k;
|
fastcgi_buffers 4 256k;
|
||||||
fastcgi_busy_buffers_size 256k;
|
fastcgi_busy_buffers_size 256k;
|
||||||
fastcgi_read_timeout 300;
|
fastcgi_read_timeout 300;
|
||||||
fastcgi_param REMOTE_USER $remote_user;
|
fastcgi_param REMOTE_USER $remote_user;
|
||||||
fastcgi_param PATH_INFO $fastcgi_path_info;
|
fastcgi_param PATH_INFO $fastcgi_path_info;
|
||||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
; Unix user/group of processes
|
; Unix user/group of processes
|
||||||
; Note: The user is mandatory. If the group is not set, the default user's group
|
; Note: The user is mandatory. If the group is not set, the default user's group
|
||||||
; will be used.
|
; will be used.
|
||||||
user = __USER__
|
user = www-data
|
||||||
group = __USER__
|
group = www-data
|
||||||
|
|
||||||
; The address on which to accept FastCGI requests.
|
; The address on which to accept FastCGI requests.
|
||||||
; Valid syntaxes are:
|
; Valid syntaxes are:
|
||||||
|
|
|
@ -3,10 +3,10 @@
|
||||||
"id": "jeedom",
|
"id": "jeedom",
|
||||||
"packaging_format": 1,
|
"packaging_format": 1,
|
||||||
"description": {
|
"description": {
|
||||||
"en": "Jeedom is a home automation application",
|
"en": "Home automation application",
|
||||||
"fr": "Jeedom est une application de domotique"
|
"fr": "Application de domotique"
|
||||||
},
|
},
|
||||||
"version": "3.3.45~ynh1",
|
"version": "3.3.45~ynh2",
|
||||||
"url": "http://www.jeedom.fr/",
|
"url": "http://www.jeedom.fr/",
|
||||||
"license": "free",
|
"license": "free",
|
||||||
"maintainer": {
|
"maintainer": {
|
||||||
|
|
|
@ -5,8 +5,25 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
# dependencies used by the app
|
# dependencies used by the app
|
||||||
pkg_dependencies="php-curl php-gd php-imap php-xml php-opcache php-soap php-xmlrpc php-common php-dev php-zip php-ssh2 php-mbstring php-ldap"
|
pkg_dependencies="ntp ca-certificates unzip curl cron \
|
||||||
|
locate tar telnet wget logrotate fail2ban dos2unix ntpdate htop iotop vim iftop smbclient \
|
||||||
|
git python python-pip \
|
||||||
|
python3 python3-pip \
|
||||||
|
software-properties-common \
|
||||||
|
libexpat1 ssl-cert \
|
||||||
|
apt-transport-https \
|
||||||
|
xvfb cutycapt xauth \
|
||||||
|
duplicity \
|
||||||
|
at \
|
||||||
|
php-curl php-gd php-imap php-xml php-soap php-xmlrpc php-common php-dev php-zip php-ssh2 php-mbstring php-ldap \
|
||||||
|
ffmpeg"
|
||||||
# ntp usb-modeswitch python-serial
|
# ntp usb-modeswitch python-serial
|
||||||
|
extra_pkg_dependencies="libsox-fmt-mp3 sox libttspico-utils \
|
||||||
|
espeak \
|
||||||
|
mbrola \
|
||||||
|
brltty \
|
||||||
|
net-tools \
|
||||||
|
nmap"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PERSONAL HELPERS
|
# PERSONAL HELPERS
|
||||||
|
|
102
scripts/install
102
scripts/install
|
@ -7,6 +7,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
source ynh_add_config
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -58,6 +59,14 @@ ynh_script_progression --message="Installing dependencies..."
|
||||||
|
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# INSTALL EXTRA DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Installing extra dependencies ..."
|
||||||
|
|
||||||
|
lsb_name="$(lsb_release --codename --short)"
|
||||||
|
ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $lsb_name contrib non-free" --package="$extra_pkg_dependencies"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE A MYSQL DATABASE
|
# CREATE A MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -85,33 +94,6 @@ ynh_script_progression --message="Configuring nginx web server..."
|
||||||
# Create a dedicated nginx config
|
# Create a dedicated nginx config
|
||||||
ynh_add_nginx_config
|
ynh_add_nginx_config
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# CREATE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Configuring system user..."
|
|
||||||
|
|
||||||
# Create a system user
|
|
||||||
ynh_system_user_create --username=$app
|
|
||||||
|
|
||||||
# For nginx user to be able to communicate with home automation devices
|
|
||||||
if [ $(getent group dialout) ]; then
|
|
||||||
usermod -a -G dialout $app
|
|
||||||
fi
|
|
||||||
if [ $(getent group gpio) ]; then
|
|
||||||
usermod -a -G gpio $app
|
|
||||||
fi
|
|
||||||
if [ $(getent group tty) ]; then
|
|
||||||
usermod -a -G tty $app
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Sudo permissions to the user if agreed to
|
|
||||||
if [ $sudo ]; then
|
|
||||||
usermod -a -G sudo $app
|
|
||||||
if [ $(sudo grep "$app ALL=(ALL) NOPASSWD: ALL" /etc/sudoers | wc -l) -eq 0 ];then
|
|
||||||
bash -c 'echo "'${app}' ALL=(ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo)'
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -119,47 +101,61 @@ ynh_script_progression --message="Configuring php-fpm..."
|
||||||
|
|
||||||
# Create a dedicated php-fpm config
|
# Create a dedicated php-fpm config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config
|
||||||
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC SETUP
|
# SPECIFIC SETUP
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURING RIGHTS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring rights..."
|
||||||
|
|
||||||
|
# Create tmp required by Jeedom
|
||||||
|
mkdir -p /tmp/jeedom
|
||||||
|
chmod 777 -R /tmp/jeedom
|
||||||
|
chown www-data:www-data -R /tmp/jeedom
|
||||||
|
|
||||||
|
# For nginx user to be able to communicate with home automation devices
|
||||||
|
if [ $(getent group dialout) ]; then
|
||||||
|
usermod -a -G dialout www-data
|
||||||
|
fi
|
||||||
|
if [ $(getent group gpio) ]; then
|
||||||
|
usermod -a -G gpio www-data
|
||||||
|
fi
|
||||||
|
if [ $(getent group tty) ]; then
|
||||||
|
usermod -a -G tty www-data
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Sudo permissions to the user if agreed to
|
||||||
|
if [ $sudo ]; then
|
||||||
|
usermod -a -G sudo www-data
|
||||||
|
if [ $(grep "www-data ALL=(ALL) NOPASSWD: ALL" /etc/sudoers | wc -l) -eq 0 ];then
|
||||||
|
bash -c 'echo "www-data ALL=(ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo)'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL JEEDOM
|
# INSTALL JEEDOM
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Installing Jeedom..."
|
ynh_script_progression --message="Installing Jeedom..."
|
||||||
|
|
||||||
# Configure Jeedom database and initialize app
|
# Configure Jeedom database
|
||||||
ynh_replace_string "#DBNAME#" "$db_name" ../conf/common.config.php
|
ynh_add_config --template="common.config.php" --destination="$final_path/core/config/common.config.php"
|
||||||
ynh_replace_string "#USERNAME#" "$db_name" ../conf/common.config.php
|
|
||||||
ynh_replace_string "#PASSWORD#" "$db_pwd" ../conf/common.config.php
|
|
||||||
sudo cp ../conf/common.config.php $final_path/core/config/common.config.php
|
|
||||||
|
|
||||||
# Install Jeedom
|
# Install Jeedom
|
||||||
sudo php $final_path/install/install.php mode=force
|
php$phpversion $final_path/install/install.php mode=force
|
||||||
|
|
||||||
# Configure LDAP and the Admin User and access settings
|
# Configure LDAP and the Admin User and access settings
|
||||||
ynh_replace_string "__ADMIN__" "$admin" ../conf/config.sql
|
ynh_replace_string --match_string="__ADMIN__" --replace_string="$admin" --target_file="../conf/config.sql"
|
||||||
mysql -u $db_name -p$db_pwd $db_name < ../conf/config.sql
|
ynh_mysql_execute_file_as_root --file="../conf/config.sql" --database=$db_name
|
||||||
|
|
||||||
# Cron
|
# Cron
|
||||||
echo "* * * * * $app /usr/bin/php -f $final_path/core/php/jeeCron.php" > cronjeedom
|
ynh_add_config --template="cronjeedom" --destination="/etc/cron.d/${app}"
|
||||||
sudo mv cronjeedom /etc/cron.d/${app}
|
ynh_add_config --template="cronjeedom_watchdog" --destination="/etc/cron.d/${app}_watchdog"
|
||||||
sudo chown root /etc/cron.d/${app}
|
|
||||||
|
|
||||||
echo "* * * * * $app /usr/bin/php -f $final_path/core/php/watchdog.php" > cronjeedom_watchdog
|
|
||||||
sudo mv cronjeedom_watchdog /etc/cron.d/${app}_watchdog
|
|
||||||
sudo chown root /etc/cron.d/${app}_watchdog
|
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
#sudo php $final_path/install/sick.php
|
#sudo php $final_path/install/sick.php
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# STORE THE CONFIG FILE CHECKSUM
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Storing the config file checksum..."
|
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
|
||||||
ynh_store_file_checksum --file="$final_path/core/config/common.config.php"
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -168,12 +164,12 @@ ynh_store_file_checksum --file="$final_path/core/config/common.config.php"
|
||||||
ynh_script_progression --message="Securing files and directories..."
|
ynh_script_progression --message="Securing files and directories..."
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R $app: $final_path
|
|
||||||
chmod 775 -R $final_path
|
chmod 775 -R $final_path
|
||||||
|
chown -R www-data:www-data $final_path
|
||||||
|
|
||||||
# Create tmp required by Jeedom
|
# Create tmp required by Jeedom
|
||||||
mkdir -p /tmp/jeedom
|
|
||||||
chmod 777 -R /tmp/jeedom
|
chmod 777 -R /tmp/jeedom
|
||||||
|
chown www-data:www-data -R /tmp/jeedom
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
|
|
@ -64,24 +64,21 @@ ynh_script_progression --message="Removing php-fpm configuration..."
|
||||||
ynh_remove_fpm_config
|
ynh_remove_fpm_config
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE THE CRON FILE
|
# SPECIFIC REMOVE
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Removing the cron file..."
|
# REMOVE VARIOUS FILES
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Removing various files..."
|
||||||
|
|
||||||
# Remove cron files
|
# Remove cron files
|
||||||
ynh_secure_remove --file="/etc/cron.d/${app}"
|
ynh_secure_remove --file="/etc/cron.d/${app}"
|
||||||
ynh_secure_remove --file="/etc/cron.d/${app}_watchdog"
|
ynh_secure_remove --file="/etc/cron.d/${app}_watchdog"
|
||||||
|
|
||||||
|
# Remove cron files
|
||||||
|
ynh_secure_remove --file="/tmp/jeedom"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# GENERIC FINALIZATION
|
# GENERIC FINALIZATION
|
||||||
#=================================================
|
|
||||||
# REMOVE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Removing the dedicated system user..."
|
|
||||||
|
|
||||||
# Delete a system user
|
|
||||||
ynh_system_user_delete --username=$app
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# END OF SCRIPT
|
# END OF SCRIPT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -61,45 +61,14 @@ ynh_script_progression --message="Restoring the app main directory..."
|
||||||
|
|
||||||
ynh_restore_file --origin_path="$final_path"
|
ynh_restore_file --origin_path="$final_path"
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# RECREATE THE DEDICATED USER
|
|
||||||
#=================================================
|
|
||||||
ynh_script_progression --message="Recreating the dedicated system user..."
|
|
||||||
|
|
||||||
# Create the dedicated user (if not existing)
|
|
||||||
ynh_system_user_create --username=$app
|
|
||||||
|
|
||||||
# For nginx user to be able to communicate with home automation devices
|
|
||||||
if [ $(getent group dialout) ]; then
|
|
||||||
usermod -a -G dialout $app
|
|
||||||
fi
|
|
||||||
if [ $(getent group gpio) ]; then
|
|
||||||
usermod -a -G gpio $app
|
|
||||||
fi
|
|
||||||
if [ $(getent group tty) ]; then
|
|
||||||
usermod -a -G tty $app
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Sudo permissions to the user if agreed to
|
|
||||||
if [ $sudo ]; then
|
|
||||||
usermod -a -G sudo $app
|
|
||||||
if [ $(sudo grep "$app ALL=(ALL) NOPASSWD: ALL" /etc/sudoers | wc -l) -eq 0 ];then
|
|
||||||
bash -c 'echo "'${app}' ALL=(ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo)'
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE USER RIGHTS
|
# RESTORE USER RIGHTS
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Restoring user rights..."
|
ynh_script_progression --message="Restoring user rights..."
|
||||||
|
|
||||||
# Restore permissions on app files
|
# Restore permissions on app files
|
||||||
chown -R $app: $final_path
|
|
||||||
chmod 775 -R $final_path
|
chmod 775 -R $final_path
|
||||||
|
chown -R www-data:www-data $final_path
|
||||||
# Create tmp required by Jeedom
|
|
||||||
mkdir -p /tmp/jeedom
|
|
||||||
chmod 777 -R /tmp/jeedom
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE PHP-FPM CONFIGURATION
|
# RESTORE THE PHP-FPM CONFIGURATION
|
||||||
|
@ -118,6 +87,43 @@ ynh_script_progression --message="Reinstalling dependencies..."
|
||||||
# Define and install dependencies
|
# Define and install dependencies
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# REINSTALL EXTRA DEPENDENCIES
|
||||||
|
#=================================================
|
||||||
|
ynh_print_info --message="Reinstalling extra dependencies ..."
|
||||||
|
|
||||||
|
lsb_name="$(lsb_release --codename --short)"
|
||||||
|
ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $lsb_name contrib non-free" --package="$extra_pkg_dependencies"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURING RIGHTS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring rights..."
|
||||||
|
|
||||||
|
# Create tmp required by Jeedom
|
||||||
|
mkdir -p /tmp/jeedom
|
||||||
|
chmod 777 -R /tmp/jeedom
|
||||||
|
chown www-data:www-data -R /tmp/jeedom
|
||||||
|
|
||||||
|
# For nginx user to be able to communicate with home automation devices
|
||||||
|
if [ $(getent group dialout) ]; then
|
||||||
|
usermod -a -G dialout www-data
|
||||||
|
fi
|
||||||
|
if [ $(getent group gpio) ]; then
|
||||||
|
usermod -a -G gpio www-data
|
||||||
|
fi
|
||||||
|
if [ $(getent group tty) ]; then
|
||||||
|
usermod -a -G tty www-data
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Sudo permissions to the user if agreed to
|
||||||
|
if [ $sudo ]; then
|
||||||
|
usermod -a -G sudo www-data
|
||||||
|
if [ $(grep "www-data ALL=(ALL) NOPASSWD: ALL" /etc/sudoers | wc -l) -eq 0 ];then
|
||||||
|
bash -c 'echo "www-data ALL=(ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo)'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE MYSQL DATABASE
|
# RESTORE THE MYSQL DATABASE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -127,7 +133,6 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=mysqlpwd)
|
||||||
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
ynh_mysql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd
|
||||||
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
ynh_mysql_connect_as --user=$db_user --password=$db_pwd --database=$db_name < ./db.sql
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE THE CRON FILES
|
# RESTORE THE CRON FILES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
source _common.sh
|
source _common.sh
|
||||||
|
source ynh_add_config
|
||||||
source /usr/share/yunohost/helpers
|
source /usr/share/yunohost/helpers
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -40,8 +41,8 @@ if [ "$sudo" = "Yes" ]; then
|
||||||
ynh_app_setting_set --app=$app --key=sudo --value=1
|
ynh_app_setting_set --app=$app --key=sudo --value=1
|
||||||
sudo=1
|
sudo=1
|
||||||
# Removes sudo to www-data
|
# Removes sudo to www-data
|
||||||
if [ $(sudo grep "www-data ALL=(ALL) NOPASSWD: ALL" /etc/sudoers | wc -l) -eq 0 ];then
|
if [ $(grep "www-data ALL=(ALL) NOPASSWD: ALL" /etc/sudoers | wc -l) -eq 0 ];then
|
||||||
sudo sed -i "/www-data ALL=(ALL) NOPASSWD: ALL/d" /etc/sudoers
|
sed -i "/www-data ALL=(ALL) NOPASSWD: ALL/d" /etc/sudoers
|
||||||
fi
|
fi
|
||||||
elif [ "$sudo" = "No" ]; then
|
elif [ "$sudo" = "No" ]; then
|
||||||
ynh_app_setting_set --app=$app --key=sudo --value=0
|
ynh_app_setting_set --app=$app --key=sudo --value=0
|
||||||
|
@ -111,31 +112,12 @@ ynh_script_progression --message="Upgrading dependencies..."
|
||||||
ynh_install_app_dependencies $pkg_dependencies
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# CREATE DEDICATED USER
|
# UPGRADE EXTRA DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Making sure dedicated system user exists..."
|
ynh_print_info --message="Upgrading extra dependencies ..."
|
||||||
|
|
||||||
# Create a dedicated user (if not existing)
|
lsb_name="$(lsb_release --codename --short)"
|
||||||
ynh_system_user_create --username=$app
|
ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian $lsb_name contrib non-free" --package="$extra_pkg_dependencies"
|
||||||
|
|
||||||
# For nginx user to be able to communicate with home automation devices
|
|
||||||
if [ $(getent group dialout) ]; then
|
|
||||||
usermod -a -G dialout $app
|
|
||||||
fi
|
|
||||||
if [ $(getent group gpio) ]; then
|
|
||||||
usermod -a -G gpio $app
|
|
||||||
fi
|
|
||||||
if [ $(getent group tty) ]; then
|
|
||||||
usermod -a -G tty $app
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Sudo permissions to the user if agreed to
|
|
||||||
if [ $sudo ]; then
|
|
||||||
usermod -a -G sudo $app
|
|
||||||
if [ $(grep "$app ALL=(ALL) NOPASSWD: ALL" /etc/sudoers | wc -l) -eq 0 ];then
|
|
||||||
bash -c 'echo "'${app}' ALL=(ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo)'
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# PHP-FPM CONFIGURATION
|
# PHP-FPM CONFIGURATION
|
||||||
|
@ -144,25 +126,50 @@ ynh_script_progression --message="Upgrading php-fpm configuration..."
|
||||||
|
|
||||||
# Create a dedicated php-fpm config
|
# Create a dedicated php-fpm config
|
||||||
ynh_add_fpm_config
|
ynh_add_fpm_config
|
||||||
|
phpversion=$(ynh_app_setting_get --app=$app --key=phpversion)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC UPGRADE
|
# SPECIFIC UPGRADE
|
||||||
|
#=================================================
|
||||||
|
# CONFIGURING RIGHTS
|
||||||
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring rights..."
|
||||||
|
|
||||||
|
# Create tmp required by Jeedom
|
||||||
|
mkdir -p /tmp/jeedom
|
||||||
|
chmod 777 -R /tmp/jeedom
|
||||||
|
chown www-data:www-data -R /tmp/jeedom
|
||||||
|
|
||||||
|
# For nginx user to be able to communicate with home automation devices
|
||||||
|
if [ $(getent group dialout) ]; then
|
||||||
|
usermod -a -G dialout www-data
|
||||||
|
fi
|
||||||
|
if [ $(getent group gpio) ]; then
|
||||||
|
usermod -a -G gpio www-data
|
||||||
|
fi
|
||||||
|
if [ $(getent group tty) ]; then
|
||||||
|
usermod -a -G tty www-data
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Sudo permissions to the user if agreed to
|
||||||
|
if [ $sudo ]; then
|
||||||
|
usermod -a -G sudo www-data
|
||||||
|
if [ $(grep "www-data ALL=(ALL) NOPASSWD: ALL" /etc/sudoers | wc -l) -eq 0 ];then
|
||||||
|
bash -c 'echo "www-data ALL=(ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo)'
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# UPGRADE JEEDOM
|
# UPGRADE JEEDOM
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_script_progression --message="Upgrading Jeedom..."
|
ynh_script_progression --message="Upgrading Jeedom..."
|
||||||
|
|
||||||
# Upgrade Jeedom
|
# Upgrade Jeedom
|
||||||
php $final_path/install/install.php mode=force
|
php$phpversion $final_path/install/install.php mode=force
|
||||||
|
|
||||||
# Cron
|
# Cron
|
||||||
echo "* * * * * $app /usr/bin/php -f $final_path/core/php/jeeCron.php" > cronjeedom
|
ynh_add_config --template="cronjeedom" --destination="/etc/cron.d/${app}"
|
||||||
sudo mv cronjeedom /etc/cron.d/${app}
|
ynh_add_config --template="cronjeedom_watchdog" --destination="/etc/cron.d/${app}_watchdog"
|
||||||
sudo chown root /etc/cron.d/${app}
|
|
||||||
|
|
||||||
echo "* * * * * $app /usr/bin/php -f $final_path/core/php/watchdog.php" > cronjeedom_watchdog
|
|
||||||
mv cronjeedom_watchdog /etc/cron.d/${app}_watchdog
|
|
||||||
chown root /etc/cron.d/${app}_watchdog
|
|
||||||
|
|
||||||
# Check
|
# Check
|
||||||
#php $final_path/install/sick.php
|
#php $final_path/install/sick.php
|
||||||
|
@ -175,12 +182,12 @@ chown root /etc/cron.d/${app}_watchdog
|
||||||
ynh_script_progression --message="Securing files and directories..."
|
ynh_script_progression --message="Securing files and directories..."
|
||||||
|
|
||||||
# Set permissions to app files
|
# Set permissions to app files
|
||||||
chown -R $app: $final_path
|
|
||||||
chmod 775 -R $final_path
|
chmod 775 -R $final_path
|
||||||
|
chown -R www-data:www-data $final_path
|
||||||
|
|
||||||
# Create tmp required by Jeedom
|
# Create tmp required by Jeedom
|
||||||
mkdir -p /tmp/jeedom
|
|
||||||
chmod 777 -R /tmp/jeedom
|
chmod 777 -R /tmp/jeedom
|
||||||
|
chown www-data:www-data -R /tmp/jeedom
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SETUP SSOWAT
|
# SETUP SSOWAT
|
||||||
|
|
137
scripts/ynh_add_config
Normal file
137
scripts/ynh_add_config
Normal file
|
@ -0,0 +1,137 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Create a dedicated config file from a template
|
||||||
|
#
|
||||||
|
# examples:
|
||||||
|
# ynh_add_config --template=".env" --destination="$final_path/.env"
|
||||||
|
# ynh_add_config --template="../conf/.env" --destination="$final_path/.env"
|
||||||
|
# ynh_add_config --template="/etc/nginx/sites-available/default" --destination="etc/nginx/sites-available/mydomain.conf"
|
||||||
|
#
|
||||||
|
# usage: ynh_add_config --template="template" --destination="destination"
|
||||||
|
# | arg: -t, --template= - Template config file to use
|
||||||
|
# | arg: -d, --destination= - Destination of the config file
|
||||||
|
#
|
||||||
|
# The template can be by default the name of a file in the conf directory
|
||||||
|
# of a YunoHost Package, a relative path or an absolute path
|
||||||
|
# The helper will use the template $template to generate a config file
|
||||||
|
# $destination by replacing the following keywords with global variables
|
||||||
|
# that should be defined before calling this helper :
|
||||||
|
# __PATH__ by $path_url
|
||||||
|
# __NAME__ by $app
|
||||||
|
# __NAMETOCHANGE__ by $app
|
||||||
|
# __USER__ by $app
|
||||||
|
# __FINALPATH__ by $final_path
|
||||||
|
# __PHPVERSION__ by $YNH_PHP_VERSION
|
||||||
|
#
|
||||||
|
# And any dynamic variables that should be defined before calling this helper like:
|
||||||
|
# __DOMAIN__ by $domain
|
||||||
|
# __APP__ by $app
|
||||||
|
# __VAR_1__ by $var_1
|
||||||
|
# __VAR_2__ by $var_2
|
||||||
|
#
|
||||||
|
# The helper will verify the checksum and backup the destination file
|
||||||
|
# if it's different before applying the new template.
|
||||||
|
# And it will calculate and store the destination file checksum
|
||||||
|
# into the app settings when configuration is done.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
ynh_add_config () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=tdv
|
||||||
|
local -A args_array=( [t]=template= [d]=destination= )
|
||||||
|
local template
|
||||||
|
local destination
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
local template_path
|
||||||
|
|
||||||
|
if [ -f "../conf/$template" ]; then
|
||||||
|
template_path="../conf/$template"
|
||||||
|
elif [ -f "../settings/conf/$template" ]; then
|
||||||
|
template_path="../settings/conf/$template"
|
||||||
|
elif [ -f "$template" ]; then
|
||||||
|
template_path=$template
|
||||||
|
else
|
||||||
|
ynh_die --message="The provided template $template doesn't exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
ynh_backup_if_checksum_is_different --file="$destination"
|
||||||
|
|
||||||
|
cp "$template_path" "$destination"
|
||||||
|
|
||||||
|
ynh_replace_vars --file="$destination"
|
||||||
|
|
||||||
|
ynh_store_file_checksum --file="$destination"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Replace variables in a file
|
||||||
|
#
|
||||||
|
# usage: ynh_replace_vars --file="file"
|
||||||
|
# | arg: -f, --file= - File where to replace variables
|
||||||
|
#
|
||||||
|
# The helper will replace the following keywords with global variables
|
||||||
|
# that should be defined before calling this helper :
|
||||||
|
# __PATH__ by $path_url
|
||||||
|
# __NAME__ by $app
|
||||||
|
# __NAMETOCHANGE__ by $app
|
||||||
|
# __USER__ by $app
|
||||||
|
# __FINALPATH__ by $final_path
|
||||||
|
# __PHPVERSION__ by $YNH_PHP_VERSION
|
||||||
|
#
|
||||||
|
# And any dynamic variables that should be defined before calling this helper like:
|
||||||
|
# __DOMAIN__ by $domain
|
||||||
|
# __APP__ by $app
|
||||||
|
# __VAR_1__ by $var_1
|
||||||
|
# __VAR_2__ by $var_2
|
||||||
|
#
|
||||||
|
#
|
||||||
|
ynh_replace_vars () {
|
||||||
|
# Declare an array to define the options of this helper.
|
||||||
|
local legacy_args=f
|
||||||
|
local -A args_array=( [f]=file= )
|
||||||
|
local file
|
||||||
|
# Manage arguments with getopts
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
|
||||||
|
# Replace specific YunoHost variables
|
||||||
|
if test -n "${path_url:-}"
|
||||||
|
then
|
||||||
|
# path_url_slash_less is path_url, or a blank value if path_url is only '/'
|
||||||
|
local path_url_slash_less=${path_url%/}
|
||||||
|
ynh_replace_string --match_string="__PATH__/" --replace_string="$path_url_slash_less/" --target_file="$file"
|
||||||
|
ynh_replace_string --match_string="__PATH__" --replace_string="$path_url" --target_file="$file"
|
||||||
|
fi
|
||||||
|
if test -n "${app:-}"; then
|
||||||
|
ynh_replace_string --match_string="__NAME__" --replace_string="$app" --target_file="$file"
|
||||||
|
ynh_replace_string --match_string="__NAMETOCHANGE__" --replace_string="$app" --target_file="$file"
|
||||||
|
ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="$file"
|
||||||
|
fi
|
||||||
|
if test -n "${final_path:-}"; then
|
||||||
|
ynh_replace_string --match_string="__FINALPATH__" --replace_string="$final_path" --target_file="$file"
|
||||||
|
fi
|
||||||
|
if test -n "${YNH_PHP_VERSION:-}"; then
|
||||||
|
ynh_replace_string --match_string="__PHPVERSION__" --replace_string="$YNH_PHP_VERSION" --target_file="$file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Replace othes variables
|
||||||
|
|
||||||
|
# List other unique (__ __) variables in $file
|
||||||
|
local uniques_vars=( $(grep -o '__[A-Z0-9_]*__' $file | sort --unique | sed "s@__\([^.]*\)__@\L\1@g" ))
|
||||||
|
|
||||||
|
# Do the replacement
|
||||||
|
local delimit=@
|
||||||
|
for one_var in "${uniques_vars[@]}"
|
||||||
|
do
|
||||||
|
# Validate that one_var is indeed defined
|
||||||
|
test -n "${!one_var:-}" || ynh_die --message="\$$one_var wasn't initialized when trying to replace __${one_var^^}__ in $file"
|
||||||
|
|
||||||
|
# Escape delimiter in match/replace string
|
||||||
|
match_string="__${one_var^^}__"
|
||||||
|
match_string=${match_string//${delimit}/"\\${delimit}"}
|
||||||
|
replace_string="${!one_var}"
|
||||||
|
replace_string=${replace_string//${delimit}/"\\${delimit}"}
|
||||||
|
|
||||||
|
# Actually replace (sed is used instead of ynh_replace_string to avoid triggering an epic amount of debug logs)
|
||||||
|
sed --in-place "s${delimit}${match_string}${delimit}${replace_string}${delimit}g" "$file"
|
||||||
|
done
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue