Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DietPi-Globals | G_CONFIG_INJECT: Auto escaping of special characters #2227

Merged
merged 18 commits into from
Nov 8, 2018
3 changes: 2 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ Changes / Improvements / Optimisations:
Bug Fixes:
- PREP: Resolved failed rootFS resize: https://github.com/Fourdee/DietPi/issues/2181#issuecomment-433715556
- DietPi-Config | Locale: Resolved an issue where DietPi would always display en_GB as the current locale: https://github.com/Fourdee/DietPi/issues/2216#issuecomment-435599419
- DietPi-Automation | CONFIG_NTP_MODE is now applied after APT cache, and, initial time sync is updated. Due to packages required for some modes: https://github.com/Fourdee/DietPi/issues/2181#issuecomment-433444882
- DietPi-Software | Roon Bridge: Resolved an issue where the remote update would fail due to underpriv permissions: https://community.roonlabs.com/t/dietpi-allo-units-not-getting-the-roonbridge-b167-update-from-b164/52503/6
- DietPi-Software | Nextcloud: Resolved an issue with failed installation: https://github.com/Fourdee/DietPi/issues/2184
- DietPi-Software | Nextcloud/Owncloud: Resolved an issue where userdata located on external drive would fail the installation: https://github.com/Fourdee/DietPi/issues/2221
- DietPi-Automation | CONFIG_NTP_MODE is now applied after APT cache, and, initial time sync is updated. Due to packages required for some modes: https://github.com/Fourdee/DietPi/issues/2181#issuecomment-433444882
- DietPi-Software | OMPD/MyMPD: Resolved inability to update database. Currently we have rolled back the versions of these programs to a working state. We will investigate with the devs to find out the cause for future release: https://github.com/Fourdee/DietPi/issues/2156
- DietPi-Software | Jackett: Resolved an issue where reinstall created an additional nested install dir. Thanks @msdos for reporting this issue: https://github.com/Fourdee/DietPi/issues/2212
- DietPi-Software | RoonServer: Resolved an issue where reinstall created an additional nested install dir. Since RoonServer has an automated internal updater, download and install will be skipped, if install already exists.
- DietPi-Software | PHP/databases: Resolved an issue where PHP database modules were not installed, when installing a new database and PHP was already installed before.
- DietPi-Software | OpenBazaar: Resolved an issue where remote OB clients could not connect to server with default configuration: https://github.com/Fourdee/DietPi/pull/2224
- DietPi-Software | Resolved an issue where a global password with special characters lead to failing installs, due to missing escaping within our internal function G_CONFIG_INJECT. Thanks to @MistahDarcy for reporting this issue: https://github.com/Fourdee/DietPi/issues/2215
- DietPi-Obtain_network_details | Resolved a tiny visual-only error message on non-root logins. Thanks to @AndrewZ for reporting: https://dietpi.com/phpbb/viewtopic.php?f=9&t=5194
- DietPi-Update | Resolved a visual-only issue, where wrong RC versions could have been shown during incremental patching: https://github.com/Fourdee/DietPi/issues/2190

Expand Down
10 changes: 5 additions & 5 deletions PREP_SYSTEM_FOR_DIETPI.sh
Original file line number Diff line number Diff line change
Expand Up @@ -958,7 +958,7 @@ _EOF_
rm /etc/profile.d/99-dietpi* &> /dev/null

# - Enable /etc/bashrc.d/ support for custom interactive non-login shell scripts:
G_CONFIG_INJECT '.*/etc/bashrc\.d/.*' 'for i in /etc/bashrc\.d/\*\.sh; do \[ -r "\$i" \] \&\& \. \$i; done' /etc/bash.bashrc
G_CONFIG_INJECT '.*/etc/bashrc\.d/.*' 'for i in /etc/bashrc.d/*.sh; do [ -r "$i" ] && . $i; done' /etc/bash.bashrc

# - Enable bash-completion for non-login shells:
# - NB: It is called twice on login shells then, but breaks directly if called already once.
Expand Down Expand Up @@ -1056,7 +1056,7 @@ _EOF_
G_DIETPI-NOTIFY 2 'Add dietpi.com SSH pub host key for DietPi-Survey and -Bugreport upload:'
mkdir -p /root/.ssh
>> /root/.ssh/known_hosts
G_CONFIG_INJECT 'ssh.dietpi.com ' 'ssh.dietpi.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDE6aw3r6aOEqendNu376iiCHr9tGBIWPgfrLkzjXjEsHGyVSUFNnZt6pftrDeK7UX\+qX4FxOwQlugG4fymOHbimRCFiv6cf7VpYg1Ednquq9TLb7/cIIbX8a6AuRmX4fjdGuqwmBq3OG7ZksFcYEFKt5U4mAJIaL8hXiM2iXjgY02LqiQY/QWATsHI4ie9ZOnwrQE\+Rr6mASN1BVFuIgyHIbwX54jsFSnZ/7CdBMkuAd9B8JkxppWVYpYIFHE9oWNfjh/epdK8yv9Oo6r0w5Rb\+4qaAc5g\+RAaknHeV6Gp75d2lxBdCm5XknKKbGma2\+/DfoE8WZTSgzXrYcRlStYN' /root/.ssh/known_hosts
G_CONFIG_INJECT 'ssh.dietpi.com ' 'ssh.dietpi.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDE6aw3r6aOEqendNu376iiCHr9tGBIWPgfrLkzjXjEsHGyVSUFNnZt6pftrDeK7UX+qX4FxOwQlugG4fymOHbimRCFiv6cf7VpYg1Ednquq9TLb7/cIIbX8a6AuRmX4fjdGuqwmBq3OG7ZksFcYEFKt5U4mAJIaL8hXiM2iXjgY02LqiQY/QWATsHI4ie9ZOnwrQE+Rr6mASN1BVFuIgyHIbwX54jsFSnZ/7CdBMkuAd9B8JkxppWVYpYIFHE9oWNfjh/epdK8yv9Oo6r0w5Rb+4qaAc5g+RAaknHeV6Gp75d2lxBdCm5XknKKbGma2+/DfoE8WZTSgzXrYcRlStYN' /root/.ssh/known_hosts

#-----------------------------------------------------------------------------------
#MISC
Expand Down Expand Up @@ -1116,7 +1116,7 @@ _EOF_
# ASUS TB WiFi: https://github.com/Fourdee/DietPi/issues/1760
elif (( $G_HW_MODEL == 52 )); then

G_CONFIG_INJECT '^8723bs' '8723bs' /etc/modules
G_CONFIG_INJECT '8723bs' '8723bs' /etc/modules

fi

Expand Down Expand Up @@ -1431,8 +1431,8 @@ _EOF_
# - Finalize GRUB
if [[ -f '/etc/default/grub' ]]; then

G_CONFIG_INJECT 'GRUB_CMDLINE_LINUX_DEFAULT=' 'GRUB_CMDLINE_LINUX_DEFAULT=\"consoleblank=0 quiet\"' /etc/default/grub
G_CONFIG_INJECT 'GRUB_CMDLINE_LINUX=' 'GRUB_CMDLINE_LINUX=\"net\.ifnames=0\"' /etc/default/grub
G_CONFIG_INJECT 'GRUB_CMDLINE_LINUX_DEFAULT=' 'GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=0 quiet"' /etc/default/grub
G_CONFIG_INJECT 'GRUB_CMDLINE_LINUX=' 'GRUB_CMDLINE_LINUX="net.ifnames=0"' /etc/default/grub
G_CONFIG_INJECT 'GRUB_TIMEOUT=' 'GRUB_TIMEOUT=3' /etc/default/grub
l_message='Finalizing GRUB' G_RUN_CMD update-grub

Expand Down
32 changes: 16 additions & 16 deletions dietpi/dietpi-software
Original file line number Diff line number Diff line change
Expand Up @@ -7482,7 +7482,7 @@ _EOF_
fi

# - Set UTF-8
G_CONFIG_INJECT 'default_charset[[:blank:]]*=' 'default_charset=\"UTF-8\"' $target_php_ini
G_CONFIG_INJECT 'default_charset[[:blank:]]*=' 'default_charset="UTF-8"' $target_php_ini

# Enable all installed and available PHP modules.
local modules_to_enable=$(ls "$FP_PHP_BASE_DIR"/mods-available | grep '.ini' | sed 's/.ini//')
Expand Down Expand Up @@ -7611,7 +7611,7 @@ This is required, since the ${aSOFTWARE_WHIP_NAME[$software_id]} server node by
fi

done
G_CONFIG_INJECT '"AllowedIPs":' " \"AllowedIPs\": [\n \"$ob_client_ip\"\n ]," $G_FP_DIETPI_USERDATA/openbazaar/config
GCI_NEWLINE=1 G_CONFIG_INJECT '"AllowedIPs":' " \"AllowedIPs\": [\n \"$ob_client_ip\"\n ]," $G_FP_DIETPI_USERDATA/openbazaar/config

else

Expand Down Expand Up @@ -7897,27 +7897,27 @@ _EOF_
# Set pretty URLs (without /index.php/) on Apache:
if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then

PRESERVE=1 G_CONFIG_INJECT "'htaccess.RewriteBase'" "'htaccess.RewriteBase' => '/owncloud'," $config_php "'overwrite.cli.url'"
GCI_PRESERVE=1 G_CONFIG_INJECT "'htaccess.RewriteBase'" "'htaccess.RewriteBase' => '/owncloud'," $config_php "'overwrite.cli.url'"
occ maintenance:update:htaccess

fi

# APCu Memcache
PRESERVE=1 G_CONFIG_INJECT "'memcache.local'" "'memcache.local' => '\\\\OC\\\\Memcache\\\\APCu'," $config_php "'version'"
GCI_PRESERVE=1 G_CONFIG_INJECT "'memcache.local'" "'memcache.local' => '\\\\OC\\\\Memcache\\\\APCu'," $config_php "'version'"

# Redis for transactional file locking:
G_DIETPI-NOTIFY 2 'Enabling Redis for transactional file locking.' # https://doc.owncloud.org/server/latest/admin_manual/configuration/server/caching_configuration.html#configuring-transactional-file-locking
local redis_conf="/etc/redis/redis*.conf"
# - Enable Redis socket and grant www-data access to it:
# - NB: To allow wildcard expansion, do not use quotes around $redis_conf!
PRESERVE=1 G_CONFIG_INJECT 'unixsocket[[:blank:]]' 'unixsocket /var/run/redis/redis-server.sock' $redis_conf
GCI_PRESERVE=1 G_CONFIG_INJECT 'unixsocket[[:blank:]]' 'unixsocket /var/run/redis/redis-server.sock' $redis_conf
G_CONFIG_INJECT 'unixsocketperm[[:blank:]]' 'unixsocketperm 770' $redis_conf
local redis_sock=$(grep -m1 '^[[:blank:]]*unixsocket[[:blank:]]' $redis_conf | awk '{print $2}')
usermod -a -G redis www-data
G_RUN_CMD systemctl restart redis-server
# - Enable ownCloud to use Redis socket for transactional file locking:
G_CONFIG_INJECT "'filelocking.enabled'" "'filelocking.enabled' => true," $config_php "'memcache.local'"
PRESERVE=1 G_CONFIG_INJECT "'memcache.locking'" "'memcache.locking' => '\\\\OC\\\\Memcache\\\\Redis',\n'redis' => array ('host' => '$redis_sock', 'port' => 0,)," $config_php "'filelocking.enabled'"
GCI_PRESERVE=1 GCI_NEWLINE=1 G_CONFIG_INJECT "'memcache.locking'" "'memcache.locking' => '\\\\OC\\\\Memcache\\\\Redis',\n'redis' => array ('host' => '$redis_sock', 'port' => 0,)," $config_php "'filelocking.enabled'"

# Enable ownCloud background cron job:
crontab -u www-data -l 2>/dev/null | grep -q '/var/www/owncloud/cron.php' || ( crontab -u www-data -l 2>/dev/null ; echo "*/15 * * * * php /var/www/owncloud/cron.php" ) | crontab -u www-data -
Expand Down Expand Up @@ -8177,27 +8177,27 @@ The install script will now exit. After applying one of the the above, rerun die
# Set pretty URLs (without /index.php/) on Apache:
if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then

PRESERVE=1 G_CONFIG_INJECT "'htaccess.RewriteBase'" "'htaccess.RewriteBase' => '/nextcloud'," $config_php "'overwrite.cli.url'"
GCI_PRESERVE=1 G_CONFIG_INJECT "'htaccess.RewriteBase'" "'htaccess.RewriteBase' => '/nextcloud'," $config_php "'overwrite.cli.url'"
ncc maintenance:update:htaccess

fi

# APCu Memcache
PRESERVE=1 G_CONFIG_INJECT "'memcache.local'" "'memcache.local' => '\\\\OC\\\\Memcache\\\\APCu'," $config_php "'version'"
GCI_PRESERVE=1 G_CONFIG_INJECT "'memcache.local'" "'memcache.local' => '\\\\OC\\\\Memcache\\\\APCu'," $config_php "'version'"

# Redis for transactional file locking:
G_DIETPI-NOTIFY 2 'Enabling Redis for transactional file locking.' # https://docs.nextcloud.com/server/14/admin_manual/configuration_files/files_locking_transactional.html
local redis_conf="/etc/redis/redis*.conf"
# - Enable Redis socket and grant www-data access to it:
# - NB: To allow wildcard expansion, do not use quotes around $redis_conf!
PRESERVE=1 G_CONFIG_INJECT 'unixsocket[[:blank:]]' 'unixsocket /var/run/redis/redis-server.sock' $redis_conf
GCI_PRESERVE=1 G_CONFIG_INJECT 'unixsocket[[:blank:]]' 'unixsocket /var/run/redis/redis-server.sock' $redis_conf
G_CONFIG_INJECT 'unixsocketperm[[:blank:]]' 'unixsocketperm 770' $redis_conf
local redis_sock=$(grep -m1 '^[[:blank:]]*unixsocket[[:blank:]]' $redis_conf | awk '{print $2}')
usermod -a -G redis www-data
G_RUN_CMD systemctl restart redis-server
# - Enable Nextloud to use Redis socket:
G_CONFIG_INJECT "'filelocking.enabled'" "'filelocking.enabled' => true," $config_php "'memcache.local'"
PRESERVE=1 G_CONFIG_INJECT "'memcache.locking'" "'memcache.locking' => '\\\\OC\\\\Memcache\\\\Redis',\n'redis' => array ('host' => '$redis_sock', 'port' => 0,)," $config_php "'filelocking.enabled'"
GCI_PRESERVE=1 GCI_NEWLINE=1 G_CONFIG_INJECT "'memcache.locking'" "'memcache.locking' => '\\\\OC\\\\Memcache\\\\Redis',\n'redis' => array ('host' => '$redis_sock', 'port' => 0,)," $config_php "'filelocking.enabled'"

# Enable Nextcloud background cron job:
crontab -u www-data -l 2>/dev/null | grep -q '/var/www/nextcloud/cron.php' || ( crontab -u www-data -l 2>/dev/null ; echo "*/15 * * * * php /var/www/nextcloud/cron.php" ) | crontab -u www-data -
Expand Down Expand Up @@ -8264,8 +8264,8 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal
G_CONFIG_INJECT 'lt-cred-mech' 'lt-cred-mech' /etc/turnserver.conf
G_CONFIG_INJECT 'use-auth-secret' 'use-auth-secret' /etc/turnserver.conf
G_CONFIG_INJECT 'realm=' "realm=$domain" /etc/turnserver.conf
PRESERVE=1 G_CONFIG_INJECT 'total-quota=' 'total-quota=100' /etc/turnserver.conf
PRESERVE=1 G_CONFIG_INJECT 'bps-capacity=' 'bps-capacity=0' /etc/turnserver.conf
GCI_PRESERVE=1 G_CONFIG_INJECT 'total-quota=' 'total-quota=100' /etc/turnserver.conf
GCI_PRESERVE=1 G_CONFIG_INJECT 'bps-capacity=' 'bps-capacity=0' /etc/turnserver.conf
G_CONFIG_INJECT 'stale-nonce' 'stale-nonce' /etc/turnserver.conf
G_CONFIG_INJECT 'no-loopback-peers' 'no-loopback-peers' /etc/turnserver.conf
G_CONFIG_INJECT 'no-multicast-peers' 'no-multicast-peers' /etc/turnserver.conf
Expand Down Expand Up @@ -8300,7 +8300,7 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal
ncc config:app:set spreed stun_servers --value="[\"$domain:$port\"]"
# Generate random secret to secure TURN server access
local secret=$(openssl rand -hex 32)
PRESERVE=1 G_CONFIG_INJECT 'static-auth-secret=' "static-auth-secret=$secret" /etc/turnserver.conf
GCI_PRESERVE=1 G_CONFIG_INJECT 'static-auth-secret=' "static-auth-secret=$secret" /etc/turnserver.conf
# Scrape existing secret, in case user manually chose/edited it
secret="$(grep -m1 '^[[:blank:]]*static-auth-secret=' /etc/turnserver.conf)"
secret="${secret#*static-auth-secret=}"
Expand Down Expand Up @@ -8347,7 +8347,7 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal
G_CONFIG_INJECT '"message-level"' '"message-level": 0,' /etc/transmission-daemon/settings.json

# To allow access for download managers and media software, files need to be created with 77X permissions.
G_CONFIG_INJECT '\"umask\":' ' \"umask\": 7,' /etc/transmission-daemon/settings.json
G_CONFIG_INJECT '\"umask\":' ' "umask": 7,' /etc/transmission-daemon/settings.json

echo '}' >> /etc/transmission-daemon/settings.json

Expand Down Expand Up @@ -12141,8 +12141,8 @@ ExecStart=/bin/bash -c '/var/lib/dietpi/dietpi-software/installed/pi-spc/sds.sh'
WantedBy=multi-user.target
_EOF_

# G_CONFIG_INJECT '^dtoverlay=gpio-shutdown' 'dtoverlay=gpio-shutdown,gpio_pin=22,active_low=0' /DietPi/config.txt
# G_CONFIG_INJECT '^dtoverlay=gpio-poweroff' 'dtoverlay=gpio-poweroff,gpio_pin=17' /DietPi/config.txt
# G_CONFIG_INJECT 'dtoverlay=gpio-shutdown' 'dtoverlay=gpio-shutdown,gpio_pin=22,active_low=0' /DietPi/config.txt
# G_CONFIG_INJECT 'dtoverlay=gpio-poweroff' 'dtoverlay=gpio-poweroff,gpio_pin=17' /DietPi/config.txt

fi

Expand Down
Loading