diff --git a/.conf/desktop/lxde/panel b/.conf/desktop/lxde/panel
index 0c444613de..0b2ff23450 100644
--- a/.conf/desktop/lxde/panel
+++ b/.conf/desktop/lxde/panel
@@ -140,25 +140,6 @@ Plugin {
Size=5
}
}
-Plugin {
- type=weather
- Config {
- alias=london
- city=London
- state=England
- country=United Kingdom
- woeid="44418"
- units=c
- interval=20
- enabled=1
- }
-}
-Plugin {
- type=space
- Config {
- Size=5
- }
-}
Plugin {
type=dclock
Config {
diff --git a/.conf/dps_114/apache.nextcloud.conf b/.conf/dps_114/apache.nextcloud.conf
index d7e6cfbaa6..55994d9fef 100644
--- a/.conf/dps_114/apache.nextcloud.conf
+++ b/.conf/dps_114/apache.nextcloud.conf
@@ -1,3 +1,5 @@
+# Based on: https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#apache-web-server-configuration
+
Options +FollowSymlinks
AllowOverride All
diff --git a/.conf/dps_114/lighttpd.nextcloud.conf b/.conf/dps_114/lighttpd.nextcloud.conf
index ba00c74e33..f61d733670 100644
--- a/.conf/dps_114/lighttpd.nextcloud.conf
+++ b/.conf/dps_114/lighttpd.nextcloud.conf
@@ -1,9 +1,30 @@
-# Solve OPcache settings warning on Nextcloud admin panel:
+# Derived from:
+# - Apache: https://github.com/nextcloud/server/blob/master/.htaccess
+# - Nginx: https://docs.nextcloud.com/server/stable/admin_manual/installation/nginx.html
+
$HTTP["url"] =~ "^/nextcloud($|/)" {
- setenv.add-environment += (
- "PHP_ADMIN_VALUE" => "opcache.memory_consumption=128",
- )
-}
-# Set "Referrer-Policy" = "no-referrer" security header
-setenv.add-response-header = ( "Referrer-Policy" => "no-referrer" )
+ # Hardening
+ # - Directories
+ $HTTP["url"] =~ "^/nextcloud/(build|tests|config|lib|3rdparty|templates|data)($|/)" { url.access-deny = ("") }
+ # - Files
+ $HTTP["url"] =~ "^/nextcloud/(\.|autotest|occ|issue|indie|db_|console)" { url.access-deny = ("") }
+ # - Directory listing
+ dir-listing.active = "disable"
+ # - Cache control and security headers for static resources
+ $HTTP["url"] =~ "^/nextcloud/.*\.(css|js|woff2?|svg|gif)$" {
+ setenv.add-response-header += (
+ "Cache-Control" => "public, max-age=15778463",
+ "X-Content-Type-Options" => "nosniff",
+ "X-XSS-Protection" => "1; mode=block",
+ "X-Robots-Tag" => "none",
+ "X-Download-Options" => "noopen",
+ "X-Permitted-Cross-Domain-Policies" => "none",
+ "Referrer-Policy" => "no-referrer",
+ )
+ }
+
+ # Solve OPcache settings warning on Nextcloud admin panel
+ setenv.add-environment += ( "PHP_ADMIN_VALUE" => "opcache.memory_consumption=128" )
+
+}
diff --git a/.conf/dps_114/nginx.nextcloud.conf b/.conf/dps_114/nginx.nextcloud.conf
index 4710138f07..fefb601b29 100644
--- a/.conf/dps_114/nginx.nextcloud.conf
+++ b/.conf/dps_114/nginx.nextcloud.conf
@@ -1,16 +1,20 @@
+# Based on: https://docs.nextcloud.com/server/stable/admin_manual/installation/nginx.html
+
location ^~ /nextcloud {
- # Security headers
- add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
+ # Add headers to serve security related headers
+ #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains;";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
add_header X-Permitted-Cross-Domain-Policies none;
- #add_header X-Frame-Options "SAMEORIGIN";
- add_header Referrer-Policy "no-referrer";
+ add_header Referrer-Policy no-referrer;
+
+ # Remove X-Powered-By, which is an information leak
+ fastcgi_hide_header X-Powered-By;
- # set max upload size
+ # Set max upload size
client_max_body_size 1048576M;
fastcgi_buffers 64 4K;
@@ -26,9 +30,6 @@ location ^~ /nextcloud {
# This module is currently not supported.
#pagespeed off;
- error_page 403 /nextcloud/core/templates/403.php;
- error_page 404 /nextcloud/core/templates/404.php;
-
location /nextcloud {
rewrite ^ /nextcloud/index.php$request_uri;
}
@@ -46,16 +47,15 @@ location ^~ /nextcloud {
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
# HTTPS forces redirection from http://, thus has to be enabled only on active HTTPS environment.
- #fastcgi_param HTTPS on;
+ fastcgi_param HTTPS $https;
# Avoid sending the security headers twice
fastcgi_param modHeadersAvailable true;
- # Front controller enables pretty URLs without /index.php/, which works fine since Nextcloud 13!
fastcgi_param front_controller_active true;
fastcgi_pass php;
fastcgi_intercept_errors on;
- # Disable on Jessie, because Jessie Nginx does not support that parameter
+ # Disable on Jessie, because Jessie Nginx does not support this directive
#fastcgi_request_buffering off;
- # Hard coding 128M OPCache size, only for /nextcloud, to suppress warning on nextcloud admin panel.
+ # Hard coding 128M OPCache size to suppress warning on Nextcloud admin panel.
fastcgi_param PHP_ADMIN_VALUE "opcache.memory_consumption=128";
}
@@ -71,15 +71,14 @@ location ^~ /nextcloud {
add_header Cache-Control "public, max-age=15778463";
# Add headers to serve security related headers (It is intended
# to have those duplicated to the ones above)
- # Before enabling Strict-Transport-Security headers please read
- # into this topic first.
- add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;";
+ #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains;";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header X-Download-Options noopen;
- #add_header X-Frame-Options "SAMEORIGIN";
add_header X-Permitted-Cross-Domain-Policies none;
+ add_header Referrer-Policy no-referrer;
+
# Optional: Don't log access to assets
access_log off;
}
diff --git a/.conf/dps_118/mopidy.conf b/.conf/dps_118/mopidy.conf
new file mode 100644
index 0000000000..673b2375f6
--- /dev/null
+++ b/.conf/dps_118/mopidy.conf
@@ -0,0 +1,20 @@
+[core]
+cache_dir = /mnt/dietpi_userdata/mopidy/cache
+config_dir = /etc/mopidy
+data_dir = /mnt/dietpi_userdata/mopidy/data
+
+[logging]
+config_file = /etc/mopidy/logging.conf
+debug_file = /var/log/mopidy/mopidy.log
+
+[local]
+media_dir = /mnt
+
+[file]
+media_dirs = /mnt|Mounts
+
+[m3u]
+playlists_dir = /mnt/dietpi_userdata/Music
+
+[http]
+hostname = ::
diff --git a/dietpi/conf/mpd.conf b/.conf/dps_128/mpd.conf
similarity index 99%
rename from dietpi/conf/mpd.conf
rename to .conf/dps_128/mpd.conf
index 50e93811f8..64ae79f22f 100644
--- a/dietpi/conf/mpd.conf
+++ b/.conf/dps_128/mpd.conf
@@ -6,7 +6,7 @@ pid_file "/var/run/mpd/pid"
state_file "/mnt/dietpi_userdata/.mpd_cache/state"
sticker_file "/mnt/dietpi_userdata/.mpd_cache/sticker.sql"
-user "root"
+user "mpd"
group "dietpi"
bind_to_address "localhost"
diff --git a/.conf/dps_47/apache.owncloud.conf b/.conf/dps_47/apache.owncloud.conf
index 39f947e21b..f3623610e3 100644
--- a/.conf/dps_47/apache.owncloud.conf
+++ b/.conf/dps_47/apache.owncloud.conf
@@ -1,3 +1,5 @@
+# Based on: https://doc.owncloud.org/server/administration_manual/installation/manual_installation.html#configure-apache-web-server
+
Options +FollowSymlinks
AllowOverride All
diff --git a/.conf/dps_47/lighttpd.owncloud.conf b/.conf/dps_47/lighttpd.owncloud.conf
new file mode 100644
index 0000000000..0f6211d132
--- /dev/null
+++ b/.conf/dps_47/lighttpd.owncloud.conf
@@ -0,0 +1,28 @@
+# Derived from:
+# - Apache: https://github.com/owncloud/core/blob/master/.htaccess
+# - Nginx: https://doc.owncloud.org/server/administration_manual/installation/nginx_configuration.html
+
+$HTTP["url"] =~ "^/owncloud($|/)" {
+
+ # Hardening
+ # - Directories
+ $HTTP["url"] =~ "^/owncloud/(build|tests|config|lib|3rdparty|templates|data)($|/)" { url.access-deny = ("") }
+ # - Files
+ $HTTP["url"] =~ "^/owncloud/(\.|autotest|occ|issue|indie|db_|console)" { url.access-deny = ("") }
+ # - Directory listing
+ dir-listing.active = "disable"
+ # - Cache control and security headers for static resources
+ $HTTP["url"] =~ "^/owncloud/.+\.(css|js)" {
+ setenv.add-response-header += (
+ "Cache-Control" => "public, max-age=15778463",
+ "X-Frame-Options" => "SAMEORIGIN",
+ "X-Content-Type-Options" => "nosniff",
+ "X-XSS-Protection" => "1; mode=block",
+ "X-Robots-Tag" => "none",
+ "X-Download-Options" => "noopen",
+ "X-Permitted-Cross-Domain-Policies" => "none",
+ "Referrer-Policy" => "no-referrer",
+ )
+ }
+
+}
diff --git a/.conf/dps_47/nginx.owncloud.conf b/.conf/dps_47/nginx.owncloud.conf
index 93e9b491be..160501c915 100644
--- a/.conf/dps_47/nginx.owncloud.conf
+++ b/.conf/dps_47/nginx.owncloud.conf
@@ -1,95 +1,94 @@
-location ^~ /owncloud {
-
- # Add headers to serve security related headers
- # Before enabling Strict-Transport-Security headers please read into this topic first.
- add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
- add_header X-Content-Type-Options nosniff;
- add_header X-Frame-Options "SAMEORIGIN";
- add_header X-XSS-Protection "1; mode=block";
- add_header X-Robots-Tag none;
- add_header X-Download-Options noopen;
- add_header X-Permitted-Cross-Domain-Policies none;
- add_header Referrer-Policy "no-referrer";
+# Based on: https://doc.owncloud.org/server/administration_manual/installation/nginx_configuration.html
- # set max upload size
- client_max_body_size 1048576M;
- # Do not set the number of buffers over 63, in our example it is set to 8.
- # When exeeding, big file downloads can possibly consume a lot of system memory over time and cause problems especially on low-mem systems.
- fastcgi_buffers 8 4K;
- # From ownCloud version 10.0.4 on, a header statement will be sent to nginx not to use buffers to avoid problems with problematic fastcgi_buffers values. See note above.
- # If these values are properly set and no problems are expected, you can turn on this statement to reenable buffering overriding the sent header.
- # In case you use an earlier version of ownCloud or can´t change the buffers, or you can´t remove a existing ignore header statement, you can explicitly set fastcgi_buffering off;
- # These statements are used either or but not together.
- fastcgi_ignore_headers X-Accel-Buffering;
+location ^~ /owncloud {
- # Disable gzip to avoid the removal of the ETag header
- # Enabling gzip would also make your server vulnerable to BREACH
- # if no additional measures are done. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773332
- gzip off;
+ # Add headers to serve security related headers
+ #add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
+ add_header X-Content-Type-Options nosniff;
+ add_header X-Frame-Options "SAMEORIGIN";
+ add_header X-XSS-Protection "1; mode=block";
+ add_header X-Robots-Tag none;
+ add_header X-Download-Options noopen;
+ add_header X-Permitted-Cross-Domain-Policies none;
+ add_header Referrer-Policy no-referrer;
- # Uncomment if your server is build with the ngx_pagespeed module
- # This module is currently not supported.
- #pagespeed off;
+ # Set max upload size
+ client_max_body_size 1048576M;
+ # Do not set the number of buffers over 63, in our example it is set to 8.
+ # When exeeding, big file downloads can possibly consume a lot of system memory over time and cause problems especially on low-mem systems.
+ fastcgi_buffers 8 4K;
+ # From ownCloud version 10.0.4 on, a header statement will be sent to nginx not to use buffers to avoid problems with problematic fastcgi_buffers values. See note above.
+ # If these values are properly set and no problems are expected, you can turn on this statement to reenable buffering overriding the sent header.
+ # In case you use an earlier version of ownCloud or can´t change the buffers, or you can´t remove a existing ignore header statement, you can explicitly set fastcgi_buffering off;
+ # These statements are used either or but not together.
+ fastcgi_ignore_headers X-Accel-Buffering;
- error_page 403 /owncloud/core/templates/403.php;
- error_page 404 /owncloud/core/templates/404.php;
+ # Disable gzip to avoid the removal of the ETag header
+ # Enabling gzip would also make your server vulnerable to BREACH
+ # if no additional measures are done. See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=773332
+ gzip off;
- location /owncloud {
- rewrite ^ /owncloud/index.php$uri;
- }
+ # Uncomment if your server is build with the ngx_pagespeed module
+ # This module is currently not supported.
+ #pagespeed off;
- location ~ ^/owncloud/(?:build|tests|config|lib|3rdparty|templates|data)/ {
- return 404;
- }
+ error_page 403 /owncloud/core/templates/403.php;
+ error_page 404 /owncloud/core/templates/404.php;
- location ~ ^/owncloud/(?:\.|autotest|occ|issue|indie|db_|console) {
- return 404;
- }
+ location /owncloud {
+ rewrite ^ /owncloud/index.php$uri;
+ }
- location ~ ^/owncloud/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
- fastcgi_split_path_info ^(.+\.php)(/.*)$;
- include fastcgi_params;
- fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
- fastcgi_param SCRIPT_NAME $fastcgi_script_name; # necessary for owncloud to detect the contextroot https://github.com/owncloud/core/blob/v10.0.0/lib/private/AppFramework/Http/Request.php#L603
- fastcgi_param PATH_INFO $fastcgi_path_info;
- #fastcgi_param HTTPS on;
- fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
- # EXPERIMENTAL: active the following if you need to get rid of the 'index.php' in the URLs
- fastcgi_param front_controller_active true;
- fastcgi_read_timeout 180; # increase default timeout e.g. for long running carddav/ caldav syncs with 1000+ entries
- fastcgi_pass php;
- fastcgi_intercept_errors on;
- #fastcgi_request_buffering off; #Available since NGINX 1.7.11
- }
+ location ~ ^/owncloud/(?:build|tests|config|lib|3rdparty|templates|data)/ {
+ return 404;
+ }
+ location ~ ^/owncloud/(?:\.|autotest|occ|issue|indie|db_|console) {
+ return 404;
+ }
- location ~ ^/owncloud/(?:updater|ocs-provider)(?:$|/) {
- try_files $uri $uri/ =404;
- index index.php;
- }
+ location ~ ^/owncloud/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
+ fastcgi_split_path_info ^(.+\.php)(/.*)$;
+ include fastcgi_params;
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+ fastcgi_param SCRIPT_NAME $fastcgi_script_name; # necessary for owncloud to detect the contextroot https://github.com/owncloud/core/blob/v10.0.0/lib/private/AppFramework/Http/Request.php#L603
+ fastcgi_param PATH_INFO $fastcgi_path_info;
+ fastcgi_param HTTPS $https;
+ fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
+ # EXPERIMENTAL: active the following if you need to get rid of the 'index.php' in the URLs
+ fastcgi_param front_controller_active true;
+ fastcgi_read_timeout 180; # increase default timeout e.g. for long running carddav/ caldav syncs with 1000+ entries
+ fastcgi_pass php;
+ fastcgi_intercept_errors on;
+ #fastcgi_request_buffering off; #Available since NGINX 1.7.11
+ }
- # Adding the cache control header for js and css files
- # Make sure it is BELOW the PHP block
- location ~ /owncloud(\/.*\.(?:css|js)) {
- try_files $uri /owncloud/index.php$uri$is_args$args;
- add_header Cache-Control "max-age=15778463";
- # Add headers to serve security related headers (It is intended to have those duplicated to the ones above)
- # Before enabling Strict-Transport-Security headers please read into this topic first.
- add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
- add_header X-Content-Type-Options nosniff;
- add_header X-Frame-Options "SAMEORIGIN";
- add_header X-XSS-Protection "1; mode=block";
- add_header X-Robots-Tag none;
- add_header X-Download-Options noopen;
- add_header X-Permitted-Cross-Domain-Policies none;
- # Optional: Don't log access to assets
- access_log off;
- }
+ location ~ ^/owncloud/(?:updater|ocs-provider)(?:$|/) {
+ try_files $uri $uri/ =404;
+ index index.php;
+ }
- location ~ /owncloud(/.*\.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg|map)) {
- try_files $uri /owncloud/index.php$uri$is_args$args;
- add_header Cache-Control "public, max-age=7200";
- # Optional: Don't log access to other assets
- access_log off;
- }
+ # Adding the cache control header for js and css files
+ # Make sure it is BELOW the PHP block
+ location ~ /owncloud/.*\.(?:css|js) {
+ try_files $uri /owncloud/index.php$uri$is_args$args;
+ add_header Cache-Control "max-age=15778463";
+ # Add headers to serve security related headers (It is intended to have those duplicated to the ones above)
+ #add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";
+ add_header X-Content-Type-Options nosniff;
+ add_header X-Frame-Options "SAMEORIGIN";
+ add_header X-XSS-Protection "1; mode=block";
+ add_header X-Robots-Tag none;
+ add_header X-Download-Options noopen;
+ add_header X-Permitted-Cross-Domain-Policies none;
+ add_header Referrer-Policy no-referrer;
+ # Optional: Don't log access to assets
+ access_log off;
+ }
+ location ~ /owncloud/.*\.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg|map|json) {
+ try_files $uri /owncloud/index.php$uri$is_args$args;
+ add_header Cache-Control "public, max-age=7200";
+ # Optional: Don't log access to other assets
+ access_log off;
+ }
}
diff --git a/.conf/dps_51/run b/.conf/dps_51/run
index d6bdb39b87..9f439918ae 100644
--- a/.conf/dps_51/run
+++ b/.conf/dps_51/run
@@ -10,13 +10,17 @@
# - Starts X if not already running
#
# Usage:
-# /DietPi/dietpi/conf/opentyrian_run
+# run
#////////////////////////////////////
#Xserver already running
if (($(pidof X) >= 0)); then
+
/usr/local/games/opentyrian/opentyrian -t /usr/local/games/opentyrian/data
+
#No X (init X server)
else
+
xinit /usr/local/games/opentyrian/opentyrian -t /usr/local/games/opentyrian/data
-fi
\ No newline at end of file
+
+fi
diff --git a/.conf/dps_65/netdata.service b/.conf/dps_65/netdata.service
index e1a6e5d2a4..4b308413d9 100644
--- a/.conf/dps_65/netdata.service
+++ b/.conf/dps_65/netdata.service
@@ -1,15 +1,69 @@
+# Based on: https://raw.githubusercontent.com/netdata/netdata/master/system/netdata.service.in + Debian sid repo hardening
+# SPDX-License-Identifier: GPL-3.0-or-later
[Unit]
Description=Real time performance monitoring
-After=network.target httpd.service squid.service nfs-server.service mysqld.service named.service postfix.service
+
+# append here other services you want netdata to wait for them to start
+After=network-online.target httpd.service squid.service nfs-server.service mysqld.service mysql.service named.service postfix.service chronyd.service
[Service]
Type=simple
-User=root
-Group=root
-ExecStart=/usr/sbin/netdata -D
+User=netdata
+Group=netdata
+RuntimeDirectory=netdata
+RuntimeDirectoryMode=0775
+PIDFile=/var/run/netdata/netdata.pid
+ExecStart=/usr/sbin/netdata -P /var/run/netdata/netdata.pid -D -W set global 'process scheduling policy' 'keep' -W set global 'OOM score' 'keep'
+ExecStartPre=/bin/mkdir -p /var/cache/netdata
+ExecStartPre=/bin/chown -R netdata:netdata /var/cache/netdata
+ExecStartPre=/bin/mkdir -p /var/run/netdata
+ExecStartPre=/bin/chown -R netdata:netdata /var/run/netdata
+#ExecStopPost=/bin/rm /var/run/netdata/netdata.pid
+PermissionsStartOnly=true
# saving a big db on slow disks may need some time
TimeoutStopSec=60
+# restart netdata if it crashes
+Restart=on-failure
+RestartSec=30
+
+# The minimum netdata Out-Of-Memory (OOM) score.
+# netdata (via [global].OOM score in netdata.conf) can only increase the value set here.
+# To decrease it, set the minimum here and set the same or a higher value in netdata.conf.
+# Valid values: -1000 (never kill netdata) to 1000 (always kill netdata).
+OOMScoreAdjust=1000
+
+# Valid policies: other (the system default) | batch | idle | fifo | rr
+# To give netdata the max priority, set CPUSchedulingPolicy=rr and CPUSchedulingPriority=99
+CPUSchedulingPolicy=idle
+
+# This sets the scheduling priority (for policies: rr and fifo).
+# Priority gets values 1 (lowest) to 99 (highest).
+#CPUSchedulingPriority=1
+
+# For scheduling policy 'other' and 'batch', this sets the lowest niceness of netdata (-20 highest to 19 lowest).
+#Nice=0
+
+WorkingDirectory=/tmp
+
+# Hardening
+NoNewPrivileges=false
+# CAP_SETGID is required for setgroups()
+# CAP_NET_RAW is needed by fping, see #864370
+CapabilityBoundingSet=CAP_DAC_READ_SEARCH CAP_SYS_PTRACE CAP_SETGID CAP_SETUID CAP_NET_RAW
+PrivateTmp=true
+ProtectHome=read-only
+ProtectSystem=full
+
+ReadOnlyDirectories=/
+ReadWriteDirectories=/proc/self
+ReadWriteDirectories=/var
+
+# Access to devices and kernel modules and tunables is required
+PrivateDevices=no
+ProtectKernelModules=no
+ProtectKernelTunables=no
+
[Install]
WantedBy=multi-user.target
diff --git a/.conf/dps_85/nginx.conf b/.conf/dps_85/nginx.conf
index 15f201f196..bed9d28302 100644
--- a/.conf/dps_85/nginx.conf
+++ b/.conf/dps_85/nginx.conf
@@ -6,6 +6,11 @@ user www-data;
# As a thumb rule: One per CPU.
worker_processes 1;
+pid /run/nginx.pid;
+
+# Load dynamic modules
+include /etc/nginx/modules-enabled/*.conf;
+
# Maximum file descriptors that can be opened per process
# This should be > worker_connections
worker_rlimit_nofile 100;
@@ -16,8 +21,6 @@ events {
error_log /var/log/nginx/error.log;
-pid /run/nginx.pid;
-
http {
charset utf-8;
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
index 19fe45e167..ddec9ccc0b 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -4,36 +4,35 @@ about: Create a report to help us improve
---
-## Creating a bug report/issue:
-
-
-#### Required Information:
-- DietPi version | `cat /DietPi/dietpi/.version`
-- Distro version | `echo $G_DISTRO_NAME` or `cat /etc/debian_version`
-- Kernel version | `uname -a`
-- SBC device | `echo $G_HW_MODEL_DESCRIPTION` or (EG: RPi3)
-- Power supply used | (EG: 5V 1A RAVpower)
-- SDcard used | (EG: SanDisk ultra)
-
-#### Additional Information (if applicable):
-- Software title | (EG: Nextcloud)
+### Creating a bug report/issue
+
+#### Required Information
+- DietPi version | `cat /DietPi/dietpi/.version`
+- Distro version | `echo $G_DISTRO_NAME` or `cat /etc/debian_version`
+- Kernel version | `uname -a`
+- SBC device | `echo $G_HW_MODEL_DESCRIPTION` or (EG: RPi3)
+- Power supply used | (EG: 5V 1A RAVpower)
+- SDcard used | (EG: SanDisk ultra)
+
+#### Additional Information (if applicable)
+- Software title | (EG: Nextcloud)
- Was the software title installed freshly or updated/migrated?
- Can this issue be replicated on a fresh installation of DietPi?
-- `dietpi-bugreport` ID
+- `dietpi-bugreport` ID | `sed -n 5p /DietPi/dietpi/.hw_model`
-#### Steps to reproduce:
+#### Steps to reproduce
1. ...
2. ...
-#### Expected behaviour:
+#### Expected behaviour
- ...
-#### Actual behaviour:
+#### Actual behaviour
- ...
-#### Extra details:
+#### Extra details
- ...
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
index 9735635a09..16cf4dfb61 100644
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -4,8 +4,7 @@ about: Suggest an idea for this project
---
-## Creating a feature request:
-
+### Creating a feature request
#### Is your feature request related to a problem? Please describe:
@@ -19,6 +18,6 @@ about: Suggest an idea for this project
- ...
-#### Additional context:
+#### Additional context
- ...
diff --git a/.github/ISSUE_TEMPLATE/image_request.md b/.github/ISSUE_TEMPLATE/image_request.md
index 7aa140ddd4..3f3093f71c 100644
--- a/.github/ISSUE_TEMPLATE/image_request.md
+++ b/.github/ISSUE_TEMPLATE/image_request.md
@@ -4,10 +4,9 @@ about: Suggest a new SBC to be added to the offial support and image list of Die
---
-## Creating an image request:
+### Creating an image request
-
-#### Give us some formal device information:
+#### Formal device information
- Device name |
- Official product URL |
- GitHub resource URL (if available) |
diff --git a/.github/ISSUE_TEMPLATE/software_request.md b/.github/ISSUE_TEMPLATE/software_request.md
index fc4c8cc85e..1409551f4e 100644
--- a/.github/ISSUE_TEMPLATE/software_request.md
+++ b/.github/ISSUE_TEMPLATE/software_request.md
@@ -4,14 +4,13 @@ about: Suggest a software title to be added to DietPi-Software
---
-## Creating a software request:
+### Creating a software request
-
-#### Give us some formal software information:
+#### Formal software information
- Software title |
- Short description |
+- Official URL (if available) |
- GitHub URL (if available) |
-- External URL (if available) |
- (Official) install documentation |
#### Are there similar/alternative software titles available with DietPi-Software?
diff --git a/.meta/dietpi-cloud-migration b/.meta/dietpi-cloud-migration
index 8cb189c0dc..07142326b4 100644
--- a/.meta/dietpi-cloud-migration
+++ b/.meta/dietpi-cloud-migration
@@ -18,11 +18,11 @@ run_backup(){
echo "[ INFO ] Scanning $fp_config for necessary information..."
[[ ! -f $fp_config ]] && echo -e "[\e[31mFAILED\e[0m] File $fp_config not found, please check your installation.\n" && exit 1
- local fp_datadir=$(grep -m1 "^[[:blank:]]*'datadirectory'" $fp_config | awk '{print $3}' | sed "s/[',]//g")
- local dbname=$(grep -m1 "^[[:blank:]]*'dbname'" $fp_config | awk '{print $3}' | sed "s/[',]//g")
- local dbhost=$(grep -m1 "^[[:blank:]]*'dbhost'" $fp_config | awk '{print $3}' | sed "s/[',]//g")
- local dbuser=$(grep -m1 "^[[:blank:]]*'dbuser'" $fp_config | awk '{print $3}' | sed "s/[',]//g")
- local dbpass=$(grep -m1 "^[[:blank:]]*'dbpassword'" $fp_config | awk '{print $3}' | sed "s/[',]//g")
+ local fp_datadir=$(grep -m1 "^[[:blank:]]*'datadirectory'" $fp_config | mawk '{print $3}' | sed "s/[',]//g")
+ local dbname=$(grep -m1 "^[[:blank:]]*'dbname'" $fp_config | mawk '{print $3}' | sed "s/[',]//g")
+ local dbhost=$(grep -m1 "^[[:blank:]]*'dbhost'" $fp_config | mawk '{print $3}' | sed "s/[',]//g")
+ local dbuser=$(grep -m1 "^[[:blank:]]*'dbuser'" $fp_config | mawk '{print $3}' | sed "s/[',]//g")
+ local dbpass=$(grep -m1 "^[[:blank:]]*'dbpassword'" $fp_config | mawk '{print $3}' | sed "s/[',]//g")
echo -e " - data directory: $fp_datadir
- database name: $dbname
- database hostname: $dbhost
diff --git a/.meta/dietpi-survey_report b/.meta/dietpi-survey_report
index cb4f9767eb..39a3235e2c 100644
--- a/.meta/dietpi-survey_report
+++ b/.meta/dietpi-survey_report
@@ -345,8 +345,8 @@
for i in ${!aSOFTWARE_NAME[@]}
do
- aSOFTWARE_NAME6_9[$i]="${aSOFTWARE_NAME[$i]}"
- aSOFTWARE_NAME6_10[$i]="${aSOFTWARE_NAME[$i]}"
+ aSOFTWARE_NAME6_9[$i]=${aSOFTWARE_NAME[$i]}
+ aSOFTWARE_NAME6_10[$i]=${aSOFTWARE_NAME[$i]}
done
#aSOFTWARE_NAME6_10[2]='2' # CurlTMPFS Removed but not marked as removed => v6.12
@@ -360,7 +360,7 @@
for i in ${!aSOFTWARE_NAME6_10[@]}
do
- aSOFTWARE_NAME6_11[$i]="${aSOFTWARE_NAME6_10[$i]}"
+ aSOFTWARE_NAME6_11[$i]=${aSOFTWARE_NAME6_10[$i]}
done
@@ -369,7 +369,7 @@
for i in ${!aSOFTWARE_NAME6_11[@]}
do
- aSOFTWARE_NAME6_12[$i]="${aSOFTWARE_NAME6_11[$i]}"
+ aSOFTWARE_NAME6_12[$i]=${aSOFTWARE_NAME6_11[$i]}
done
aSOFTWARE_NAME6_12[2]='2' # CurlTMPFS
@@ -380,7 +380,7 @@
for i in ${!aSOFTWARE_NAME6_12[@]}
do
- aSOFTWARE_NAME6_13[$i]="${aSOFTWARE_NAME6_12[$i]}"
+ aSOFTWARE_NAME6_13[$i]=${aSOFTWARE_NAME6_12[$i]}
done
aSOFTWARE_NAME6_13[2]='Folding@Home'
@@ -391,7 +391,7 @@
for i in ${!aSOFTWARE_NAME6_13[@]}
do
- aSOFTWARE_NAME6_14[$i]="${aSOFTWARE_NAME6_13[$i]}"
+ aSOFTWARE_NAME6_14[$i]=${aSOFTWARE_NAME6_13[$i]}
done
aSOFTWARE_NAME6_14[38]='FreshRSS'
@@ -401,10 +401,10 @@
for i in ${!aSOFTWARE_NAME6_14[@]}
do
- aSOFTWARE_NAME6_15[$i]="${aSOFTWARE_NAME6_14[$i]}"
+ aSOFTWARE_NAME6_15[$i]=${aSOFTWARE_NAME6_14[$i]}
done
- aSOFTWARE_NAME6_12[148]='myMPD'
+ aSOFTWARE_NAME6_15[148]='myMPD'
# - v6.16 + v6.17 + v6.18
aSOFTWARE_NAME6_16=()
@@ -413,13 +413,28 @@
for i in ${!aSOFTWARE_NAME6_15[@]}
do
- aSOFTWARE_NAME6_16[$i]="${aSOFTWARE_NAME6_15[$i]}"
- aSOFTWARE_NAME6_17[$i]="${aSOFTWARE_NAME6_16[$i]}"
- aSOFTWARE_NAME6_18[$i]="${aSOFTWARE_NAME6_17[$i]}"
+ aSOFTWARE_NAME6_16[$i]=${aSOFTWARE_NAME6_15[$i]}
+ aSOFTWARE_NAME6_17[$i]=${aSOFTWARE_NAME6_16[$i]}
+ aSOFTWARE_NAME6_18[$i]=${aSOFTWARE_NAME6_17[$i]}
done
aSOFTWARE_NAME6_18[168]='Nextcloud Talk'
+ # - v6.19 + v6.20
+ aSOFTWARE_NAME6_19=()
+ aSOFTWARE_NAME6_20=()
+ for i in ${!aSOFTWARE_NAME6_18[@]}
+ do
+
+ aSOFTWARE_NAME6_19[$i]=${aSOFTWARE_NAME6_18[$i]}
+ aSOFTWARE_NAME6_20[$i]=${aSOFTWARE_NAME6_19[$i]}
+
+ done
+ aSOFTWARE_NAME6_20[116]='Medusa'
+ aSOFTWARE_NAME6_20[170]='Unrar'
+ aSOFTWARE_NAME6_20[171]='DietPi-NordVPN'
+ aSOFTWARE_NAME6_20[172]='WireGuard'
+
Main(){
# Copy files to RAM to speed up grep
@@ -449,9 +464,12 @@
# - Add bench to array
if [[ $BENCH_VERSION ]]; then
- #DEBUG
- echo -e "DEBUG Benchmark: $file"
- echo -e "BENCH_VERSION=$BENCH_VERSION | BENCH_HW_MODEL=$BENCH_HW_MODEL BENCH_CPU=$BENCH_CPU | BENCH_ROOTFS_WRITE=$BENCH_ROOTFS_WRITE | BENCH_ROOTFS_READ=$BENCH_ROOTFS_READ | BENCH_RAM_WRITE=$BENCH_RAM_WRITE | BENCH_RAM_READ=$BENCH_RAM_READ | BENCH_CPU_TEMP_START=$BENCH_CPU_TEMP_START | BENCH_CPU_TEMP_END=$BENCH_CPU_TEMP_END | BENCH_CUSTOMFS_WRITE=$BENCH_CUSTOMFS_WRITE | BENCH_CUSTOMFS_READ=$BENCH_CUSTOMFS_READ | BENCH_NET_LAN_SPEED=$BENCH_NET_LAN_SPEED"
+ if [[ $G_DEBUG == 1 ]]; then
+
+ echo "DEBUG Benchmark: $file"
+ echo "BENCH_VERSION=$BENCH_VERSION | BENCH_HW_MODEL=$BENCH_HW_MODEL BENCH_CPU=$BENCH_CPU | BENCH_ROOTFS_WRITE=$BENCH_ROOTFS_WRITE | BENCH_ROOTFS_READ=$BENCH_ROOTFS_READ | BENCH_RAM_WRITE=$BENCH_RAM_WRITE | BENCH_RAM_READ=$BENCH_RAM_READ | BENCH_CPU_TEMP_START=$BENCH_CPU_TEMP_START | BENCH_CPU_TEMP_END=$BENCH_CPU_TEMP_END | BENCH_CUSTOMFS_WRITE=$BENCH_CUSTOMFS_WRITE | BENCH_CUSTOMFS_READ=$BENCH_CUSTOMFS_READ | BENCH_NET_LAN_SPEED=$BENCH_NET_LAN_SPEED"
+
+ fi
#Common benchmarks
# - Check for all expected values based on how we handle them, only add entry if valid for all.
@@ -741,15 +759,17 @@
fi
- # - DEBUG
- echo "DEBUG Bench Entry: $i $j"
- echo ${aBENCH_ROOTFS_WRITE[$i,$j]}
- echo ${aBENCH_ROOTFS_READ[$i,$j]}
- echo ${aBENCH_RAM_WRITE[$i,$j]}
- echo ${aBENCH_RAM_READ[$i,$j]}
- echo ${aBENCH_CPU_TEMP_START[$i,$j]}
- echo ${aBENCH_CPU_TEMP_END[$i,$j]}
- # - DEBUG
+ if [[ $G_DEBUG == 1 ]]; then
+
+ echo "DEBUG Bench Entry: $i $j"
+ echo ${aBENCH_ROOTFS_WRITE[$i,$j]}
+ echo ${aBENCH_ROOTFS_READ[$i,$j]}
+ echo ${aBENCH_RAM_WRITE[$i,$j]}
+ echo ${aBENCH_RAM_READ[$i,$j]}
+ echo ${aBENCH_CPU_TEMP_START[$i,$j]}
+ echo ${aBENCH_CPU_TEMP_END[$i,$j]}
+
+ fi
#Last item in current array. Work out averages
if (( $j == ${aBENCH_COMMON_INDEX[$i]} - 1 )); then
@@ -767,16 +787,18 @@
fi
- #DEBUG
- # echo "DEBUG Bench avg: $i"
- # echo "aBENCH_RESULT_CPU_AVG $i = ${aBENCH_RESULT_CPU_AVG[$i]}"
- # echo "aBENCH_RESULT_ROOTFS_WRITE_AVG $i = ${aBENCH_RESULT_ROOTFS_WRITE_AVG[$i]}"
- # echo "aBENCH_RESULT_ROOTFS_READ_AVG $i = ${aBENCH_RESULT_ROOTFS_READ_AVG[$i]}"
- # echo "aBENCH_RESULT_RAM_WRITE_AVG $i = ${aBENCH_RESULT_RAM_WRITE_AVG[$i]}"
- # echo "aBENCH_RESULT_RAM_READ_AVG $i = ${aBENCH_RESULT_RAM_READ_AVG[$i]}"
- # echo "aBENCH_RESULT_CPU_TEMP_START_AVG $i = ${aBENCH_RESULT_CPU_TEMP_START_AVG[$i]}"
- # echo "aBENCH_RESULT_CPU_TEMP_END_AVG $i = ${aBENCH_RESULT_CPU_TEMP_END_AVG[$i]}"
- #DEBUG
+ if [[ $G_DEBUG == 1 ]]; then
+
+ echo "DEBUG Bench avg: $i"
+ echo "aBENCH_RESULT_CPU_AVG $i = ${aBENCH_RESULT_CPU_AVG[$i]}"
+ echo "aBENCH_RESULT_ROOTFS_WRITE_AVG $i = ${aBENCH_RESULT_ROOTFS_WRITE_AVG[$i]}"
+ echo "aBENCH_RESULT_ROOTFS_READ_AVG $i = ${aBENCH_RESULT_ROOTFS_READ_AVG[$i]}"
+ echo "aBENCH_RESULT_RAM_WRITE_AVG $i = ${aBENCH_RESULT_RAM_WRITE_AVG[$i]}"
+ echo "aBENCH_RESULT_RAM_READ_AVG $i = ${aBENCH_RESULT_RAM_READ_AVG[$i]}"
+ echo "aBENCH_RESULT_CPU_TEMP_START_AVG $i = ${aBENCH_RESULT_CPU_TEMP_START_AVG[$i]}"
+ echo "aBENCH_RESULT_CPU_TEMP_END_AVG $i = ${aBENCH_RESULT_CPU_TEMP_END_AVG[$i]}"
+
+ fi
fi
diff --git a/BRANCH_SYSTEM.md b/BRANCH_SYSTEM.md
index 13838f5c01..5f62c94cf3 100644
--- a/BRANCH_SYSTEM.md
+++ b/BRANCH_SYSTEM.md
@@ -1,4 +1,4 @@
-## Steps to use the DietPi "beta" branch.
+## Steps to use the DietPi "beta" branch
#### This is the pre-release branch for public testing and may potentially be unstable.
The goal of the Beta branch, is to allow for public testing of our next release. Once testing has passed, and, all issues have been resolved, the Beta branch will then be set live on our stable branch (master).
We will apply updates to the Beta branch during pre-release phases, you will then see an update notification. By running ```dietpi-update```, your Beta version will then update to the latest.
@@ -21,7 +21,6 @@ G_CONFIG_INJECT 'DEV_GITBRANCH=' 'DEV_GITBRANCH=beta' /DietPi/dietpi.txt
4. Test away, please report any issues on our GitHub page. Also ensure you mention "Beta branch" in your post: https://github.com/Fourdee/DietPi/issues
5. If you want to return the system to the previous restore state, run ```dietpi-backup``` to restore (or restore quickly with ```dietpi-backup -1```)
-## Steps to use the DietPi "dev" branch.
+## Steps to use the DietPi "dev" branch
#### This is the active development branch. Its potentially unstable, unsupported and should not be used by end users.
-
1. Same as above, however, use ```DEV_GITBRANCH=dev``` instead
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 357b835f02..10aa38c883 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,3 +1,85 @@
+
+v6.20
+(xx/12/18)
+
+Image line-up:
+- We removed Jessie images from our download server (besides for Odroid C1), since we see no advantage to use them anymore. Existing Jessie systems are still supported, but we encourage all users to consider switching to a fresh Stretch image by times: https://github.com/Fourdee/DietPi/issues/2332
+
+Changes / Improvements / Optimisations:
+- DietPi-PREP | Removed the option to install a Jessie system. Removed the option to install DietPi on top of a Wheezy image, since an upgrade over two distro version would be required, which is not reliable. It is still possible to install DietPi on top of a Jessie image, where a distro upgrade to Stretch would be applied: https://github.com/Fourdee/DietPi/issues/2332
+- General | RPi-Update: In our effort to improve system stability, and, offer software installations which build custom modules (eg: WireGuard), we can not longer support systems with non-stock APT kernel installed. If "rpi-update" is installed during update, DietPi will prompt and return you back to stock APT kernel.
+- General | Moved the remaining conf/* files located on DietPi-RAMdisk to /var/lib/dietpi or into DietPi-PREP, and removed /DietPi/dietpi/conf completely. These files were only used once or never, thus have no business inside the RAMdisk.
+- DietPi-Config | RPi: Improved available options for HDMI boost setting: https://github.com/Fourdee/DietPi/issues/2350
+- DietPi-Config | RPi: Headless display mode is now applied via undocumented config.txt setting. Removed/Replaced some other obsolete config.txt entries: https://github.com/Fourdee/DietPi/pull/2402
+- DietPi-Config | RPi: Added info to "hifiberry-dacplus" sound device overlay that it supports the AMP2 DAC. Thanks to @Lat Dior for reporting the issue and testing the solution: https://dietpi.com/phpbb/viewtopic.php?t=5396
+- DietPi-Config | WiFi Hotspot: You can now toggle support for 802.11 N. Please note this is device and compatibility dependent, mileage may vary.
+- DietPi-Drive_Manager | Now allows to check & repair the boot file system and trigger it for root file system on next reboot: https://github.com/Fourdee/DietPi/issues/1740#issuecomment-388325204
+- DietPi-Software | AmiBerry: Updated to v2.24, thanks @midwan! Brings several bug fixes, new features and improvements over the previous version (2.19). Please check the version history for full details on the changes made: https://github.com/midwan/amiberry/wiki/Version-history
+- DietPi-Software | DietPi-NordVPN: Now available for installation. Includes a GUI which allows for easy connection to a list of NordVPN servers 'dietpi-nordvpn'. If you need a NordVPN subscription, please use this link: https://go.nordvpn.net/aff_c?offer_id=15&aff_id=5305&url_id=902
+- DietPi-Software | WireGuard VPN is now available for installation. Is can be easily configured as client or as server, passing either all client traffic through the tunnel, local network access only, or server access only, e.g. as well in combination with Pi-hole, to have remote ad blocking.
+- DietPi-Software | SickRage has been replaced by Medusa, which is now available for install: https://github.com/Fourdee/DietPi/issues/2239
+- DietPi-Software | Blynk: Reinstalls now preserve existing config files; New directory structure and blynk user (v6.19) is patched now as well to existing installs: https://github.com/Fourdee/DietPi/pull/2324
+- DietPi-Software | Plex Media Server: Updated to v1.14.0 on x86 images, switch to HTTPS ARM repo and automated locale switch to en_US.UTF-8: https://github.com/Fourdee/DietPi/issues/2294
+- DietPi-Software | Nextcloud Talk: Disabled the very verbose coturn logging by default to reduce disk I/O. This can be overridden via /etc/turnserver.conf: https://github.com/Fourdee/DietPi/issues/2321
+- DietPi-Software | Deluge: UMask 002 applied to all downloads: https://github.com/Fourdee/DietPi/issues/2339
+- DietPi-Software | Netdata: Updated to v1.11.1 and now runs as user "netdata": https://github.com/Fourdee/DietPi/pull/2337
+- DietPi-Software | ownCloud/Nextcloud: Updated webserver configs to match current recommendations and security hardenings. Only applied on new installs. To apply manually, run "dietpi-software reinstall 47" (owncloud) or "dietpi-software reinstall 114" (Nextcloud). You will be informed about the new configs, which then need to be manually moved to overwrite the old ones, since we don't want to mess with manual changes: https://github.com/Fourdee/DietPi/pull/2361
+- DietPi-Software | OpenSSH: Host keys won't be recreated anymore on reinstall, only on first boot of a fresh image, using now "dpkg-reconfigure openssh-server" to generate default key types based on distro.
+- DietPi-Software | Dropbear: Now installs only the "dropbear-run" package on Stretch (and above), which matches the default DietPi setup on our images and PREP script.
+- DietPi-Software | NAA Daemon: Updated to 3.5.5-39. Thanks to @volpone for the heads up: https://github.com/Fourdee/DietPi/issues/2387#issue-395321320
+- DietPi-Software | MPD: Updated to 0.20.23-1. Includes support for NFS and Samba: https://github.com/Fourdee/DietPi/issues/2377
+- DietPi-Software | MPD: Now runs as "mpd" user again, updated systemd unit to match official one and better handle existing cache and log files on reinstall: https://github.com/Fourdee/DietPi/issues/2378
+- DietPi-Software | Samba: Moved disk cache to RAM to reduce disk I/O. Thanks to @WolfganP for suggesting this enhancement: https://github.com/Fourdee/DietPi/issues/2396
+- DietPi-Software | Kodi RPi: Default GPU memory split is now 320MB for 1GB devices. This should improve overall performance and stability: https://github.com/Fourdee/DietPi/issues/2365
+- DietPi-Software | Airsonic: Now installs the latest upstream version automatically: https://github.com/Fourdee/DietPi/pull/2410
+- DietPi-Software | You will now receive a whiptail prompt, if config files are overwritten during software installations: https://github.com/Fourdee/DietPi/issues/2325
+- DietPi-Software | NoMachine: Enabled ARMv8 support and will now install current version 6.4.6: https://github.com/Fourdee/DietPi/pull/2408
+- DietPi-Software | Shairport Sync: Updated to 3.2.2 (previously 3.1.7): https://github.com/Fourdee/DietPi/issues/2439
+- DietPi-Software | Gitea: New installations now install 1.7 (previously 1.4). Many thanks to @yumiris for this update! https://github.com/Fourdee/DietPi/pull/2448
+- DietPi-Software | Grafana: Now the new official APT repo is used for all architectures (excluding ARMv6), which allows updates to the current upstream version (currently v5.4.3) as well. This change will be applied to existing installs on dietpi-update to v6.20. Thanks to @jvteleco for informing us: https://github.com/Fourdee/DietPi/issues/2449
+- DietPi-Update | Added optional ability to automatically update DietPi, when updates are available. Please note, this is disabled by default.
+- DietPi-Sync | Removed the compression option, which has no effect on local sync, since files are not stored compressed, but only transferred compressed through remote sync protocols, which are currently not offered by DietPi-Sync.
+- DietPi-RAMlog/Logclear | The internally rotated LetsEncrypt (CertBot) log files are now removed, hourly with DietPi-RAMlog enabled, or when executing DietPi-Logclear manually.
+
+Bug Fixes:
+- DietPi-Software | LXDE: Installation will no longer enable the weather application. This is due to Yahoo API hard coded into LXpanel, being taken offline: https://github.com/Fourdee/DietPi/issues/2416#issuecomment-456805925
+- DietPi-Software | Nextcloud: Resolved an issue, where the Nextcloud Apache config was not downloaded correctly. Thanks to @Stefan3v for reporting this issue: https://github.com/Fourdee/DietPi/issues/2383
+- DietPi-Software | ownCloud/Nextcloud (Talk): Resolved an issue, where occ/ncc commands could fail, if Redis server is not running: https://github.com/Fourdee/DietPi/issues/2321
+- DietPi-Software | ownCloud/Nextcloud: Resolved an issue, where during fresh installs on v6.19, Apache configs were not enabled correctly.
+- DietPi-Software | MPD: Resolved an issue on Stretch, where the mpd binary could not find the configuration file without giving it explicitely as argument. Thanks to @mfeif for reporting this issue: https://github.com/Fourdee/DietPi/issues/2378
+- DietPi-Software | Mopidy: Resolved an issue, where playlist files could not be created due to missing permissions. Further improved handling of existing configs, data and cache directories on (re)install. Thanks to @cyberlussi for reporting this issue: https://github.com/Fourdee/DietPi/issues/2384
+- DietPi-Software | Deluge: Resolved a visual-only error in systemd unit, since same-line comments are not allowed anymore. Thanks to @Gabba for reporting this issue: https://dietpi.com/phpbb/viewtopic.php?t=5378
+- DietPi-Software | No-IP: Fixed an issue, where on "Generic device" (ID 22), the wrong binary could have been installed. As well added failsafe "/usr/local/[bin|etc]" directory pre-creation, in case not present on the system or manually removed by user. Thanks to @walker93 for reporting this issue: https://github.com/Fourdee/DietPi/issues/2426
+- DietPi-Software | PHP: Resolved an issue where install fails on Stretch due to package name changes in the Debian repo. Thanks to @rox-wolf for reporting this issue: https://github.com/Fourdee/DietPi/issues/2438
+- DietPi-Sync | Resolved an issue, where dry-run and compression options were not applied correctly. Thanks to @WilburWalsh for reporting the issue and identifying the faulty code: https://dietpi.com/phpbb/viewtopic.php?f=11&t=5347
+- DietPi-Sync | Resolved an issue, where daily sync was not applied due to changed settings file scheme.
+- DietPi-Config | RPi: gpu_mem_256/512 are now capped when being applied (to prevent value exceeding limits of each board type): https://github.com/Fourdee/DietPi/issues/2417
+- DietPi-Config | Resolved a visual-only issue, where WiFi interface starts throw an error message about unsupported power management: https://github.com/Fourdee/DietPi/issues/2198
+- DietPi-WiFi-Monitor | Resolved an issue, where DietPi-WiFi-Monitor stuck in a reconnection loop, if no valid WiFi interface was detected or the WiFi adapter is unplugged.
+- DietPi-Cloudshell | Resolved an issue where CPU scene failed on VM and other devices that do not support CPU governors: https://github.com/Fourdee/DietPi/issues/2428
+- DietPi-LetsEncrypt | Resolved an issue where Nginx and Apache modules are missing, if one installs CertBot first and the webserver afterwards on a separate dietpi-software run: https://github.com/Fourdee/DietPi/issues/2295
+- General | Pinebook: Resolved issue with failed apt-get upgrades due to missing armbian-release data file. Also switched to stable kernel packages and kernel updates over APT are now enabled.
+- General | Enhanced and fixed some issue with dependencies and boot order of DietPi systemd units: https://github.com/Fourdee/DietPi/pull/2357
+- General | AudioPhonics I-Sabre-K2M: Once the driver is compiled, it will no longer be recompiled. This prevents ALSA installs from re-compiling the driver each time.
+- General | Resolved an issue, where login with non-bash session caused an error message. Thanks to @Elijahg for reporting this issue: https://github.com/Fourdee/DietPi/issues/2347
+- General | Resolved an issue where G_CHECK_URL would not terminate applications on failure. Also added option to retry + change networking options.
+
+As always, many smaller code performance and stability improvements, visual and spelling fixes have been done, too much to list all of them here. Check out all code changes of this release on GitHub: https://github.com/Fourdee/DietPi/pulls?utf8=%E2%9C%93&q=is%3Apr+is%3Aclosed+base%3Amaster
+
+Known/Outstanding Issues:
+- DietPi-Config | Enabling WiFi + Ethernet adapters, both on different subnets, breaks WiFi connection in some cases: https://github.com/Fourdee/DietPi/issues/2103
+- DietPi-Config | RPi | OpenGL/VC4 causes sound card selection to be invalid: https://github.com/Fourdee/DietPi/issues/2173
+- RPi | LXAppearance (on LXDE desktop) hangs on dbus-launch: https://github.com/Fourdee/DietPi/issues/1791
+- Pine A64 | No sound over 3.5mm jack: https://github.com/Fourdee/DietPi/issues/2153
+- Odroid C2 | Some WiFi adapters do no work as hotspot: https://github.com/Fourdee/DietPi/issues/1955
+- DietPi-Software | Node-RED: Pre-installed modules cannot be updated via webUI: https://github.com/Fourdee/DietPi/issues/2073
+- DietPi-Software | Raspimjpeg: With Lighttpd, streaming mjpeg does not work: https://github.com/Fourdee/DietPi/issues/1747
+- DietPi-Drive_Manager | encryptfs is currently not supported and will be removed from fstab, when executing drive manager: https://github.com/Fourdee/DietPi/issues/2078
+
+For all additional issues that may appear after release, please see the following link and select the 'Next Version Milestone' to see active tickets: https://github.com/Fourdee/DietPi/milestones
+
+-----------------------------------------------------------------------------------------------------------
+
v6.19.7
(10/12/18 Hotfix)
@@ -16,7 +98,7 @@ v6.19
(04/12/18)
Changes / Improvements / Optimisations:
-- General | ASUS TB: Image updated to mainline kernel, with midgard r13 GPU driver. Now supports hardware accelleration and support for Kodi. Please download the image to enable these features.
+- General | ASUS TB: Image updated to mainline kernel, with midgard r13 GPU driver. Now supports hardware acceleration and support for Kodi. Please download the image to enable these features.
- General | RPi 3A+: Added hardware code enabling correct naming of device throughout DietPi: https://github.com/Fourdee/DietPi/issues/2301
- DietPi-Software | Renamed several software config files to have a consistent naming scheme: https://github.com/Fourdee/DietPi/pull/2312
- DietPi-Software | LXDE: Applied updated DietPi theme and wallpaper. For new installations only.
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 753798e4ed..13ce8416f7 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,21 +1,21 @@
-### DietPi Project Contribution.
+### DietPi Project Contribution
-Git coders, please use the active development branch: [`dev`](https://github.com/Fourdee/DietPi/tree/dev)
+Git coders, please use the active development branch: [dev](https://github.com/Fourdee/DietPi/tree/dev)
-* [How to add new software installation options to DietPi-Software](https://github.com/Fourdee/DietPi/issues/490#issuecomment-244416570)
+- [How to add new software installation options to DietPi-Software](https://github.com/Fourdee/DietPi/issues/490#issuecomment-244416570)
Are you able to:
-* Provide feedback and/or test areas of DietPi, to improve the user experience?
-* Report bugs?
-* Improve/add more features to the [DietPi website](https://dietpi.com)?
-* Compile software for Odroid C1 and RPi systems?
-* Contribute to DietPi with programming on GitHub?
-* Suggest new software that we can add to the `dietpi-software` install system?
+- Provide feedback and/or test areas of DietPi, to improve the user experience?
+- Report bugs?
+- Improve/add more features to the [DietPi website](https://dietpi.com)?
+- Compile software for our supported SBCs?
+- Contribute to DietPi with programming on GitHub?
+- Suggest new software that we can add to the `dietpi-software` install system?
If so, let us know!
We are always looking for talented people who believe in the DietPi project, and, wish to contribute in any way you can.
-* Send me an Email: daniel.knight@dietpi.com
-* Join our forums: https://dietpi.com/phpbb
-* GitHub: https://github.com/Fourdee/DietPi
+- Send me an Email: daniel.knight@dietpi.com
+- Join our forums: https://dietpi.com/phpbb
+- GitHub: https://github.com/Fourdee/DietPi
diff --git a/PREP_SYSTEM_FOR_DIETPI.sh b/PREP_SYSTEM_FOR_DIETPI.sh
index afb12e4d95..467d4baecc 100644
--- a/PREP_SYSTEM_FOR_DIETPI.sh
+++ b/PREP_SYSTEM_FOR_DIETPI.sh
@@ -19,7 +19,6 @@
#Core globals
G_PROGRAM_NAME='DietPi-PREP'
GITOWNER=${GITOWNER:-Fourdee}
- GITBRANCH=${GITBRANCH:-master}
#------------------------------------------------------------------------------------------------
# Critical checks and pre-reqs, with exit, prior to initial run of script
@@ -27,42 +26,63 @@
#Exit path for non-root logins
if (( $UID )); then
- echo -e 'Error: Root privileges required, please run the script with "sudo"\nIn case install the "sudo" package with root privileges:\n\t# apt-get install -y sudo\n'
+ echo -e 'ERROR: Root privileges required, please run the script with "sudo"\nIn case install the "sudo" package with root privileges:\n\t# apt-get install -y sudo\n'
exit 1
fi
#Work inside /tmp as usually ramfs to reduce disk I/O and speed up download and unpacking
+ # - Save full script path, beforehand: https://github.com/Fourdee/DietPi/pull/2341#discussion_r241784962
+ FP_PREP_SCRIPT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/$(basename "${BASH_SOURCE[0]}")"
cd /tmp
+ #Prefer IPv4 by default, to avoid hanging access attempts in some cases
+ # - NB: This needs to match the method in: /DietPi/dietpi/func/dietpi-set_hardware preferipv4 enable
+ # - APT
+ echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99-dietpi-force-ipv4
+ # - Wget
+ if grep -q '^[[:blank:]]*prefer-family[[:blank:]]*=' /etc/wgetrc; then
+
+ sed -i '/^[[:blank:]]*prefer-family[[:blank:]]*=/c\prefer-family = IPv4' /etc/wgetrc
+
+ elif grep -q '^[[:blank:]#;]*prefer-family[[:blank:]]*=' /etc/wgetrc; then
+
+ sed -i '/^[[:blank:]#;]*prefer-family[[:blank:]]*=/c\prefer-family = IPv4' /etc/wgetrc
+
+ else
+
+ echo 'prefer-family = IPv4' >> /etc/wgetrc
+
+ fi
+
#Check/install minimal APT Pre-Reqs
a_MIN_APT_PREREQS=(
- 'apt-transport-https' # Allows HTTPS sources for ATP
+ 'apt-transport-https' # Allows HTTPS sources for APT
'wget' # Download DietPi-Globals...
'ca-certificates' # ...via HTTPS
+ 'unzip' # Unzip DietPi code
'locales' # Allow ensuring en_GB.UTF-8
'whiptail' # G_WHIP...
'ncurses-bin' # ...using tput
)
- # - Meveric special: https://github.com/Fourdee/DietPi/issues/1285#issuecomment-355759321
- rm /etc/apt/sources.list.d/deb-multimedia.list &> /dev/null
+ #Removing conflicting /etc/apt/sources.list.d entries
+ # - Meveric: https://github.com/Fourdee/DietPi/issues/1285#issuecomment-355759321
+ [[ -f /etc/apt/sources.list.d/deb-multimedia.list ]] && rm /etc/apt/sources.list.d/deb-multimedia.list
+ # - OMV: https://dietpi.com/phpbb/viewtopic.php?f=11&t=2772&p=10646#p10594
+ [[ -f /etc/apt/sources.list.d/openmediavault.list ]] && rm /etc/apt/sources.list.d/openmediavault.list
apt-get clean
apt-get update
- for (( i=0; i<${#a_MIN_APT_PREREQS[@]}; i++))
+ for i in "${a_MIN_APT_PREREQS[@]}"
do
- if ! dpkg-query -s ${a_MIN_APT_PREREQS[$i]} &> /dev/null; then
-
- if ! apt-get install -y ${a_MIN_APT_PREREQS[$i]}; then
+ if ! dpkg-query -s $i &> /dev/null && ! apt-get install -y $i; then
- echo -e "Error: Unable to install ${a_MIN_APT_PREREQS[$i]}, please try to install it manually:\n\t# apt-get install -y ${a_MIN_APT_PREREQS[$i]}"
- exit 1
-
- fi
+ echo -e "[FAILED] Unable to install $i, please try to install it manually:\n\t # apt-get install -y $i\n"
+ exit 1
fi
@@ -71,9 +91,9 @@
unset a_MIN_APT_PREREQS
#Setup locale
- # - Remove exisiting settings that could break dpkg-reconfigure locales
+ # - Remove existing settings that could break dpkg-reconfigure locales
> /etc/environment
- rm /etc/default/locale &> /dev/null
+ [[ -f /etc/default/locale ]] && rm /etc/default/locale
# - NB: DEV, any changes here must be also rolled into function '/DietPi/dietpi/func/dietpi-set_software locale', for future script use
echo 'en_GB.UTF-8 UTF-8' > /etc/locale.gen
@@ -82,7 +102,7 @@
# - "update-locale": Add $LANG to "/etc/default/locale" based on generated locale(s) or interactive default language selection.
if ! dpkg-reconfigure -f noninteractive locales; then
- echo -e 'Error: Locale generation failed. Aborting...\n'
+ echo -e '[FAILED] Locale generation failed. Aborting...\n'
exit 1
fi
@@ -93,6 +113,10 @@
update-locale LC_TIME=en_GB.UTF-8
update-locale LC_ALL=en_GB.UTF-8
+ # - Export locale vars to assure the following whiptail being beautiful
+ export LANG=en_GB.UTF8
+ export LC_ALL=en_GB.UTF8
+
#Select gitbranch
aWHIP_BRANCH=(
@@ -102,22 +126,20 @@
)
- WHIP_RETURN=$(whiptail --title "$G_PROGRAM_NAME" --menu "Please select a Git branch:" --default-item "master" --ok-button "Ok" --cancel-button "Exit" --backtitle "$G_PROGRAM_NAME" 12 80 3 "${aWHIP_BRANCH[@]}" 3>&1 1>&2 2>&3)
- if (( $? == 0 )); then
+ if WHIP_RETURN=$(whiptail --title "$G_PROGRAM_NAME" --menu 'Please select a Git branch:' --default-item 'master' --ok-button 'Ok' --cancel-button 'Exit' --backtitle "$G_PROGRAM_NAME" 12 80 3 "${aWHIP_BRANCH[@]}" 3>&1 1>&2 2>&3); then
- export GITBRANCH=$WHIP_RETURN
+ GITBRANCH=$WHIP_RETURN
else
- echo -e 'No choice detected. Aborting...\n'
+ echo -e '[ INFO ] No choice detected. Aborting...\n'
exit 0
fi
- unset aWHIP_BRANCH
- unset WHIP_RETURN
+ unset aWHIP_BRANCH WHIP_RETURN
- echo "Git branch: $GITOWNER/$GITBRANCH"
+ echo "[ INFO ] Selected Git branch: $GITOWNER/$GITBRANCH"
#------------------------------------------------------------------------------------------------
# DietPi-Globals
@@ -126,7 +148,7 @@
# - NB: We'll have to manually handle errors, until DietPi-Globals are sucessfully loaded.
if ! wget "https://raw.githubusercontent.com/$GITOWNER/DietPi/$GITBRANCH/dietpi/func/dietpi-globals" -O dietpi-globals; then
- echo -e 'Error: Unable to download dietpi-globals. Aborting...\n'
+ echo -e '[FAILED] Unable to download dietpi-globals. Aborting...\n'
exit 1
fi
@@ -134,7 +156,7 @@
# - Load
if ! . ./dietpi-globals; then
- echo -e 'Error: Unable to load dietpi-globals. Aborting...\n'
+ echo -e '[FAILED] Unable to load dietpi-globals. Aborting...\n'
exit 1
fi
@@ -146,12 +168,7 @@
DISTRO_TARGET=0
DISTRO_TARGET_NAME=''
- if grep -q 'wheezy' /etc/os-release; then
-
- G_DISTRO=2
- G_DISTRO_NAME='wheezy'
-
- elif grep -q 'jessie' /etc/os-release; then
+ if grep -q 'jessie' /etc/os-release; then
G_DISTRO=3
G_DISTRO_NAME='jessie'
@@ -173,7 +190,7 @@
fi
- G_HW_ARCH_DESCRIPTION="$(uname -m)"
+ G_HW_ARCH_DESCRIPTION=$(uname -m)
if [[ $G_HW_ARCH_DESCRIPTION == 'armv6l' ]]; then
G_HW_ARCH=1
@@ -192,7 +209,7 @@
else
- G_DIETPI-NOTIFY 1 "Error: Unknown or unsupported CPU architecture \"$G_HW_ARCH_DESCRIPTION\". Aborting...\n"
+ G_DIETPI-NOTIFY 1 "Unknown or unsupported CPU architecture: \"$G_HW_ARCH_DESCRIPTION\". Aborting...\n"
exit 1
fi
@@ -219,51 +236,38 @@
((SETUP_STEP++))
G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------'
#------------------------------------------------------------------------------------------------
- if [[ -d /DietPi/dietpi || /boot/dietpi ]]; then
+ if [[ -d /DietPi/dietpi || -d /boot/dietpi ]]; then
G_DIETPI-NOTIFY 2 'DietPi system found, running pre-prep'
# - Stop services
- /DietPi/dietpi/dietpi-services stop
-
- [[ -f /etc/systemd/system/dietpi-ramlog ]] && systemctl stop dietpi-ramlog
- systemctl stop dietpi-ramdisk
+ [[ -f /DietPi/dietpi/dietpi-services ]] && /DietPi/dietpi/dietpi-services stop
+ [[ -f /etc/systemd/system/dietpi-ramdisk.service ]] && systemctl stop dietpi-ramdisk
+ [[ -f /etc/systemd/system/dietpi-ramlog.service ]] && systemctl stop dietpi-ramlog
# - Delete any previous existing data
- rm -R /DietPi/*
- rm -R /boot/dietpi
+ # Failsafe
+ umount /DietPi
+ [[ -d /DietPi ]] && rm -R /DietPi
+ [[ -d /boot/dietpi ]] && rm -R /boot/dietpi
- rm -R /mnt/dietpi-backup &> /dev/null
- rm -R /mnt/dietpi-sync &> /dev/null
- rm -R /mnt/dietpi_userdata &> /dev/null
+ [[ -d /mnt/dietpi-backup ]] && rm -R /mnt/dietpi-backup
+ [[ -d /mnt/dietpi-sync ]] && rm -R /mnt/dietpi-sync
+ [[ -d /mnt/dietpi_userdata ]] && rm -R /mnt/dietpi_userdata
- rm -R /etc/dietpi &> /dev/null # Pre v160
- rm -R /var/lib/dietpi &> /dev/null
- rm -R /var/tmp/dietpi &> /dev/null
+ [[ -d /etc/dietpi ]] && rm -R /etc/dietpi # Pre v160
+ [[ -d /var/lib/dietpi ]] && rm -R /var/lib/dietpi
+ [[ -d /var/tmp/dietpi ]] && rm -R /var/tmp/dietpi
- rm /root/DietPi-Automation.log &> /dev/null
- rm /boot/Automation_Format_My_Usb_Drive &> /dev/null
+ [[ -f /root/DietPi-Automation.log ]] && rm /root/DietPi-Automation.log
+ [[ -f /boot/Automation_Format_My_Usb_Drive ]] && rm /boot/Automation_Format_My_Usb_Drive
else
- G_DIETPI-NOTIFY 2 'Non-DietPi system'
+ G_DIETPI-NOTIFY 2 'Non-DietPi system found, skipping pre-prep'
fi
- #------------------------------------------------------------------------------------------------
- echo ''
- G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------'
- G_DIETPI-NOTIFY 0 "Step $SETUP_STEP: Initial prep to allow this script to function:"
- ((SETUP_STEP++))
- G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------'
- #------------------------------------------------------------------------------------------------
- #Recreate dietpi logs dir, used by G_AGx
- G_RUN_CMD mkdir -p /var/tmp/dietpi/logs
-
- G_DIETPI-NOTIFY 2 'Installing core packages, required for next stage of this script:'
-
- G_AGI apt-transport-https unzip
-
#------------------------------------------------------------------------------------------------
echo ''
G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------'
@@ -293,10 +297,10 @@
)
- for (( i=0; i<${#aDISALLOWED_NAMES[@]}; i++))
+ for i in "${aDISALLOWED_NAMES[@]}"
do
- if [[ ${G_WHIP_RETURNED_VALUE,,} =~ ${aDISALLOWED_NAMES[$i]} ]]; then
+ if [[ ${G_WHIP_RETURNED_VALUE,,} =~ $i ]]; then
DISALLOWED_NAME=1
break
@@ -313,7 +317,8 @@
else
- IMAGE_CREATOR="$G_WHIP_RETURNED_VALUE"
+ IMAGE_CREATOR=$G_WHIP_RETURNED_VALUE
+ G_DIETPI-NOTIFY 2 "Entered image creator: $IMAGE_CREATOR"
break
fi
@@ -329,7 +334,8 @@
G_WHIP_INPUTBOX 'Please enter the name or URL of the pre-image you installed on this system, prior to running this script. This will be used to identify the pre-image credits.\n\nEG: Debian, Raspbian Lite, Meveric, FriendlyARM, or "forum.odroid.com/viewtopic.php?f=ABC&t=XYZ" etc.\n\nNB: An entry is required.'
if (( ! $? )) && [[ $G_WHIP_RETURNED_VALUE ]]; then
- PREIMAGE_INFO="$G_WHIP_RETURNED_VALUE"
+ PREIMAGE_INFO=$G_WHIP_RETURNED_VALUE
+ G_DIETPI-NOTIFY 2 "Entered pre-image info: $PREIMAGE_INFO"
break
fi
@@ -396,45 +402,42 @@
G_WHIP_MENU 'Please select the current device this is being installed on:\n - NB: Select "Generic device" if not listed.\n - "Core devices": Are fully supported by DietPi, offering full GPU + Kodi support.\n - "Limited support devices": No GPU support, supported limited to DietPi specific issues only (eg: excludes Kernel/GPU/VPU related items).'
if (( $? )) || [[ -z $G_WHIP_RETURNED_VALUE ]]; then
- G_DIETPI-NOTIFY 1 'No choice detected. Aborting...'
+ G_DIETPI-NOTIFY 1 'No choice detected. Aborting...\n'
exit 0
fi
# + Set for future scripts
G_HW_MODEL=$G_WHIP_RETURNED_VALUE
-
- G_DIETPI-NOTIFY 2 "Setting G_HW_MODEL index of: $G_HW_MODEL"
- G_DIETPI-NOTIFY 2 "CPU ARCH = $G_HW_ARCH : $G_HW_ARCH_DESCRIPTION"
-
echo $G_HW_MODEL > /etc/.dietpi_hw_model_identifier
- #WiFi selection
- G_DIETPI-NOTIFY 2 'WiFi selection'
-
- G_WHIP_DEFAULT_ITEM=1
- (( $G_HW_MODEL == 20 )) && G_WHIP_DEFAULT_ITEM=0
+ G_DIETPI-NOTIFY 2 "Selected hardware model ID: $G_HW_MODEL"
+ G_DIETPI-NOTIFY 2 "Detected CPU architecture: $G_HW_ARCH_DESCRIPTION (ID: $G_HW_ARCH)"
G_WHIP_MENU_ARRAY=(
- '0' ": I don't require WiFi, do not install."
- '1' ': I require WiFi functionality, keep/install related packages.'
+ '0' ': I do not require WiFi functionality, skip related package install.'
+ '1' ': I require WiFi functionality, install related packages.'
)
+ G_WHIP_DEFAULT_ITEM=1
+ (( $G_HW_MODEL == 20 )) && G_WHIP_DEFAULT_ITEM=0
+
if G_WHIP_MENU 'Please select an option:' && (( $G_WHIP_RETURNED_VALUE )); then
- G_DIETPI-NOTIFY 2 'Marking WiFi as needed'
+ G_DIETPI-NOTIFY 2 'Marking WiFi as required'
WIFI_REQUIRED=1
+ else
+
+ G_DIETPI-NOTIFY 2 'Marking WiFi as NOT required'
+
fi
#Distro Selection
- G_WHIP_DEFAULT_ITEM=$G_DISTRO
- G_WHIP_BUTTON_CANCEL_TEXT='Exit'
DISTRO_LIST_ARRAY=(
- '3' ': Jessie (oldstable, if you need to avoid upgrade to current release)'
'4' ': Stretch (current stable release, recommended)'
'5' ': Buster (testing only, not officially supported)'
@@ -443,39 +446,35 @@
# - Enable/list available options based on criteria
# NB: Whiptail use 2 array indexs per whip displayed entry.
G_WHIP_MENU_ARRAY=()
- for ((i=0; i<$(( ${#DISTRO_LIST_ARRAY[@]} / 2 )); i++))
+ for ((i=0; i<${#DISTRO_LIST_ARRAY[@]}; i+=2))
do
- temp_distro_available=1
- temp_distro_index=$(( $i + 3 ))
# - Disable downgrades
- if (( $temp_distro_index < $G_DISTRO )); then
+ if (( ${DISTRO_LIST_ARRAY[$i]} < $G_DISTRO )); then
- G_DIETPI-NOTIFY 2 "Disabled Distro downgrade: index $temp_distro_index"
- temp_distro_available=0
-
- fi
+ G_DIETPI-NOTIFY 2 "Disabled distro downgrade to: ${DISTRO_LIST_ARRAY[$i+1]}"
# - Enable option
- if (( $temp_distro_available )); then
+ else
- G_WHIP_MENU_ARRAY+=( "${DISTRO_LIST_ARRAY[$(( $i * 2 ))]}" "${DISTRO_LIST_ARRAY[$(( ($i * 2) + 1 ))]}" )
+ G_WHIP_MENU_ARRAY+=( "${DISTRO_LIST_ARRAY[$i]}" "${DISTRO_LIST_ARRAY[$i+1]}" )
fi
done
- #delete []
unset DISTRO_LIST_ARRAY
if [[ -z ${G_WHIP_MENU_ARRAY+x} ]]; then
- G_DIETPI-NOTIFY 1 'Error: No available Distros for this system. Aborting...\n'
+ G_DIETPI-NOTIFY 1 'No available distro versions for this system. Aborting...\n'
exit 1
fi
- G_WHIP_MENU "Please select a distro to install on this system. Selecting a distro that is older than the current installed on system, is not supported.\n\nCurrently installed:\n - $G_DISTRO $G_DISTRO_NAME"
+ G_WHIP_DEFAULT_ITEM=${G_WHIP_MENU_ARRAY[0]} # Downgrades disabled, so first item matches current/lowest supported distro version
+ G_WHIP_BUTTON_CANCEL_TEXT='Exit'
+ G_WHIP_MENU "Please select a distro version to install on this system. Selecting a distro that is older than the current installed on system, is not supported.\n\nCurrently installed:\n - $G_DISTRO $G_DISTRO_NAME"
if (( $? )) || [[ -z $G_WHIP_RETURNED_VALUE ]]; then
G_DIETPI-NOTIFY 1 'No choice detected. Aborting...\n'
@@ -484,11 +483,7 @@
fi
DISTRO_TARGET=$G_WHIP_RETURNED_VALUE
- if (( $DISTRO_TARGET == 3 )); then
-
- DISTRO_TARGET_NAME='jessie'
-
- elif (( $DISTRO_TARGET == 4 )); then
+ if (( $DISTRO_TARGET == 4 )); then
DISTRO_TARGET_NAME='stretch'
@@ -496,8 +491,15 @@
DISTRO_TARGET_NAME='buster'
+ else
+
+ G_DIETPI-NOTIFY 1 'Invalid choice detected. Aborting...\n'
+ exit 1
+
fi
+ G_DIETPI-NOTIFY 2 "Selected Debian version: $DISTRO_TARGET_NAME (ID: $DISTRO_TARGET)"
+
#------------------------------------------------------------------------------------------------
echo ''
G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------'
@@ -511,15 +513,13 @@
G_RUN_CMD wget "$INTERNET_ADDRESS" -O package.zip
[[ -d DietPi-$GITBRANCH ]] && l_message='Cleaning previously extracted files' G_RUN_CMD rm -R "DietPi-$GITBRANCH"
- l_message='Extracting DietPi sourcecode' G_RUN_CMD unzip -o package.zip
+ l_message='Extracting DietPi sourcecode' G_RUN_CMD unzip package.zip
rm package.zip
- [[ ! -d /boot ]] && l_message='Creating /boot' G_RUN_CMD mkdir -p /boot
+ [[ -d /boot ]] || l_message='Creating /boot' G_RUN_CMD mkdir -p /boot
G_DIETPI-NOTIFY 2 'Moving kernel and boot configuration to /boot'
- G_RUN_CMD mv "DietPi-$GITBRANCH/dietpi.txt" /boot/
-
# - HW specific config.txt, boot.ini uEnv.txt
if (( $G_HW_MODEL < 10 )); then
@@ -539,26 +539,26 @@
fi
- G_RUN_CMD mv "DietPi-$GITBRANCH/README.md" /boot/
- #G_RUN_CMD mv "DietPi-$GITBRANCH/CHANGELOG.txt" /boot/
+ G_RUN_CMD mv "DietPi-$GITBRANCH/dietpi.txt" /boot/
+ G_RUN_CMD mv "DietPi-$GITBRANCH/README.md" /boot/dietpi-README.md
+ G_RUN_CMD mv "DietPi-$GITBRANCH/CHANGELOG.txt" /boot/dietpi-CHANGELOG.txt
- # - Remove server_version / patch_file (downloads fresh from dietpi-update)
+ # - Remove server_version* / (pre-)patch_file (downloads fresh from dietpi-update)
+ rm "DietPi-$GITBRANCH/dietpi/server_version"*
+ rm "DietPi-$GITBRANCH/dietpi/pre-patch_file"
rm "DietPi-$GITBRANCH/dietpi/patch_file"
- rm DietPi-"$GITBRANCH"/dietpi/server_version*
-
- l_message='Copy DietPi core files to /boot/dietpi' G_RUN_CMD cp -Rf DietPi-"$GITBRANCH"/dietpi /boot/
- l_message='Copy rootfs files in place' G_RUN_CMD cp -Rf DietPi-"$GITBRANCH"/rootfs/. /
+ l_message='Copy DietPi core files to /boot/dietpi' G_RUN_CMD cp -Rf "DietPi-$GITBRANCH/dietpi" /boot/
+ l_message='Copy DietPi rootfs files in place' G_RUN_CMD cp -Rf "DietPi-$GITBRANCH/rootfs"/. /
l_message='Clean download location' G_RUN_CMD rm -R "DietPi-$GITBRANCH"
-
- l_message='Set execute permissions for DietPi scripts' G_RUN_CMD chmod -R +x /boot/dietpi /var/lib/dietpi/services /etc/cron.*/dietpi /etc/profile.d/dietpi-*.sh /etc/bashrc.d/dietpi-*.sh
+ l_message='Set execute permissions for DietPi scripts' G_RUN_CMD chmod -R +x /DietPi/dietpi /var/lib/dietpi/services /etc/cron.*/dietpi
G_RUN_CMD systemctl daemon-reload
G_RUN_CMD systemctl enable dietpi-ramdisk
# - Mount tmpfs
G_RUN_CMD mkdir -p /DietPi
- G_RUN_CMD mount -t tmpfs -o size=20m tmpfs /DietPi
+ G_RUN_CMD mount -t tmpfs -o size=10m tmpfs /DietPi
l_message='Starting DietPi-RAMdisk' G_RUN_CMD systemctl start dietpi-ramdisk
#------------------------------------------------------------------------------------------------
@@ -569,33 +569,29 @@
G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------'
#------------------------------------------------------------------------------------------------
- G_DIETPI-NOTIFY 2 'Removing conflicting /etc/apt/sources.list.d entries'
- # NB: Apt sources will get overwritten during 1st run, via boot script and dietpi.txt entry
-
- #rm /etc/apt/sources.list.d/* &> /dev/null #Probably a bad idea
- #rm /etc/apt/sources.list.d/deb-multimedia.list &> /dev/null #meveric, already done above
- rm /etc/apt/sources.list.d/openmediavault.list &> /dev/null #https://dietpi.com/phpbb/viewtopic.php?f=11&t=2772&p=10646#p10594
-
G_DIETPI-NOTIFY 2 "Setting APT sources.list: $DISTRO_TARGET_NAME $DISTRO_TARGET"
# - We need to forward $DISTRO_TARGET* to dietpi-set_software, as well as $G_HW_MODEL for Debian vs Raspbian decision.
- G_DISTRO=$DISTRO_TARGET G_DISTRO_NAME="$DISTRO_TARGET_NAME" G_HW_MODEL=$G_HW_MODEL G_RUN_CMD /DietPi/dietpi/func/dietpi-set_software apt-mirror 'default'
+ G_DISTRO=$DISTRO_TARGET G_DISTRO_NAME=$DISTRO_TARGET_NAME G_HW_MODEL=$G_HW_MODEL G_RUN_CMD /DietPi/dietpi/func/dietpi-set_software apt-mirror 'default'
# - Meveric, update repo to use our EU mirror: https://github.com/Fourdee/DietPi/issues/1519#issuecomment-368234302
sed -i 's@https://oph.mdrjr.net/meveric@http://fuzon.co.uk/meveric@' /etc/apt/sources.list.d/meveric* &> /dev/null
+ # - (Re)create DietPi logs dir, used by G_AGx
+ G_RUN_CMD mkdir -p /var/tmp/dietpi/logs
+
G_AGUP
# - @MichaIng https://github.com/Fourdee/DietPi/pull/1266/files
- G_DIETPI-NOTIFY 2 'Marking all packages as auto installed first, to allow effective autoremove afterwards'
+ G_DIETPI-NOTIFY 2 'Marking all packages as auto-installed first, to allow effective autoremove afterwards'
G_RUN_CMD apt-mark auto $(apt-mark showmanual)
# - @MichaIng https://github.com/Fourdee/DietPi/pull/1266/files
- G_DIETPI-NOTIFY 2 'Disable automatic recommends/suggests installation and allow them to be autoremoved:'
+ G_DIETPI-NOTIFY 2 'Disable automatic recommends/suggests install and allow them to be autoremoved:'
- # Remove any existing apt recommends settings
- rm /etc/apt/apt.conf.d/*recommends* &> /dev/null
+ # Remove any existing APT recommends settings
+ rm -f /etc/apt/apt.conf.d/*recommends*
G_ERROR_HANDLER_COMMAND='/etc/apt/apt.conf.d/99-dietpi-norecommends'
cat << _EOF_ > $G_ERROR_HANDLER_COMMAND
@@ -607,7 +603,7 @@ _EOF_
G_ERROR_HANDLER_EXITCODE=$?
G_ERROR_HANDLER
- G_DIETPI-NOTIFY 2 'Forcing use of modified package configs'
+ G_DIETPI-NOTIFY 2 'Preserve modified config files on APT update:'
G_ERROR_HANDLER_COMMAND='/etc/apt/apt.conf.d/99-dietpi-forceconf'
cat << _EOF_ > $G_ERROR_HANDLER_COMMAND
@@ -637,21 +633,22 @@ _EOF_
'fake-hwclock' # Hardware clock emulation, to allow correct timestamps during boot before network time sync
'gnupg' # apt-key add
'htop' # System monitor
- 'iputils-ping' # ping command
+ 'iputils-ping' # "ping" command
'isc-dhcp-client' # DHCP client
- 'kmod' # "modprobe", "lsmod", required by several DietPi scripts
- 'locales' # Support locales, necessary for DietPi scripts, as we use enGB.UTF8 as default language
+ 'kmod' # "modprobe", "lsmod", used by several DietPi scripts
+ 'locales' # Support locales, necessary for DietPi scripts, as we use en_GB.UTF8 as default language
'nano' # Simple text editor
'p7zip-full' # .7z wrapper
- 'parted' # Needed by DietPi-Boot + DietPi-Drive_Manager
- 'psmisc' # "killall", needed by many DietPi scripts
+ 'parted' # Drive partitioning, required by DietPi-Boot + DietPi-Drive_Manager
+ 'procps' # "kill", "ps", "pgrep", "sysctl", used by several DietPi scripts
+ 'psmisc' # "killall", used by several DietPi scripts
'resolvconf' # Network nameserver handler + depandant for "ifupdown" (network interface handler) => "iproute2" ("ip" command)
'sudo' # Root permission wrapper for users within /etc/sudoers(.d/)
- 'systemd-sysv' # Includes systemd and additional commands: poweroff, shutdown etc.
+ 'systemd-sysv' # Includes systemd and additional commands: "poweroff", "shutdown" etc.
'tzdata' # Time zone data for system clock, auto summer/winter time adjustment
'udev' # /dev/ and hotplug management daemon
'unzip' # .zip unpacker
- 'usbutils' # "lsusb", needed by DietPi-Software + DietPi-Bugreport
+ 'usbutils' # "lsusb", used by DietPi-Software + DietPi-Bugreport
'wget' # Download tool
'whiptail' # DietPi dialogs
@@ -736,7 +733,7 @@ _EOF_
)
- for i in "${!apackages[@]}"
+ for i in "${apackages[@]}"
do
while read -r line
@@ -750,7 +747,7 @@ _EOF_
fi
- done <<< "$(dpkg --get-selections | grep "^${apackages[$i]}" | awk '{print $1}')"
+ done <<< "$(dpkg --get-selections | mawk -v pat="^$i" '$0~pat {print $1}')"
done
@@ -760,7 +757,7 @@ _EOF_
elif (( $G_HW_MODEL < 10 )); then
apt-mark unhold libraspberrypi-bin libraspberrypi0 raspberrypi-bootloader raspberrypi-kernel raspberrypi-sys-mods raspi-copies-and-fills
- rm -R /lib/modules/*
+ rm -Rf /lib/modules/*
G_AGI libraspberrypi-bin libraspberrypi0 raspberrypi-bootloader raspberrypi-kernel raspberrypi-sys-mods
G_AGI --reinstall libraspberrypi-bin libraspberrypi0 raspberrypi-bootloader raspberrypi-kernel
# Buster systemd-udevd doesn't support the current raspi-copies-and-fills: https://github.com/Fourdee/DietPi/issues/1286
@@ -781,7 +778,7 @@ _EOF_
elif (( $G_HW_MODEL == 11 )); then
#G_AGI linux-image-4.9-armhf-odroid-xu3
- G_AGI $(dpkg --get-selections | grep '^linux-image' | awk '{print $1}')
+ G_AGI $(dpkg --get-selections | mawk '/^linux-image/ {print $1}')
dpkg --get-selections | grep -q '^linux-image' || G_AGI linux-image-4.14-armhf-odroid-xu4
# Odroid C1
@@ -789,37 +786,18 @@ _EOF_
G_AGI linux-image-armhf-odroid-c1
- # RockPro64
- elif (( $G_HW_MODEL == 42 )); then
-
- G_AGI linux-rockpro64 gdisk
-
- # Rock64
- elif (( $G_HW_MODEL == 43 )); then
-
- G_AGI linux-rock64 gdisk
-
# BBB
elif (( $G_HW_MODEL == 71 )); then
G_AGI device-tree-compiler #Kern
- # - Auto detect kernel package
+ # - Auto detect kernel package incl. ARMbian/others DTB
else
- AUTO_DETECT_KERN_PKG=$(dpkg --get-selections | grep '^linux-image' | awk '{print $1}')
+ AUTO_DETECT_KERN_PKG=$(dpkg --get-selections | grep -E '^linux-(image|dtb)' | awk '{print $1}')
if [[ $AUTO_DETECT_KERN_PKG ]]; then
- # - Install kern package if it exists in cache, else, mark manual #: https://github.com/Fourdee/DietPi/issues/1651#issuecomment-376974917
- if [[ $(apt-cache search ^$AUTO_DETECT_KERN_PKG) ]]; then
-
- G_AGI $AUTO_DETECT_KERN_PKG
-
- else
-
- apt-mark manual $AUTO_DETECT_KERN_PKG
-
- fi
+ G_AGI $AUTO_DETECT_KERN_PKG
else
@@ -827,14 +805,6 @@ _EOF_
fi
- #ARMbian/others DTB
- AUTO_DETECT_DTB_PKG=$(dpkg --get-selections | grep '^linux-dtb-' | awk '{print $1}')
- if [[ $AUTO_DETECT_DTB_PKG ]]; then
-
- G_AGI $AUTO_DETECT_DTB_PKG
-
- fi
-
fi
# - Firmware
@@ -847,7 +817,7 @@ _EOF_
# Usually no firmware should be necessary for VMs. If user manually passes though some USB device, user might need to install the firmware then.
if (( $G_HW_MODEL != 20 )); then
- aPACKAGES_REQUIRED_INSTALL+=('firmware-realtek') # Eth/WiFi/BT dongle firmware
+ aPACKAGES_REQUIRED_INSTALL+=('firmware-realtek') # Eth/WiFi/BT dongle firmware
aPACKAGES_REQUIRED_INSTALL+=('firmware-linux-nonfree')
fi
@@ -876,23 +846,11 @@ _EOF_
G_DIETPI-NOTIFY 2 'Generating list of minimal packages, required for DietPi installation'
- INSTALL_PACKAGES=''
- for ((i=0; i<${#aPACKAGES_REQUIRED_INSTALL[@]}; i++))
- do
-
- # One line INSTALL_PACKAGES so we can use it later.
- INSTALL_PACKAGES+="${aPACKAGES_REQUIRED_INSTALL[$i]} "
-
- done
-
- # - delete[]
- unset aPACKAGES_REQUIRED_INSTALL
-
- l_message='Marking required packages as manually installed' G_RUN_CMD apt-mark manual $INSTALL_PACKAGES
+ l_message='Marking required packages as manually installed' G_RUN_CMD apt-mark manual ${aPACKAGES_REQUIRED_INSTALL[@]}
# Purging additional packages, that (in some cases) do not get autoremoved:
# - dhcpcd5: https://github.com/Fourdee/DietPi/issues/1560#issuecomment-370136642
- # - dbus: Not needed for headless images, but sometimes marked as "important", thus not autoremoved.
+ # - dbus: Not required for headless images, but sometimes marked as "important", thus not autoremoved.
G_AGP dbus dhcpcd5
G_AGA
@@ -908,20 +866,18 @@ _EOF_
# - Distro is now target (for APT purposes and G_AGX support due to installed binary, its here, instead of after G_AGUP)
G_DISTRO=$DISTRO_TARGET
- G_DISTRO_NAME="$DISTRO_TARGET_NAME"
+ G_DISTRO_NAME=$DISTRO_TARGET_NAME
G_DIETPI-NOTIFY 2 'Installing core DietPi pre-req APT packages'
- G_AGI $INSTALL_PACKAGES
+ G_AGI ${aPACKAGES_REQUIRED_INSTALL[@]}
- G_AGA
-
- # Reenable HTTPS for deb.debian.org, if system was dist-upgraded to Stretch+
- if (( $G_DISTRO > 3 && $G_HW_MODEL > 9 )); then
+ unset aPACKAGES_REQUIRED_INSTALL
- sed -i 's/http:/https:/g' /etc/apt/sources.list
+ G_AGA
- fi
+ # Reenable HTTPS for deb.debian.org, since system was dist-upgraded to Stretch+
+ (( $G_HW_MODEL > 9 )) && sed -i 's/http:/https:/g' /etc/apt/sources.list
#------------------------------------------------------------------------------------------------
echo ''
@@ -933,96 +889,118 @@ _EOF_
G_DIETPI-NOTIFY 2 'Deleting list of known users, not required by DietPi'
- userdel -f pi &> /dev/null
- userdel -f test &> /dev/null #@fourdee
- userdel -f odroid &> /dev/null
- userdel -f rock64 &> /dev/null
- userdel -f linaro &> /dev/null #ASUS TB
- userdel -f dietpi &> /dev/null #recreated below
- userdel -f debian &> /dev/null #BBB
+ getent passwd pi &> /dev/null && userdel -f pi
+ getent passwd test &> /dev/null && userdel -f test #@fourdee
+ getent passwd odroid &> /dev/null && userdel -f odroid
+ getent passwd rock64 &> /dev/null && userdel -f rock64
+ getent passwd linaro &> /dev/null && userdel -f linaro #ASUS TB
+ getent passwd dietpi &> /dev/null && userdel -f dietpi #recreated below
+ getent passwd debian &> /dev/null && userdel -f debian #BBB
G_DIETPI-NOTIFY 2 'Removing misc files/folders/services, not required by DietPi'
- rm -R /home &> /dev/null
- rm -R /media &> /dev/null
- rm -R /selinux &> /dev/null
+ [[ -d /home ]] && rm -R /home
+ [[ -d /media ]] && rm -R /media
+ [[ -d /selinux ]] && rm -R /selinux
# - www
- rm -R /var/www/* &> /dev/null
+ [[ -d /var/www ]] && rm -Rf /var/www/{,.??,.[^.]}*
# - sourcecode (linux-headers etc)
- rm -R /usr/src/* &> /dev/null
+ [[ -d /usr/src ]] && rm -Rf /usr/src/{,.??,.[^.]}*
# - root
- rm -R /root/.cache/* &> /dev/null
- rm -R /root/.local/* &> /dev/null
- rm -R /root/.config/* &> /dev/null
+ [[ -e /root/.cache ]] && rm -R /root/.cache
+ [[ -e /root/.local ]] && rm -R /root/.local
+ [[ -e /root/.config ]] && rm -R /root/.config
# - documentation folders
- rm -R /usr/share/man &> /dev/null
- rm -R /usr/share/doc &> /dev/null
- rm -R /usr/share/doc-base &> /dev/null
- rm -R /usr/share/calendar &> /dev/null
+ [[ -d /usr/share/man ]] && rm -R /usr/share/man
+ [[ -d /usr/share/doc ]] && rm -R /usr/share/doc
+ [[ -d /usr/share/doc-base ]] && rm -R /usr/share/doc-base
+ [[ -d /usr/share/calendar ]] && rm -R /usr/share/calendar
# - Previous debconfs
- rm /var/cache/debconf/*-old &> /dev/null
+ rm -f /var/cache/debconf/*-old
# - Fonts
- rm -R /usr/share/fonts/* &> /dev/null
- rm -R /usr/share/icons/* &> /dev/null
+ [[ -d /usr/share/fonts ]] && rm -R /usr/share/fonts
+ [[ -d /usr/share/icons ]] && rm -R /usr/share/icons
- # - ARMbian
- systemctl disable firstrun &> /dev/null
- rm /etc/init.d/resize2fs &> /dev/null
- rm /etc/init.d/firstrun &> /dev/null
- systemctl disable log2ram &> /dev/null
- systemctl stop log2ram &> /dev/null
- rm $(find / -name armbian*.service) &> /dev/null
- rm $(find / -name log2ram.service) &> /dev/null
- rm /usr/local/sbin/log2ram &> /dev/null
- rm /usr/bin/armbianmonitor &> /dev/null
- rm -R /usr/lib/armbian &> /dev/null
- rm -R /usr/share/armbian &> /dev/null
- rm /etc/profile.d/armbian* &> /dev/null
- rm -R /etc/armbian* &> /dev/null
- rm -R /etc/default/armbian* &> /dev/null
- rm -R /etc/update-motd.d/*armbian* &> /dev/null
- rm -R /etc/logrotate.d &> /dev/null
- rm -R /etc/X11/xorg.conf.d/*armbian* &> /dev/null
- rm /etc/cron.d/armbian* &> /dev/null
- rm /etc/cron.daily/armbian* &> /dev/null
- rm /boot/armbian_first_run.txt.template &> /dev/null
- umount /var/log.hdd &> /dev/null
- rm -R /var/log.hdd &> /dev/null
+ # - Stop, disable and remove not required services
+ local aservices=(
+
+ # - ARMbian
+ firstrun
+ resize2fs
+ log2ram
+ armbian*
+ # - Meveric
+ cpu_governor
+
+ )
+
+ for i in ${aservices[@]}
+ do
+
+ # Loop through known service locations
+ for j in /etc/init.d/$i /etc/systemd/system/$i.service /etc/systemd/system/$i.service.d /lib/systemd/system/$i.service /lib/systemd/system/$i.service.d
+ do
+
+ if [[ -e $j ]]; then
+
+ if [[ -f $j ]]; then
+
+ systemctl stop ${j##*/}
+ systemctl disable ${j##*/}
+
+ fi
+
+ rm -R $j
+
+ fi
+
+ done
+
+ done
systemctl daemon-reload
+ # - ARMbian
+ [[ -f /usr/local/sbin/log2ram ]] && rm /usr/local/sbin/log2ram
+ [[ -f /usr/bin/armbianmonitor ]] && rm /usr/bin/armbianmonitor
+ [[ -d /usr/lib/armbian ]] && rm -R /usr/lib/armbian
+ [[ -d /usr/share/armbian ]] && rm -R /usr/share/armbian
+ rm -f /etc/profile.d/armbian*
+ #rm -Rf /etc/armbian* armbian-release required for kernel package update success.
+ rm -Rf /etc/default/armbian*
+ rm -Rf /etc/update-motd.d/*armbian*
+ rm -Rf /etc/X11/xorg.conf.d/*armbian*
+ rm -f /etc/cron.*/armbian*
+ [[ -f /boot/armbian_first_run.txt.template ]] && rm /boot/armbian_first_run.txt.template
+ umount /var/log.hdd 2> /dev/null
+ [[ -d /var/log.hdd ]] && rm -R /var/log.hdd
+
# - Meveric specific
- rm /etc/init.d/cpu_governor &> /dev/null
- rm /etc/systemd/system/cpu_governor.service &> /dev/null
- rm /usr/local/sbin/setup-odroid &> /dev/null
+ [[ -f /usr/local/sbin/setup-odroid ]] && rm /usr/local/sbin/setup-odroid
# - RPi specific https://github.com/Fourdee/DietPi/issues/1631#issuecomment-373965406
- rm /etc/profile.d/wifi-country.sh &> /dev/null
+ [[ -f /etc/profile.d/wifi-country.sh ]] && rm /etc/profile.d/wifi-country.sh
# - make_nas_processes_faster cron job on Rock64 + NanoPi + Pine64(?) images
- rm /etc/cron.d/make_nas_processes_faster &> /dev/null
+ [[ -f /etc/cron.d/make_nas_processes_faster ]] && rm /etc/cron.d/make_nas_processes_faster
#-----------------------------------------------------------------------------------
#Boot Logo
- if [[ -f /boot/boot.bmp ]]; then
-
- G_RUN_CMD wget https://github.com/Fourdee/DietPi/raw/$GITBRANCH/.meta/images/dietpi-logo_boot.bmp -O /boot/boot.bmp
-
- fi
+ [[ -f /boot/boot.bmp ]] && G_RUN_CMD wget https://github.com/$GITOWNER/DietPi/raw/$GITBRANCH/.meta/images/dietpi-logo_boot.bmp -O /boot/boot.bmp
#-----------------------------------------------------------------------------------
- # Bash Profiles
+ #Bash Profiles
# - Pre v6.9 cleaning:
sed -i '/\/DietPi/d' /root/.bashrc
sed -i '/\/DietPi/d' /home/dietpi/.bashrc &> /dev/null
- rm /etc/profile.d/99-dietpi* &> /dev/null
+ rm -f /etc/profile.d/99-dietpi*
# - 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
@@ -1037,8 +1015,7 @@ _EOF_
l_message='Creating DietPi User Account' G_RUN_CMD /DietPi/dietpi/func/dietpi-set_software useradd dietpi
#-----------------------------------------------------------------------------------
- #UID bit for sudo
- # - https://github.com/Fourdee/DietPi/issues/794
+ #UID bit for sudo: https://github.com/Fourdee/DietPi/issues/794
G_DIETPI-NOTIFY 2 'Configuring Sudo UID bit'
@@ -1052,19 +1029,17 @@ _EOF_
# - /var/lib/dietpi : Core storage for installed non-standard APT software, outside of /mnt/dietpi_userdata
#mkdir -p /var/lib/dietpi
mkdir -p /var/lib/dietpi/postboot.d
- chown dietpi:dietpi /var/lib/dietpi
- chmod 660 /var/lib/dietpi
-
# Storage locations for program specifc additional data
mkdir -p /var/lib/dietpi/dietpi-autostart
mkdir -p /var/lib/dietpi/dietpi-config
- mkdir -p /var/tmp/dietpi/logs/dietpi-ramlog_store
-
#mkdir -p /var/lib/dietpi/dietpi-software
- mkdir -p /var/lib/dietpi/dietpi-software/installed #Additional storage for installed apps, eg: custom scripts and data
+ mkdir -p /var/lib/dietpi/dietpi-software/installed #Additional storage for installed apps, eg: custom scripts and data
+ chown dietpi:dietpi /var/lib/dietpi
+ chmod 660 /var/lib/dietpi
# - /var/tmp/dietpi : Temp storage saved during reboots, eg: logs outside of /var/log
- mkdir -p /var/tmp/dietpi/logs
+ #mkdir -p /var/tmp/dietpi/logs
+ mkdir -p /var/tmp/dietpi/logs/dietpi-ramlog_store
chown dietpi:dietpi /var/tmp/dietpi
chmod 660 /var/tmp/dietpi
@@ -1074,9 +1049,9 @@ _EOF_
chmod 660 /DietPi
# - /mnt/dietpi_userdata : DietPi userdata
- mkdir -p "$G_FP_DIETPI_USERDATA"
- chown dietpi:dietpi "$G_FP_DIETPI_USERDATA"
- chmod -R 775 "$G_FP_DIETPI_USERDATA"
+ mkdir -p $G_FP_DIETPI_USERDATA
+ chown dietpi:dietpi $G_FP_DIETPI_USERDATA
+ chmod -R 775 $G_FP_DIETPI_USERDATA
# - Networked drives
mkdir -p /mnt/samba
@@ -1092,60 +1067,57 @@ _EOF_
G_RUN_CMD systemctl enable dietpi-boot
G_RUN_CMD systemctl enable dietpi-preboot
G_RUN_CMD systemctl enable dietpi-postboot
- G_RUN_CMD systemctl enable kill-ssh-user-sessions-before-network
+ G_RUN_CMD systemctl enable dietpi-kill_ssh
#-----------------------------------------------------------------------------------
#Cron Jobs
- G_DIETPI-NOTIFY 2 'Configuring Cron'
+ G_DIETPI-NOTIFY 2 'Configuring Cron:'
- cat << _EOF_ > /etc/crontab
-#Please use dietpi-cron to change cron start times
+ G_ERROR_HANDLER_COMMAND='/etc/crontab'
+ cat << _EOF_ > $G_ERROR_HANDLER_COMMAND
+# Please use dietpi-cron to change cron start times
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-# m h dom mon dow user command
-#*/0 * * * * root cd / && run-parts --report /etc/cron.minutely
-17 * * * * root cd / && run-parts --report /etc/cron.hourly
-25 1 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
-47 1 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
-52 1 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
+# m h dom mon dow user command
+#*/0 * * * * root cd / && run-parts --report /etc/cron.minutely
+17 * * * * root cd / && run-parts --report /etc/cron.hourly
+25 1 * * * root test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.daily; }
+47 1 * * 7 root test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.weekly; }
+52 1 1 * * root test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.monthly; }
_EOF_
+ G_ERROR_HANDLER_EXITCODE=$?
+ G_ERROR_HANDLER
#-----------------------------------------------------------------------------------
#Network
- G_DIETPI-NOTIFY 2 'Configuring: prefer wlan/eth naming for networked devices:'
-
- # - Prefer to use wlan/eth naming for networked devices (eg: stretch)
- ln -sf /dev/null /etc/systemd/network/99-default.link
+ G_DIETPI-NOTIFY 2 'Configuring wlan/eth naming to be preferred for networked devices:'
+ ln -sfv /dev/null /etc/systemd/network/99-default.link
- G_DIETPI-NOTIFY 2 'Add dietpi.com SSH pub host key for DietPi-Survey and -Bugreport upload:'
+ G_DIETPI-NOTIFY 2 'Adding dietpi.com SSH pub host key for DietPi-Survey/Bugreport uploads:'
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_DIETPI-NOTIFY 2 'Recreate symlink for resolv.conf (DNS)'
- rm /etc/resolv.conf
- ln -sf /etc/resolvconf/run/resolv.conf /etc/resolv.conf
+ G_DIETPI-NOTIFY 2 'Recreating symlink for resolv.conf (DNS):'
+ echo 'nameserver 8.8.8.8' > /etc/resolvconf/run/resolv.conf # Temp apply, in case was not previously symlink, resets on next ifup.
+ ln -sfv /etc/resolvconf/run/resolv.conf /etc/resolv.conf
#-----------------------------------------------------------------------------------
#MISC
- if (( $G_DISTRO > 3 )); then
+ G_DIETPI-NOTIFY 2 'Disabling apt-daily services to prevent random APT cache lock'
- G_DIETPI-NOTIFY 2 'Disabling apt-daily services to prevent random APT cache lock'
+ for i in apt-daily.service apt-daily.timer apt-daily-upgrade.service apt-daily-upgrade.timer
+ do
- systemctl disable apt-daily.service &> /dev/null
- systemctl disable apt-daily.timer &> /dev/null
- systemctl disable apt-daily-upgrade.service &> /dev/null
- systemctl disable apt-daily-upgrade.timer &> /dev/null
- systemctl mask apt-daily.service &> /dev/null
- systemctl mask apt-daily.timer &> /dev/null
- systemctl mask apt-daily-upgrade.service &> /dev/null
- systemctl mask apt-daily-upgrade.timer &> /dev/null
+ systemctl stop $i &> /dev/null
+ systemctl disable $i &> /dev/null
+ systemctl mask $i &> /dev/null
- fi
+ done
local info_use_drive_manager='can be installed and setup by DietPi-Drive_Manager.\nSimply run: dietpi-drive_manager and select Add Network Drive'
echo -e "Samba client: $info_use_drive_manager" > /mnt/samba/readme.txt
@@ -1163,21 +1135,48 @@ _EOF_
/DietPi/dietpi/func/dietpi-logclear 2 &> /dev/null # As this will report missing vars, however, its fine, does not break functionality.
- l_message='Starting DietPi-RAMlog service' G_RUN_CMD systemctl start dietpi-ramlog.service
+ l_message='Starting DietPi-RAMlog service' G_RUN_CMD systemctl start dietpi-ramlog
G_DIETPI-NOTIFY 2 'Updating DietPi HW_INFO'
/DietPi/dietpi/func/dietpi-obtain_hw_model
- G_DIETPI-NOTIFY 2 'Configuring Network'
+ G_DIETPI-NOTIFY 2 'Configuring network interfaces:'
- rm -R /etc/network/interfaces &> /dev/null # armbian symlink for bulky network-manager
+ [[ -f /etc/network/interfaces ]] && rm -R /etc/network/interfaces # ARMbian symlink for bulky network-manager
- G_RUN_CMD cp /DietPi/dietpi/conf/network_interfaces /etc/network/interfaces
+ G_ERROR_HANDLER_COMMAND='/etc/network/interfaces'
+ cat << _EOF_ > $G_ERROR_HANDLER_COMMAND
+#/etc/network/interfaces
+#Please use DietPi-Config to modify network settings.
+
+# Local
+auto lo
+iface lo inet loopback
+
+# Ethernet
+#allow-hotplug eth0
+iface eth0 inet dhcp
+address 192.168.0.100
+netmask 255.255.255.0
+gateway 192.168.0.1
+#dns-nameservers 8.8.8.8 8.8.4.4
+
+# Wifi
+#allow-hotplug wlan0
+iface wlan0 inet dhcp
+address 192.168.0.100
+netmask 255.255.255.0
+gateway 192.168.0.1
+wireless-power off
+wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
+#dns-nameservers 8.8.8.8 8.8.4.4
+_EOF_
+ G_ERROR_HANDLER_EXITCODE=$?
+ G_ERROR_HANDLER
# - Remove all predefined eth*/wlan* adapter rules
- rm /etc/udev/rules.d/70-persistent-net.rules &> /dev/null
- rm /etc/udev/rules.d/70-persistant-net.rules &> /dev/null
+ rm -f /etc/udev/rules.d/70-persist*nt-net.rules
# Add pre-up lines for wifi on OrangePi Zero
if (( $G_HW_MODEL == 32 )); then
@@ -1192,7 +1191,7 @@ _EOF_
fi
# Fix rare WiFi interface start issue: https://github.com/Fourdee/DietPi/issues/2074
- sed -i '\|^[[:blank:]]ifconfig "$IFACE" up$|c\\t/sbin/ip link set dev "$IFACE" up' /etc/network/if-pre-up.d/wireless-tools &> /dev/null
+ [[ -f /etc/network/if-pre-up.d/wireless-tools ]] && sed -i '\|^[[:blank:]]ifconfig "$IFACE" up$|c\\t/sbin/ip link set dev "$IFACE" up' /etc/network/if-pre-up.d/wireless-tools
G_DIETPI-NOTIFY 2 'Tweaking DHCP timeout:'
@@ -1215,16 +1214,49 @@ _EOF_
echo 'DietPi' > /etc/hostname
- G_DIETPI-NOTIFY 2 'Configuring htop'
+ G_DIETPI-NOTIFY 2 'Configuring htop:'
- mkdir -p /root/.config/htop
- cp /DietPi/dietpi/conf/htoprc /root/.config/htop/htoprc
+ G_ERROR_HANDLER_COMMAND='/etc/htoprc'
+ cat << _EOF_ > $G_ERROR_HANDLER_COMMAND
+# DietPi default config for htop
+# Location: /etc/htoprc
+#
+# NB: htop will create "~/.config/htop/htoprc" based on this defaults, when opened the first time by per-user.
+# Use setup (F2) within htop GUI or edit "~/.config/htop/htoprc" to change settings for your user.
+fields=48 18 46 47 49 1
+sort_key=46
+sort_direction=1
+hide_threads=0
+hide_kernel_threads=1
+hide_userland_threads=1
+shadow_other_users=0
+show_thread_names=0
+highlight_base_name=1
+highlight_megabytes=1
+highlight_threads=0
+tree_view=0
+header_margin=1
+detailed_cpu_time=0
+cpu_count_from_zero=0
+color_scheme=0
+delay=15
+left_meters=AllCPUs Memory Swap
+left_meter_modes=1 1 1
+right_meters=Tasks LoadAverage Uptime
+right_meter_modes=2 2 2
+_EOF_
+ G_ERROR_HANDLER_EXITCODE=$?
+ G_ERROR_HANDLER
G_DIETPI-NOTIFY 2 'Configuring fake-hwclock:'
+ systemctl stop fake-hwclock
+
# - allow times in the past
G_CONFIG_INJECT 'FORCE=' 'FORCE=force' /etc/default/fake-hwclock
+ systemctl restart fake-hwclock #failsafe, apply now if date is way far back...
+
G_DIETPI-NOTIFY 2 'Configuring enable serial console:'
/DietPi/dietpi/func/dietpi-set_hardware serialconsole enable
@@ -1234,15 +1266,15 @@ _EOF_
systemctl mask getty-static
# - logind features disabled by default. Usually not needed and all features besides auto getty creation are not available without libpam-systemd package.
# - It will be unmasked/enabled, automatically if libpam-systemd got installed during dietpi-software install, usually with desktops.
- systemctl stop systemd-logind &> /dev/null
+ systemctl stop systemd-logind
systemctl disable systemd-logind &> /dev/null
systemctl mask systemd-logind
G_DIETPI-NOTIFY 2 'Configuring regional settings (TZdata):'
- rm /etc/timezone &> /dev/null
- rm /etc/localtime
- ln -fs /usr/share/zoneinfo/Europe/London /etc/localtime
+ [[ -f /etc/timezone ]] && rm /etc/timezone
+ [[ -f /etc/localtime ]] && rm /etc/localtime
+ ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime
G_RUN_CMD dpkg-reconfigure -f noninteractive tzdata
G_DIETPI-NOTIFY 2 'Configuring regional settings (Keyboard):'
@@ -1260,7 +1292,7 @@ _EOF_
# - i386 APT support
dpkg --add-architecture i386
- G_AGUP
+ #G_AGUP # Not required here, since this will be done on every update+install
# - Disable nouveau: https://github.com/Fourdee/DietPi/issues/1244 // https://dietpi.com/phpbb/viewtopic.php?f=11&t=2462&p=9688#p9688
cat << _EOF_ > /etc/modprobe.d/blacklist-nouveau.conf
@@ -1342,18 +1374,18 @@ blacklist videobuf2_vmalloc
blacklist bc_example
_EOF_
- #Sparky SBC, WiFi rtl8812au driver: https://github.com/sparky-sbc/sparky-test/tree/master/rtl8812au
+ # Sparky SBC, WiFi rtl8812au driver: https://github.com/sparky-sbc/sparky-test/tree/master/rtl8812au
G_RUN_CMD wget https://raw.githubusercontent.com/sparky-sbc/sparky-test/master/rtl8812au/rtl8812au_sparky.tar
mkdir -p rtl8812au_sparky
tar -xvf rtl8812au_sparky.tar -C rtl8812au_sparky
- chmod +x -R rtl8812au_sparky
+ chmod -R +x rtl8812au_sparky
cd rtl8812au_sparky
G_RUN_CMD ./install.sh
cd /tmp/$G_PROGRAM_NAME
rm -R rtl8812au_sparky*
# Use performance gov for stability.
- sed -i '/^[[:blank:]]*CONFIG_CPU_GOVERNOR=/c\CONFIG_CPU_GOVERNOR=performance' /DietPi/dietpi.txt
+ G_CONFIG_INJECT 'CONFIG_CPU_GOVERNOR=' 'CONFIG_CPU_GOVERNOR=performance' /DietPi/dietpi.txt
# - RPI:
elif (( $G_HW_MODEL < 10 )); then
@@ -1383,13 +1415,13 @@ _EOF_
#Rock64, remove HW accell config, as its not currently functional: https://github.com/Fourdee/DietPi/issues/2086
elif (( $G_HW_MODEL == 43 )); then
- rm /etc/X11/xorg.conf.d/20-armsoc.conf &> /dev/null
+ [[ -f /etc/X11/xorg.conf.d/20-armsoc.conf ]] && rm /etc/X11/xorg.conf.d/20-armsoc.conf
# - Odroids FFMPEG fix. Prefer debian.org over Meveric for backports: https://github.com/Fourdee/DietPi/issues/1273 + https://github.com/Fourdee/DietPi/issues/1556#issuecomment-369463910
elif (( $G_HW_MODEL > 9 && $G_HW_MODEL < 15 )); then
- rm /etc/apt/preferences.d/meveric*
- cat << _EOF_ > /etc/apt/preferences.d/backports
+ rm -f /etc/apt/preferences.d/meveric*
+ cat << _EOF_ > /etc/apt/preferences.d/dietpi-meveric-backports
Package: *
Pin: release a=jessie-backports
Pin: origin "fuzon.co.uk"
@@ -1404,7 +1436,7 @@ _EOF_
fi
# - ARMbian increase console verbose
- sed -i '/verbosity=/c\verbosity=7' /boot/armbianEnv.txt &> /dev/null
+ [[ -f /boot/armbianEnv.txt ]] && sed -i '/verbosity=/c\verbosity=7' /boot/armbianEnv.txt
#------------------------------------------------------------------------------------------------
@@ -1422,30 +1454,32 @@ _EOF_
/DietPi/dietpi/dietpi-services stop
/DietPi/dietpi/dietpi-services dietpi_controlled
+ G_DIETPI-NOTIFY 2 'Mask cron until 1st run setup is completed'
+
+ G_RUN_CMD systemctl mask cron
+
G_DIETPI-NOTIFY 2 'Running general cleanup of misc files'
- # - Remove Bash History file
- rm ~/.bash_history &> /dev/null
+ # - Remove Bash history file
+ [[ -f ~/.bash_history ]] && rm ~/.bash_history
+ rm -f /home/*/.bash_history
- # - Nano histroy file
- rm ~/.nano_history &> /dev/null
+ # - Remove Nano histroy file
+ [[ -f ~/.nano_history ]] && rm ~/.nano_history
+ rm -f /home/*/.nano_history
G_DIETPI-NOTIFY 2 'Removing swapfile from image'
/DietPi/dietpi/func/dietpi-set_dphys-swapfile 0 /var/swap
- rm /var/swap &> /dev/null # still exists on some images...
+ [[ -e /var/swap ]] && rm /var/swap # still exists on some images...
# - re-enable for next run
- sed -i '/AUTO_SETUP_SWAPFILE_SIZE=/c\AUTO_SETUP_SWAPFILE_SIZE=1' /DietPi/dietpi.txt
+ G_CONFIG_INJECT 'AUTO_SETUP_SWAPFILE_SIZE=' 'AUTO_SETUP_SWAPFILE_SIZE=1' /DietPi/dietpi.txt
G_DIETPI-NOTIFY 2 'Resetting boot.ini, config.txt, cmdline.txt etc'
# - PineA64 - delete ethaddr from uEnv.txt file
- if (( $G_HW_MODEL == 40 )); then
-
- sed -i '/^ethaddr/ d' /boot/uEnv.txt
-
- fi
+ (( $G_HW_MODEL == 40 )) && [[ -f /boot/uEnv.txt ]] && sed -i '/^ethaddr/ d' /boot/uEnv.txt
# - Set Pi cmdline.txt back to normal
[[ -f /boot/cmdline.txt ]] && sed -i 's/ rootdelay=10//g' /boot/cmdline.txt
@@ -1489,7 +1523,7 @@ _EOF_
fi
- # - Finalize GRUB
+ # - Finalise GRUB
if [[ -f '/etc/default/grub' ]]; then
G_CONFIG_INJECT 'GRUB_CMDLINE_LINUX_DEFAULT=' 'GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=0 quiet"' /etc/default/grub
@@ -1518,23 +1552,11 @@ _EOF_
/DietPi/dietpi/func/dietpi-logclear 2
- G_DIETPI-NOTIFY 2 'Deleting DietPi-RAMlog storage'
-
- rm -R /var/tmp/dietpi/logs/dietpi-ramlog_store/* &> /dev/null
-
G_DIETPI-NOTIFY 2 'Resetting DietPi generated globals/files'
rm /DietPi/dietpi/.??*
- G_DIETPI-NOTIFY 2 'Setting DietPi-Autostart to console'
-
- echo 0 > /DietPi/dietpi/.dietpi-autostart_index
-
- G_DIETPI-NOTIFY 2 'Creating our update file (used on 1st run to check for DietPi updates)'
-
- echo -1 > /DietPi/dietpi/.update_stage
-
- G_DIETPI-NOTIFY 2 'Set Init .install_stage to -1 (first boot)'
+ G_DIETPI-NOTIFY 2 'Set init .install_stage to -1 (first boot)'
echo -1 > /DietPi/dietpi/.install_stage
@@ -1543,22 +1565,34 @@ _EOF_
cat << _EOF_ > /DietPi/dietpi/.prep_info
$IMAGE_CREATOR
$PREIMAGE_INFO
+_EOF_
+
+ G_DIETPI-NOTIFY 2 'Generating GPL license readme'
+
+ cat << _EOF_ > /var/lib/dietpi/license.txt
+-----------------------
+DietPi - GPLv2 License:
+-----------------------
+ - Use arrow keys to scrolll
+ - Press 'TAB' then 'ENTER' to continue
+
+This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or any later version.
+
+This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along with this program. If not, please see http://www.gnu.org/licenses/'
_EOF_
G_DIETPI-NOTIFY 2 'Clearing APT cache'
G_RUN_CMD apt-get clean
- rm -R /var/lib/apt/lists/* -vf 2> /dev/null #lists cache: remove partial folder also, automatically gets regenerated on G_AGUP
+ rm -Rfv /var/lib/apt/lists/* # Clear APT cache, gets regenerated on G_AGUP
#rm /var/lib/dpkg/info/* #issue...
#dpkg: warning: files list file for package 'libdbus-1-3:armhf' missing; assuming package has no files currently installed
# - HW Specific
# RPi remove saved G_HW_MODEL , allowing obtain-hw_model to auto detect RPi model
- if (( $G_HW_MODEL < 10 )); then
-
- rm /etc/.dietpi_hw_model_identifier
-
- fi
+ (( $G_HW_MODEL < 10 )) && [[ -f /etc/.dietpi_hw_model_identifier ]] && rm /etc/.dietpi_hw_model_identifier
# - BBB remove fsexpansion: https://github.com/Fourdee/DietPi/issues/931#issuecomment-345451529
if (( $G_HW_MODEL == 71 )); then
@@ -1579,8 +1613,8 @@ _EOF_
chmod +x /DietPi/dietpi/.version
. /DietPi/dietpi/.version
- # reduce sub_version by 1, allows us to create image, prior to release and patch if needed.
- G_DIETPI_VERSION_SUB=$(( $G_DIETPI_VERSION_SUB - 1 ))
+ # Reduce sub_version by 1, allows us to create image, prior to release and patch if needed.
+ ((G_DIETPI_VERSION_SUB--))
G_CONFIG_INJECT 'DEV_GITBRANCH=' "DEV_GITBRANCH=$GITBRANCH" /DietPi/dietpi.txt
G_CONFIG_INJECT 'DEV_GITOWNER=' "DEV_GITOWNER=$GITOWNER" /DietPi/dietpi.txt
@@ -1593,35 +1627,43 @@ _EOF_
G_RUN_CMD systemctl stop dietpi-ramlog
G_RUN_CMD systemctl stop dietpi-ramdisk
- # - Clear tmp files on disk
- rm /var/tmp/dietpi/logs/* &> /dev/null
+ # - Clear DietPi logs, written during PREP
+ rm -Rf /var/tmp/dietpi/logs/{,.??,.[^.]}*
- # - Clear items that may have been left on disk, from previous PREP's
- rm -R /DietPi/* &> /dev/null
- cd /root
- umount /tmp; rm -R /tmp/* &> /dev/null
+ # - Clear items below mount points, e.g. from previous PREP's
+ umount /DietPi
+ rm -Rf /DietPi/{,.??,.[^.]}*
- sync
+ umount /var/log
+ rm -Rf /var/log/{,.??,.[^.]}*
+ mount /var/log # Prevent new log files from being written to disk by background processes
+
+ cd ~
+ umount /tmp
+ rm -Rf /tmp/{,.??,.[^.]}*
+ mount /tmp # Prevent new tmp files from being written to disk by background processes
# - Remove PREP script
- rm /root/PREP_SYSTEM_FOR_DIETPI.sh &> /dev/null
+ [[ -f $FP_PREP_SCRIPT ]] && rm $FP_PREP_SCRIPT
+
+ sync
- G_DIETPI-NOTIFY 2 "The used kernel version is: $(uname -r)"
- kernel_apt_packages="$(dpkg --get-selections | grep '^linux-image-[0-9]')"
+ G_DIETPI-NOTIFY 2 "The used kernel version is:\n\t - $(uname -a)"
+ kernel_apt_packages=$(dpkg -l | grep -E '[[:blank:]]linux-(image|dtb)-[0-9]')
if [[ $kernel_apt_packages ]]; then
- G_DIETPI-NOTIFY 2 'The following kernel APT packages have been found, please purge the outdated ones:'
+ G_DIETPI-NOTIFY 2 'The following kernel APT packages have been found, please purge outdated ones:'
echo "$kernel_apt_packages"
fi
G_DIETPI-NOTIFY 2 'Please delete outdated non-APT kernel modules:'
- ls -lh /lib/modules
+ ls -lAh /lib/modules
- G_DIETPI-NOTIFY 2 'Please check and delete all non-required folders in /root/.*:'
- ls -lha /root
+ G_DIETPI-NOTIFY 2 'Please check and delete all non-required home diretory content:'
+ ls -lAh /root /home/*/
- G_DIETPI-NOTIFY 0 'Completed, disk can now be saved to .img for later use, or, reboot system to start first run of DietPi:'
+ G_DIETPI-NOTIFY 0 'Completed, disk can now be saved to .img for later use, or, reboot system to start first run of DietPi.'
#Power off system
diff --git a/README.md b/README.md
index 2f1d432535..e5a6efebd0 100644
--- a/README.md
+++ b/README.md
@@ -1,47 +1,41 @@
-
-
-
-
- Lightweight justice for your single-board computer!
-
-
- optimised • simplified • for everyone
-
-
- find out more
- •
- download image
-
-
-
- Optional "ready to run" optimised software choices with dietpi-software.
-
- Feature rich configuration tool for your device with dietpi-config.
-
-
-
-
-
-
- DietPi's web hosting is powered by
- myVirtualServer.
-
-
- A wide range of SBCs and VMs are supported. Click here for the full list.
-
-
-
+
+
+
+
+ Lightweight justice for your single-board computer!
+
+ optimised • simplified • for everyone
+
+ find out more
+ •
+ download image
+
+
+
+ Optional "ready to run" optimised software choices with dietpi-software.
+
+ Feature rich configuration tool for your device with dietpi-config.
+
+
+
+
+
+ DietPi's web hosting is powered by
+ myVirtualServer.
+
+ A wide range of SBCs and VMs are supported. Click here for the full list.
+
+
## Introduction
-DietPi is an extremely lightweight Debian-based OS. With images starting at 400MB, that's 3x lighter than 'Raspbian Lite'. It is highly optimized for minimal CPU and RAM resource usage, ensuring your SBC always runs at its maximum potential. The programs use lightweight Whiptail menus. You'll spend less time staring at the command line, and more time enjoying DietPi.
+DietPi is an extremely lightweight Debian-based OS. With images starting at 400MB, that's 3x lighter than "Raspbian Lite". It is highly optimized for minimal CPU and RAM resource usage, ensuring your SBC always runs at its maximum potential. The programs use lightweight Whiptail menus. You'll spend less time staring at the command line, and more time enjoying DietPi.
-Use `dietpi-software` to quickly and easily install popular software that's "Ready to run" and optimized for your system. Only the software you need is installed. Use `dietpi-process_tool` to control which installed software has higher or lower priority levels (nice, affinity, policy scheduler).
-
-`dietpi-update` automatically checks for updates and informs you when they are available. Update instantly, without having to write a new image. `dietpi-automation` Allows you to completely automate a DietPi installation with no user input, simply by configuring dietpi.txt before powering on.
+Use `dietpi-software` to quickly and easily install popular software that's "Ready to run" and optimised for your system. Only the software you need is installed. Use `dietpi-process_tool` to control which installed software has higher or lower priority levels (nice, affinity, policy scheduler).
+`dietpi-update` automatically checks for updates and informs you when they are available. Update instantly, without having to write a new image. `dietpi-automation` Allows you to completely automate a DietPi installation with no user input, simply by configuring "dietpi.txt" before powering on.
## The DietPi Project Team
@@ -128,31 +122,37 @@ A personal thanks to **Pilovali** for helping DietPi during our early days with
## Contributing
-Git coders, please use the active development branch: [`dev`](https://github.com/Fourdee/DietPi/tree/dev)
+Git coders, please use the active development branch: [dev](https://github.com/Fourdee/DietPi/tree/dev)
-* [How to add new software installation options to DietPi-Software](https://github.com/Fourdee/DietPi/issues/490#issuecomment-244416570)
+- [How to add new software installation options to DietPi-Software](https://github.com/Fourdee/DietPi/issues/490#issuecomment-244416570)
Are you able to:
-* Provide feedback and/or test areas of DietPi, to improve the user experience?
-* Report bugs?
-* Improve/add more features to the [DietPi website](https://dietpi.com)?
-* Compile software for Odroid C1 and RPi systems?
-* Contribute to DietPi with programming on GitHub?
-* Suggest new software that we can add to the `dietpi-software` install system?
+- Provide feedback and/or test areas of DietPi, to improve the user experience?
+- Report bugs?
+- Improve/add more features to the [DietPi website](https://dietpi.com)?
+- Compile software for our supported SBCs?
+- Contribute to DietPi with programming on GitHub?
+- Suggest new software that we can add to the `dietpi-software` install system?
If so, let us know!
We are always looking for talented people who believe in the DietPi project, and, wish to contribute in any way you can.
-* Send me an Email: daniel.knight@dietpi.com
-* Join our forums: https://dietpi.com/phpbb
-* GitHub: https://github.com/Fourdee/DietPi
+- Send me an Email: daniel.knight@dietpi.com
+- Join our forums: https://dietpi.com/phpbb
+- GitHub: https://github.com/Fourdee/DietPi
+
+### FeatHub
+
+Vote for new suggestions, feature-, software- or image requests, or add your own to our new FeatHub page:
+
+[](http://feathub.com/Fourdee/DietPi)
## License
DietPi Copyright (C) 2016 Daniel Knight
-* Email daniel.knight@dietpi.com
-* Web https://dietpi.com
+- Email daniel.knight@dietpi.com
+- Web https://dietpi.com
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -175,11 +175,15 @@ along with this program. If not, see https://www.gnu.org/licenses/
### DietPi file list
-
-- All files located in `/DietPi/dietpi` (recursive)
+- All files located in (recursively):
+ - `/boot/dietpi/`
+ - `/DietPi/dietpi/`
+ - `/var/lib/dietpi/`
+ - `/var/tmp/dietpi/`
- `/DietPi/dietpi.txt`
-- `/DietPi/config.txt`
-- `/DietPi/boot.ini`
+- `/DietPi/config.txt` (RPi)
+- `/DietPi/boot.ini` (Odroid)
+- All files prefixed with: `dietpi-`
> The above GPLv2 documentation also applies to all mentioned files!
@@ -191,32 +195,33 @@ Links to additional software used in DietPi and their source and build instructi
- [Odroid](https://github.com/hardkernel?tab=repositories)
- [FriendlyARM](https://github.com/friendlyarm?tab=repositories)
- [LXDE](https://github.com/LXDE)
-- [Kodi / Xbmc](https://github.com/xbmc/xbmc)
+- [Kodi/XBMC](https://github.com/xbmc/xbmc)
- [Transmission](https://transmissionbt.com/download/)
- [Nextcloud](https://github.com/nextcloud/server)
- [ownCloud](https://github.com/owncloud/core)
- [MiniDLNA](https://sourceforge.net/p/minidlna/git/ci/master/tree/)
- [MPD](https://github.com/MusicPlayerDaemon/MPD)
- [YMPD](https://github.com/notandy/ympd)
-- [PHPBB](https://github.com/phpbb/phpbb)
+- [phpBB](https://github.com/phpbb/phpbb)
- [Apache2](https://github.com/apache)
- [MariaDB](https://github.com/MariaDB)
- [PHP](https://git.php.net/)
-- [PhpMyAdmin](https://github.com/phpmyadmin)
-- [Proftpd](https://github.com/proftpd)
+- [phpMyAdmin](https://github.com/phpmyadmin)
+- [ProFTPD](https://github.com/proftpd)
- [Samba](https://wiki.samba.org/index.php/Using_Git_for_Samba_Development)
-- [NoIp2 Client Binary](https://www.noip.com/support/knowledgebase/installing-the-linux-dynamic-update-client/)
+- [No-IP Client Binary](https://www.noip.com/support/knowledgebase/installing-the-linux-dynamic-update-client/)
- [RetroPie Setup Script](https://github.com/petrockblog/RetroPie-Setup)
- [PiVPN VPN Server](https://github.com/pivpn/pivpn)
- [OpenTyrian](https://bitbucket.org/opentyrian/opentyrian/wiki/Home)
- [DietPiCam](https://github.com/Fourdee/RPi_Cam_Web_Interface)
- [PHP OPcache GUI](https://github.com/amnuts/opcache-gui)
- [Nginx](https://hg.nginx.org/nginx/)
+- [Lighttpd](https://redmine.lighttpd.net/projects/lighttpd/repository)
- [Deluge](https://dev.deluge-torrent.org/wiki/Development#SourceCode)
-- [Grasshopper](https://sourceforge.net/projects/grasshopperwebapp/Grasshopper)
- [Pi-hole](https://github.com/pi-hole/pi-hole)
-- [SubSonic](https://sourceforge.net/projects/subsonic/)
-- [SqueezeBox](https://github.com/Logitech/slimserver)
+- [Subsonic](https://sourceforge.net/projects/subsonic/)
+- [Airsonic](https://github.com/airsonic/airsonic)
+- [LMS/SqueezeBox](https://github.com/Logitech/slimserver)
- [Ampache](https://github.com/ampache/ampache)
- [FFmpeg](https://github.com/FFmpeg/FFmpeg)
- [CertBot](https://github.com/certbot/certbot)
@@ -225,3 +230,5 @@ Links to additional software used in DietPi and their source and build instructi
- [FreshRSS](https://github.com/FreshRSS/FreshRSS)
- [Folding@Home](https://github.com/FoldingAtHome)
- [OpenBazaar](https://github.com/OpenBazaar/openbazaar-go)
+- [Medusa](https://github.com/pymedusa/Medusa)
+- [Grafana](https://github.com/grafana/grafana)
diff --git a/boot_c1.ini b/boot_c1.ini
index c5fbeb82d8..e36cda9466 100644
--- a/boot_c1.ini
+++ b/boot_c1.ini
@@ -1,3 +1,7 @@
+# IMPORTANT:
+# - Modifications to /boot/boot.ini will not be preserved on reboot.
+# - Please ensure you edit from the DietPi-RAMdisk location: /DietPi/boot.ini
+
ODROIDC-UBOOT-CONFIG
setenv m "720p"
diff --git a/boot_c2.ini b/boot_c2.ini
index f2871cf8ca..47264489ea 100644
--- a/boot_c2.ini
+++ b/boot_c2.ini
@@ -1,5 +1,6 @@
-#Modifcations to /boot/* files, will not be saved when powered on.
-#Please ensure you edit from the DietPi-RamDisk location /DietPi/*
+# IMPORTANT:
+# - Modifications to /boot/boot.ini will not be preserved on reboot.
+# - Please ensure you edit from the DietPi-RAMdisk location: /DietPi/boot.ini
ODROIDC2-UBOOT-CONFIG
diff --git a/boot_xu4.ini b/boot_xu4.ini
index 223c918204..bc354c2c29 100644
--- a/boot_xu4.ini
+++ b/boot_xu4.ini
@@ -1,3 +1,7 @@
+# IMPORTANT:
+# - Modifications to /boot/boot.ini will not be preserved on reboot.
+# - Please ensure you edit from the DietPi-RAMdisk location: /DietPi/boot.ini
+
ODROIDXU-UBOOT-CONFIG
# U-Boot Parameters
diff --git a/config.txt b/config.txt
index fe5567ea73..210c378ceb 100644
--- a/config.txt
+++ b/config.txt
@@ -1,80 +1,86 @@
-#Modifcations to /boot/* files, will not be saved when powered on.
-#Please ensure you edit from the DietPi-RamDisk location /DietPi/*
+# IMPORTANT:
+# - Modifications to /boot/config.txt will not be preserved on reboot.
+# - Please ensure you edit from the DietPi-RAMdisk location: /DietPi/config.txt
-# uncomment if you get no picture on HDMI for a default "safe" mode
+#-------Display---------
+# If you get no picture, set the following to "1" to apply most compatible HDMI settings.
#hdmi_safe=1
-# Set to 1 if your display has a black border of unused pixels visible
-disable_overscan=1
+# Uncomment to adjust the HDMI signal strength if you have interferences, blanking, or no display.
+# - Values from "0" to "11" are allowed, use values above "7" only if required, e.g. with very long HDMI cable.
+# - Default on first RPi1 is "2" and on RPi2 and above: "5"
+#config_hdmi_boost=5
-# uncomment the following to adjust overscan. Use positive numbers if console
-# goes off screen, and negative if there is too much border
-#overscan_left=16
-#overscan_right=16
-#overscan_top=16
-#overscan_bottom=16
+# Uncomment if HDMI display is not detected and composite is being outputted.
+#hdmi_force_hotplug=1
-# uncomment to force a console size. By default it will be display's size minus overscan
-framebuffer_width=1280
-framebuffer_height=720
+# Set the following two settings to "1" to disable video output and framebuffer completely.
+# NB: This will lead to some error messages on boot, which can be safely ignored.
+#hdmi_ignore_hotplug=1
+#hdmi_ignore_composite=1
+
+# Uncomment to force a console size. By default it will be display's size minus overscan.
+#framebuffer_width=1280
+#framebuffer_height=720
#framebuffer_depth=16
# SDTV_MODES
#sdtv_mode=0
-# Rotation
-display_rotate=0
-lcd_rotate=0
-
-# uncomment if HDMI display is not detected and composite is being outputted
-#hdmi_force_hotplug=1
-
-# uncomment to force a specific HDMI mode (this will force VGA)
+# Uncomment to force a specific HDMI mode (this will force VGA).
#hdmi_group=1
#hdmi_mode=1
-# uncomment to force an HDMI mode rather than DVI. This can make audio work in
-# DMT (computer monitor) modes
+# Uncomment to force an HDMI mode rather than DVI. This can make audio work in DMT (computer monitor) modes.
#hdmi_drive=2
-# uncomment to increase the signal to HDMI if you have interference, blanking, or
-# no display
-#config_hdmi_boost=4
+# Set "hdmi_blanking=1" to allow the display going into standby after 10 minutes without input.
+# With default value "0", the display shows a blank screen instead, but will not go into standby.
+# NB: With "1" some applications (e.g. Kodi, OMXPlayer) cannot prevent display standby due to missing DPMS signal.
+#hdmi_blanking=1
-#-------RPi Camera Module-------
+# Set to "1" if your display has a black border of unused pixels visible.
+disable_overscan=1
+
+# Uncomment the following to adjust overscan. Use positive numbers if console goes off screen, and negative if there is too much border.
+#overscan_left=16
+#overscan_right=16
+#overscan_top=16
+#overscan_bottom=16
+
+# Rotation
+display_hdmi_rotate=0
+lcd_rotate=0
+
+#-------RPi camera module-------
start_x=0
disable_camera_led=0
-#-------GPU memory Splits-------
+#-------GPU memory splits-------
gpu_mem_256=16
gpu_mem_512=16
gpu_mem_1024=16
-#-------Max USB Current -------
+#-------Max USB current---------
max_usb_current=1
-#-------Disable Ram temp refresh every 500ms---------------
-disable_pvt=1
-
-#-------Disable Pi Splash screen on boot-------------
+#-------Disable Pi splash screen on boot-----------
disable_splash=1
-#-------Remove dedicated pll for PWM audio -------
-avoid_pwm_pll=1
-
#-------SoundCard-------
dtparam=audio=off
-#-------i2c-------------
+#-------I²C-------------
dtparam=i2c_arm=off
dtparam=i2c1=off
i2c_arm_baudrate=100000
-#-------spi-------------
+#-------SPI-------------
dtparam=spi=off
#-------Serial/UART-----
-# NB: enabled for the 1st run only, if you want to keep this setting, please set CONFIG_SERIAL_CONSOLE_ENABLE=1 in dietpi.txt
+# NB: Enabled for 1st run only, if you want to keep this setting, please set CONFIG_SERIAL_CONSOLE_ENABLE=1 in /DietPi/dietpi.txt.
+# NB: "enable_uart=1" will forcefully set "core_freq=250" unless "force_turbo=1" is set as well.
enable_uart=1
#-------Overclock-------
diff --git a/dietpi.txt b/dietpi.txt
index 8246bde0c5..15fde0bb79 100644
--- a/dietpi.txt
+++ b/dietpi.txt
@@ -1,8 +1,9 @@
-#Modifications to /boot/* files, will not be saved when powered on.
-#Please ensure you edit from the DietPi-RamDisk location /DietPi/*
+# IMPORTANT:
+# - Modifications to /boot/dietpi.txt will not be preserved on reboot.
+# - Please ensure you edit from the DietPi-RAMdisk location: /DietPi/dietpi.txt
-#NB: This is intended for advanced users, unless you know what you are doing, do not edit this file. Please use the DietPi programs instead.
-#NB: Do not remove uncommented lines, as the items are scraped by DietPi programs, on demand.
+# NB: This is intended for advanced users, unless you know what you are doing, do not edit this file. Please use the DietPi programs instead.
+# NB: Do not remove uncommented lines, as the items are scraped by DietPi programs, on demand.
#------------------------------------------------------------------------------------------------------
# D I E T - P I
@@ -122,12 +123,14 @@ AUTO_SETUP_KEYBOARD_LAYOUT=gb
# NB: Executed script log /var/tmp/dietpi/logs/dietpi-automation_custom_script.log
AUTO_SETUP_CUSTOM_SCRIPT_EXEC=0
+#Disable HDMI (and GPU/VPU where supported) output for supported devices:
+# RPi | Odroid C1 | Odroid C2
+AUTO_SETUP_HEADLESS=0
+
#------------------------------------------------------------------------------------------------------
# D I E T - P I
# DietPi-Config settings
#------------------------------------------------------------------------------------------------------
-#RPi HDMI output (if 0, sets tvservice -o and framebuffer 16x 16y 8z on boot, headless)
-CONFIG_HDMI_OUTPUT=1
#Cpu Governor | ondemand | powersave | performance | conservative
CONFIG_CPU_GOVERNOR=ondemand
@@ -163,6 +166,8 @@ CONFIG_BOOT_WAIT_FOR_NETWORK=1
#DietPi checks for updates (allows dietpi to check for updates on a daily basis and boot using a <1kb file download.)
CONFIG_CHECK_DIETPI_UPDATES=1
+# Optional: Automatically update DietPi when updates are available. | requires CONFIG_CHECK_DIETPI_UPDATES=1
+CONFIG_AUTO_DIETPI_UPDATES=0
#NTPD Update Mode: 0=disabled | 1=boot only | 2=boot + daily | 3=boot + hourly | 4=Daemon + Drift
CONFIG_NTP_MODE=2
@@ -170,10 +175,8 @@ CONFIG_NTP_MODE=2
#WiFi country code. 2 character value (eg GB US DE JP): https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
CONFIG_WIFI_COUNTRY_CODE=GB
-#Serial Console: Set to 1 if you require a serial console.
-# NB: Serial console is always enabled by default for 1st run setup, then disabled afterwards, unless set below.
-# NB: must be ENABLED for the following boards: Odroid XU4/HC1/HC2, RockPro64
-CONFIG_SERIAL_CONSOLE_ENABLE=0
+#Serial Console: Set to 0 if you do not require serial console.
+CONFIG_SERIAL_CONSOLE_ENABLE=1
#Soundcard
CONFIG_SOUNDCARD=none
diff --git a/dietpi/.dietpi-autostart_index b/dietpi/.dietpi-autostart_index
deleted file mode 100644
index 573541ac97..0000000000
--- a/dietpi/.dietpi-autostart_index
+++ /dev/null
@@ -1 +0,0 @@
-0
diff --git a/dietpi/.update_stage b/dietpi/.update_stage
deleted file mode 100644
index 3a2e3f4984..0000000000
--- a/dietpi/.update_stage
+++ /dev/null
@@ -1 +0,0 @@
--1
diff --git a/dietpi/.version b/dietpi/.version
index c1f8f6aaba..0013468351 100644
--- a/dietpi/.version
+++ b/dietpi/.version
@@ -1,6 +1,6 @@
#!/bin/bash
G_DIETPI_VERSION_CORE=6
-G_DIETPI_VERSION_SUB=19
+G_DIETPI_VERSION_SUB=20
G_DIETPI_VERSION_RC=0
G_GITBRANCH='master'
G_GITOWNER='Fourdee'
diff --git a/dietpi/boot b/dietpi/boot
index fe6188404c..10fbb0ab3f 100644
--- a/dietpi/boot
+++ b/dietpi/boot
@@ -124,7 +124,7 @@ _EOF_
#----------------------------------------------------------------
# Pre-installed image, 1st run
- if (( $G_DIETPI_INSTALL_STAGE == 2 )); then
+ if (( $G_DIETPI_INSTALL_STAGE == 10 )); then
# - Set swap
/DietPi/dietpi/func/dietpi-set_dphys-swapfile $(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_SIZE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//') "$(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=' /DietPi/dietpi.txt | sed 's/.*=//')"
@@ -134,33 +134,26 @@ _EOF_
/DietPi/dietpi/dietpi-survey 1 &> /dev/null &
# - Continue with normal boot
- G_DIETPI_INSTALL_STAGE=1
+ G_DIETPI_INSTALL_STAGE=2
echo $G_DIETPI_INSTALL_STAGE > /DietPi/dietpi/.install_stage
fi
# Normal boot
- if (( $G_DIETPI_INSTALL_STAGE == 1 )); then
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )); then
# - Run time sync
/DietPi/dietpi/func/run_ntpd 1 &> /dev/null &
- # - Check for updates
- if grep -qi '^[[:blank:]]*CONFIG_CHECK_DIETPI_UPDATES=1' /DietPi/dietpi.txt; then
-
- /DietPi/dietpi/dietpi-update 2 &> /dev/null &
-
- fi
-
- #----------------------------------------------------------------
# First run prep
elif (( $G_DIETPI_INSTALL_STAGE == -1 )); then
# - Activate and apply any 1st run settings
Apply_DietPi_FirstRun_Settings
- # - Set Install stage index to trigger DietPi-Software installation on login
- echo 0 > /DietPi/dietpi/.install_stage
+ # - Set Install stage index to trigger DietPi-Update 1st run on login
+ G_DIETPI_INSTALL_STAGE=0
+ echo $G_DIETPI_INSTALL_STAGE > /DietPi/dietpi/.install_stage
fi
diff --git a/dietpi/conf/htoprc b/dietpi/conf/htoprc
deleted file mode 100644
index 7f973d9060..0000000000
--- a/dietpi/conf/htoprc
+++ /dev/null
@@ -1,26 +0,0 @@
-# ~/.config/htop/htoprc
-# DietPi Config File for Htop
-#
-# Beware! This file is rewritten by htop when settings are changed in the interface.
-# The parser is also very primitive, and not human-friendly.
-fields=48 18 46 47 49 1
-sort_key=46
-sort_direction=1
-hide_threads=0
-hide_kernel_threads=1
-hide_userland_threads=1
-shadow_other_users=0
-show_thread_names=0
-highlight_base_name=1
-highlight_megabytes=1
-highlight_threads=0
-tree_view=0
-header_margin=1
-detailed_cpu_time=0
-cpu_count_from_zero=0
-color_scheme=0
-delay=15
-left_meters=AllCPUs Memory Swap
-left_meter_modes=1 1 1
-right_meters=Tasks LoadAverage Uptime
-right_meter_modes=2 2 2
diff --git a/dietpi/conf/network_interfaces b/dietpi/conf/network_interfaces
deleted file mode 100644
index 81f4aa6a1e..0000000000
--- a/dietpi/conf/network_interfaces
+++ /dev/null
@@ -1,24 +0,0 @@
-#/etc/network/interfaces
-#Please use DietPi-Config to modify network settings.
-
-# Local
-auto lo
-iface lo inet loopback
-
-# Ethernet
-#allow-hotplug eth0
-iface eth0 inet dhcp
-address 192.168.0.100
-netmask 255.255.255.0
-gateway 192.168.0.1
-#dns-nameservers 8.8.8.8 8.8.4.4
-
-# Wifi
-#allow-hotplug wlan0
-iface wlan0 inet dhcp
-address 192.168.0.100
-netmask 255.255.255.0
-gateway 192.168.0.1
-wireless-power off
-wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
-#dns-nameservers 8.8.8.8 8.8.4.4
diff --git a/dietpi/dietpi-autostart b/dietpi/dietpi-autostart
index c20c3385bd..fb5a45005c 100644
--- a/dietpi/dietpi-autostart
+++ b/dietpi/dietpi-autostart
@@ -25,7 +25,7 @@
#Grab Input (valid interger)
INPUT=-1
- disable_error=1 G_CHECK_VALIDINT $1 && INPUT=$1
+ disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1
#/////////////////////////////////////////////////////////////////////////////////////
# MENUS
@@ -36,26 +36,32 @@
Apply_Boot_Index(){
- #Always disable LightDM
- systemctl disable lightdm.service &> /dev/null
+ # - Always disable LightDM
+ systemctl disable lightdm &> /dev/null
# - Amiberry | always disable services, service launched by DietPi/login if non fastboot mode
- systemctl disable amiberry.service &> /dev/null
+ systemctl disable amiberry &> /dev/null
if (( $G_HW_MODEL < 10 )); then
- sed -i '/^boot_delay=0/d' /DietPi/config.txt
- sed -i 's/logo.nologo//' /boot/cmdline.txt
- sed -i 's/loglevel=3//' /boot/cmdline.txt
+ sed -i '/^[[:blank:]]*boot_delay=0/d' /DietPi/config.txt
+ sed -i 's/[[:blank:]]*logo.nologo//' /boot/cmdline.txt
+ sed -i 's/[[:blank:]]*loglevel=3//' /boot/cmdline.txt
sed -i 's/console=tty3/console=tty1/' /boot/cmdline.txt
fi
# - Disable custom launch service
- rm /etc/systemd/system/dietpi-autostart_custom.service &> /dev/null
+ [[ -f /etc/systemd/system/dietpi-autostart_custom.service ]] && rm /etc/systemd/system/dietpi-autostart_custom.service
# - Disable auto login
- rm /etc/systemd/system/getty@tty1.service.d/autologin.conf &> /dev/null
+ local fp_svc='/etc/systemd/system/getty@tty1.service.d'
+ if [[ -d $fp_svc ]]; then
+
+ [[ -f $fp_svc/dietpi-autologin.conf ]] && rm $fp_svc/dietpi-autologin.conf
+ [[ $(ls -A $fp_svc) ]] || rmdir $fp_svc
+
+ fi
#----------------------------------------------------------------------
#Enable autoboot options
@@ -64,67 +70,58 @@
cat << _EOF_ > /etc/systemd/system/dietpi-autostart_custom.service
[Unit]
-Description=DietPi autostart (Custom /var/lib/dietpi/dietpi-autostart/custom.sh)
+Description=DietPi-Autostart (Custom /var/lib/dietpi/dietpi-autostart/custom.sh)
After=dietpi-boot.service dietpi-ramdisk.service dietpi-ramlog.service dietpi-postboot.service rc-local.service
Requires=dietpi-boot.service dietpi-ramdisk.service
[Service]
Type=idle
-ExecStartPre=/bin/bash -c 'echo -e "Starting DietPi-Autostart (Custom) script"'
-ExecStartPre=$(which chmod) +x /var/lib/dietpi/dietpi-autostart/custom.sh
-ExecStart=/bin/bash -c /var/lib/dietpi/dietpi-autostart/custom.sh
+ExecStartPre=$(command -v echo) 'Starting DietPi-Autostart (Custom) script'
+ExecStartPre=$(command -v chmod) +x /var/lib/dietpi/dietpi-autostart/custom.sh
+ExecStart=/var/lib/dietpi/dietpi-autostart/custom.sh
StandardOutput=tty
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
_EOF_
- systemctl enable dietpi-autostart_custom.service
+
+ systemctl enable dietpi-autostart_custom
# Uae4arm special | fast boot via enabled service
elif (( $AUTO_START_INDEX == 6 )); then
- systemctl enable amiberry.service
+ systemctl enable amiberry
# - apply tweaks
if (( $G_HW_MODEL < 10 )); then
G_CONFIG_INJECT 'boot_delay=' 'boot_delay=0' /DietPi/config.txt
-
- if ! grep -qi ' logo.nologo' /boot/cmdline.txt; then
-
- sed -i 's/rootwait/rootwait logo.nologo/' /boot/cmdline.txt
-
- fi
-
- if ! grep -qi ' loglevel=3' /boot/cmdline.txt; then
-
- sed -i 's/rootwait/rootwait loglevel=3/' /boot/cmdline.txt
-
- fi
-
- if ! grep -qi ' console=tty3' /boot/cmdline.txt; then
-
- sed -i 's/console=tty1/console=tty3/' /boot/cmdline.txt
-
- fi
+ grep -qi ' logo.nologo' /boot/cmdline.txt || sed -i 's/rootwait/rootwait logo.nologo/' /boot/cmdline.txt
+ grep -qi ' loglevel=3' /boot/cmdline.txt || sed -i 's/rootwait/rootwait loglevel=3/' /boot/cmdline.txt
+ grep -qi ' console=tty3' /boot/cmdline.txt || sed -i 's/console=tty1/console=tty3/' /boot/cmdline.txt
fi
# Enable auto login
elif (( $AUTO_START_INDEX > 0 )); then
- mkdir -p /etc/systemd/system/getty@tty1.service.d &> /dev/null
- cat << _EOF_ > /etc/systemd/system/getty@tty1.service.d/autologin.conf
+ mkdir -p /etc/systemd/system/getty@tty1.service.d
+ cat << _EOF_ > /etc/systemd/system/getty@tty1.service.d/dietpi-autologin.conf
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin root %I $TERM
_EOF_
+ else
+
+ [[ -f /DietPi/dietpi/.dietpi-autostart_index ]] && rm /DietPi/dietpi/.dietpi-autostart_index
+ [[ -f /boot/dietpi/.dietpi-autostart_index ]] && rm /boot/dietpi/.dietpi-autostart_index
+
fi
- #Save boot index.
- echo $AUTO_START_INDEX > /DietPi/dietpi/.dietpi-autostart_index
+ #Save boot index, if not default 0
+ (( $AUTO_START_INDEX )) && echo $AUTO_START_INDEX > /DietPi/dietpi/.dietpi-autostart_index
systemctl daemon-reload
@@ -134,7 +131,7 @@ _EOF_
Menu_Main(){
#existing boot flag
- AUTO_START_INDEX=$( /dev/null; then
Error_Rsync_Already_Running
@@ -174,7 +177,7 @@ _EOF_
#Generate Exclude/Include lists
Create_Filter_Include_Exclude
- while true
+ while :
do
# - system
@@ -183,12 +186,12 @@ _EOF_
# - - Check for sufficient free space
# NB: working in KiB until end MiB conversion, as, don't like using long long int, and, KiB should offer a good end result.
- local old_backup_size=$(du -ks "$FP_TARGET_BACKUP"/data | awk '{print $1}')
+ local old_backup_size=$(du -ks "$FP_TARGET_BACKUP"/data | mawk '{print $1}')
rsync --dry-run --stats $RSYNC_RUN_OPTIONS_BACKUP "$FP_SOURCE" "$FP_TARGET_BACKUP"/data/ > /tmp/dietpi-backup_result
local new_backup_size=$(( $(grep -m1 'Total file size' /tmp/dietpi-backup_result | sed 's/[^0-9]*//g') / 1024 ))
- local total_file_count=$(( $(grep -m1 'Number of files' /tmp/dietpi-backup_result | awk '{print $6}' | sed 's/[^0-9]*//g') ))
- local total_folder_count=$(( $(grep -m1 'Number of files' /tmp/dietpi-backup_result | awk '{print $8}' | sed 's/[^0-9]*//g') ))
+ local total_file_count=$(( $(mawk '/Number of files/ {print $6;exit}' /tmp/dietpi-backup_result | sed 's/[^0-9]*//g') ))
+ local total_folder_count=$(( $(mawk '/Number of files/ {print $8;exit}' /tmp/dietpi-backup_result | sed 's/[^0-9]*//g') ))
local target_fs_blocksize=$(stat -fc %s "$FP_TARGET_BACKUP"/data)
new_backup_size=$(( $new_backup_size + ( $total_file_count + $total_folder_count ) * $target_fs_blocksize / 1024 ))
local end_result=$(( ( $new_backup_size - $old_backup_size ) / 1024 + 1 ))
@@ -265,7 +268,7 @@ _EOF_
G_WHIP_MSG "$RSYNC_MODE_TEXT Failed:\n\n$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME does not exist\n\nHave you created a backup?"
#Error: Rsync is already running
- elif (( $(ps aux | grep -ci -m1 "[r]sync") )); then
+ elif pgrep 'rsync' &> /dev/null; then
Error_Rsync_Already_Running
@@ -329,7 +332,7 @@ _EOF_
fi
- TARGET_FILESYSTEM_TYPE="$( df -T $FP_TARGET_BACKUP | sed -n '2p' | awk '{print $2}')"
+ TARGET_FILESYSTEM_TYPE="$( df -T $FP_TARGET_BACKUP | sed -n '2p' | mawk '{print $2}')"
for ((i=0; i<${#aSUPPORTED_FILESYSTEMS[@]}; i++))
do
@@ -381,11 +384,7 @@ _EOF_
Read_Settings_File(){
- if [[ -f $FP_DIETPIBACKUP_SETTINGS ]]; then
-
- . $FP_DIETPIBACKUP_SETTINGS
-
- fi
+ [[ -f $FP_DIETPIBACKUP_SETTINGS ]] && . $FP_DIETPIBACKUP_SETTINGS
}
@@ -418,12 +417,11 @@ _EOF_
G_WHIP_MENU_ARRAY+=('Backup' 'Create (or update) a backup of this device.')
G_WHIP_MENU_ARRAY+=('Restore' 'Restore this device from a previous backup.')
- G_WHIP_DEFAULT_ITEM="$MENU_LASTITEM"
+ G_WHIP_DEFAULT_ITEM=$MENU_LASTITEM
G_WHIP_BUTTON_CANCEL_TEXT='Exit'
- G_WHIP_MENU "Current backup and restore location:\n - $FP_TARGET_BACKUP\n - $backup_last_completed"
- if (( $? == 0 )); then
+ if G_WHIP_MENU "Current backup and restore location:\n - $FP_TARGET_BACKUP\n - $backup_last_completed"; then
- MENU_LASTITEM="$G_WHIP_RETURNED_VALUE"
+ MENU_LASTITEM=$G_WHIP_RETURNED_VALUE
case "$G_WHIP_RETURNED_VALUE" in
@@ -447,8 +445,7 @@ _EOF_
'Delete')
- G_WHIP_YESNO "Do you wish to DELETE the following backup?\n - $FP_TARGET_BACKUP"
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Do you wish to DELETE the following backup?\n - $FP_TARGET_BACKUP"; then
rm -R "$FP_TARGET_BACKUP"
@@ -459,22 +456,14 @@ _EOF_
'Backup')
G_WHIP_YESNO "The $text_start_mode_desc will be backed up to:\n$FP_TARGET_BACKUP\n\nDo you wish to continue and start the backup?"
- if (( $? == 0 )); then
-
- Run_Backup
-
- fi
+ (( $? == 0 )) && Run_Backup
;;
'Restore')
G_WHIP_YESNO "The $text_start_mode_desc will be restored from:\n$FP_TARGET_BACKUP\n\nDo you wish to continue and start the restore?"
- if (( $? == 0 )); then
-
- Run_Restore
-
- fi
+ (( $? == 0 )) && Run_Restore
;;
@@ -491,8 +480,7 @@ _EOF_
Menu_Exit(){
G_WHIP_SIZE_X_MAX=50
- G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"; then
EXIT_CODE=0
TARGETMENUID=-1
@@ -508,9 +496,9 @@ _EOF_
G_WHIP_MENU_ARRAY=(
- 'Search' 'Find previous backups in /mnt/*'
- 'List' 'Select from a list of available mounts/drives'
- 'Manual' 'Manually type a directory to use.'
+ 'Search' ': Find previous backups in /mnt/*'
+ 'List' ': Select from a list of available mounts/drives'
+ 'Manual' ': Manually type a directory to use'
)
@@ -521,14 +509,14 @@ _EOF_
'Search')
- local fp_search_results="/tmp/.dietpi-backup_search_results"
+ local fp_search_results='.dietpi-backup_search_results'
echo -e "\n\nSearching /mnt/* for previous backups, please wait... \n \n"
- find /mnt -type f -name "$BACKUP_STATS_FILENAME" > "$fp_search_results"
+ find /mnt -type f -name "$BACKUP_STATS_FILENAME" > $fp_search_results
#Do we have any results?
- if (( $(cat "$fp_search_results" | wc -l) > 0 )); then
+ if (( $(wc -l < $fp_search_results) )); then
- readarray search_results_list < "$fp_search_results"
+ readarray search_results_list < $fp_search_results
#Create List for Whiptail
G_WHIP_MENU_ARRAY=()
for ((i=0; i<${#search_results_list[@]}; i++))
@@ -540,16 +528,15 @@ _EOF_
done
- G_WHIP_MENU 'Please select a previous backup to use:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a previous backup to use:'; then
- FP_TARGET_BACKUP="$G_WHIP_RETURNED_VALUE"
+ FP_TARGET_BACKUP=$G_WHIP_RETURNED_VALUE
fi
#delete[] array
unset search_results_list
- rm "$fp_search_results" &> /dev/null
+ [[ -f $fp_search_results ]] && rm $fp_search_results
else
@@ -568,13 +555,9 @@ _EOF_
'List')
/DietPi/dietpi/dietpi-drive_manager 1
- FP_TARGET_BACKUP="$(cat /tmp/dietpi-drive_manager_selmnt)"
- if [[ $FP_TARGET_BACKUP == '/' ]]; then
-
- FP_TARGET_BACKUP='/mnt'
-
- fi
+ FP_TARGET_BACKUP=$(> "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME"
@@ -657,11 +632,7 @@ _EOF_
Read_Settings_File
# $2 Optional directory input.
- if [[ -n $2 ]]; then
-
- FP_TARGET_BACKUP=$2
-
- fi
+ [[ $2 ]] && FP_TARGET_BACKUP=$2
#Create user inc/exc templates
# - Add users filter list
@@ -719,13 +690,6 @@ _EOF_
Write_Settings_File
fi
-
- #-----------------------------------------------------------------------------------
- #Cleaup left over tmp files
- rm $FP_FILTER_INCLUDE_EXCLUDE &> /dev/null
- #-----------------------------------------------------------------------------------
- #delete[] array
- unset aSUPPORTED_FILESYSTEMS
#-----------------------------------------------------------------------------------
exit $EXIT_CODE
#-----------------------------------------------------------------------------------
diff --git a/dietpi/dietpi-bugreport b/dietpi/dietpi-bugreport
index f694afee1c..8d26806ed7 100644
--- a/dietpi/dietpi-bugreport
+++ b/dietpi/dietpi-bugreport
@@ -59,7 +59,10 @@
'locale'
'ls -lha /mnt' #dietpi userdata location
'dmesg'
+ 'uname -a'
'lsmod'
+ 'aplay -l'
+ 'aplay -L'
"systemctl status *.service -l"
"systemctl status *.mount -l"
'/DietPi/dietpi/dietpi-services status'
@@ -225,17 +228,17 @@ The file will be removed after your issue is solved and you can remove it by you
Would you like to send a bug report archive or remove an already uploaded one?"
if (( ! $? )); then
- if (( G_WHIP_RETURNED_VALUE == 1 )); then
+ if (( $G_WHIP_RETURNED_VALUE == 1 )); then
INPUT=1
break
- elif (( G_WHIP_RETURNED_VALUE == 2 )); then
+ elif (( $G_WHIP_RETURNED_VALUE == 2 )); then
INPUT=-1
break
- elif (( G_WHIP_RETURNED_VALUE == 3 )); then
+ elif (( $G_WHIP_RETURNED_VALUE == 3 )); then
G_WHIP_SCROLLBOX "The upload will contain the following command outputs:
diff --git a/dietpi/dietpi-cleaner b/dietpi/dietpi-cleaner
index bb8fa3e389..07ed115228 100644
--- a/dietpi/dietpi-cleaner
+++ b/dietpi/dietpi-cleaner
@@ -26,7 +26,7 @@
#Grab Input (valid interger)
INPUT=0
- disable_error=1 G_CHECK_VALIDINT $1 && INPUT=$1
+ disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1
#/////////////////////////////////////////////////////////////////////////////////////
# Globals
@@ -167,8 +167,7 @@ Further information:\n - https://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=623#p6
G_WHIP_YESNO "$G_PROGRAM_NAME will now run your enabled cleaners.\n
(Notice): If you are unsure what this program will do, I would recommend creating a backup with dietpi-backup before proceeding.\n
-Would you like to continue and start the cleaning process?"
- (( $? == 0 )) && Run_Cleaners
+Would you like to continue and start the cleaning process?" && Run_Cleaners
else
@@ -233,8 +232,7 @@ Would you like to continue and start the cleaning process?"
done
- G_WHIP_CHECKLIST 'Please use the spacebar to toggle which cleaners are enabled.'
- if (( $? == 0 )); then
+ if G_WHIP_CHECKLIST 'Please use the spacebar to toggle which cleaners are enabled.'; then
for ((i=0; i<$MAX_CLEANERS; i++))
do
@@ -252,9 +250,6 @@ Would you like to continue and start the cleaning process?"
fi
- #Clean up temp files
- rm $FP_TEMP &> /dev/null
-
}
#TARGETMENUID=2
@@ -276,8 +271,7 @@ Would you like to continue and start the cleaning process?"
)
- G_WHIP_MENU 'Files: Cleaner options.\n(NB) The cleaner named "Files" must be enabled for this to work.'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Files: Cleaner options.\n(NB) The cleaner named "Files" must be enabled for this to work.'; then
case "$G_WHIP_RETURNED_VALUE" in
@@ -322,7 +316,7 @@ Would you like to continue and start the cleaning process?"
Update_Space_Used(){
- ROOT_SPACE_USED_CURRENT=$(df --block-size MB | grep "$ROOTFS_DEVICE_PATH" | awk '{ print $3 }' | tr -d 'MB')
+ ROOT_SPACE_USED_CURRENT=$(df --block-size MB | mawk -v pat="$ROOTFS_DEVICE_PATH" '$0~pat {print $3}' | tr -d 'MB')
}
@@ -393,7 +387,7 @@ Would you like to continue and start the cleaning process?"
#Convert lined list into a 1 line string.
string_package_names+="$line "
- done < <(dpkg --get-selections | awk '{ print $1 }' | grep '\-dev')
+ done <<< "$(dpkg --get-selections | mawk '/-dev/ {print $1}')"
#add other dev packages
string_package_names+='build-essential git'
@@ -443,11 +437,11 @@ Would you like to continue and start the cleaning process?"
INFO_CLEAN_NAME='Files'
Banner_Cleaning
- #generate list of files to include. Remove lines with (#) or (space) or (empty) from list
- cat $FILEPATH_CUSTOMFILES | sed '/#/d' | sed '/ /d' | sed '/^$/d' > $FP_TEMP
+ #Generate list of files to include. Remove lines with (#) or (space) or (empty) from list
+ sed -E '/([#[:blank:]]|^$)/d' $FILEPATH_CUSTOMFILES > $FP_TEMP
#Check include file has at least one value/line to process.
- local line_count=$(cat $FP_TEMP | wc -l)
+ local line_count=$(wc -l < $FP_TEMP)
if (( $line_count == 0 )); then
echo -e "\nNo files to find. Have you setup the Files options and added filename entries to match?\n"
@@ -486,7 +480,7 @@ Would you like to continue and start the cleaning process?"
#Remove /mnt from find list
(( $INCLUDE_MNT )) || sed -i '/\/mnt/d' $FP_TEMP
- line_count=$(cat $FP_TEMP | wc -l)
+ line_count=$(wc -l < $FP_TEMP)
if (( $line_count == 0 )); then
echo -e '\nNo matching filenames were found.\n'
@@ -516,7 +510,7 @@ Would you like to continue and start the cleaning process?"
fi
- rm $FP_TEMP &> /dev/null
+ rm $FP_TEMP
}
@@ -529,7 +523,7 @@ Would you like to continue and start the cleaning process?"
if (( ! $DRY_RUN )); then
/DietPi/dietpi/func/dietpi-logclear 1
- rm /var/tmp/dietpi/logs/* &> /dev/null
+ rm -vf /var/tmp/dietpi/logs/*
fi
@@ -544,7 +538,7 @@ Would you like to continue and start the cleaning process?"
if (( ! $DRY_RUN )); then
apt-get clean
- rm /var/lib/apt/lists/* -vf
+ rm -vf /var/lib/apt/lists/*
G_AGUP
fi
@@ -667,9 +661,6 @@ _EOF_
fi
#-----------------------------------------------------------------------------------
- #delete[]
- unset aEnabledCleaners
- #-----------------------------------------------------------------------------------
exit
#-----------------------------------------------------------------------------------
}
diff --git a/dietpi/dietpi-cloudshell b/dietpi/dietpi-cloudshell
index a933fe7ff4..f99437edb3 100644
--- a/dietpi/dietpi-cloudshell
+++ b/dietpi/dietpi-cloudshell
@@ -19,15 +19,15 @@
#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
- G_CHECK_ROOT_USER
G_PROGRAM_NAME='DietPi-Cloudshell'
+ G_CHECK_ROOT_USER
G_INIT_ALLOW_CONCURRENT=1
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
#Grab Input (valid interger)
INPUT=0
- disable_error=1 G_CHECK_VALIDINT $1 && INPUT=$1
+ disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1
#Version
DIETPI_CLOUDSHELL_VERSION=9
@@ -87,11 +87,10 @@
return_value="0$return_value"
-
# -0
elif [[ ${return_value:0:2} == '-.' ]]; then
- return_value=$(sed 's/^-./-0./' <<< "$return_value")
+ return_value="-0.${return_value#-.}"
fi
@@ -110,17 +109,17 @@
# - KB
if (( $1 < 1048576 )); then
- return_value="$(echo "scale=$decimal_count; $1 / 1024" | bc -l ) KB"
+ return_value="$(bc -l <<< "scale=$decimal_count; $1 / 1024") KB"
# - MB
elif (( $1 < 1073741824 )); then
- return_value="$(echo "scale=$decimal_count; $1 / 1024 / 1024" | bc -l ) MB"
+ return_value="$(bc -l <<< "scale=$decimal_count; $1 / 1024 / 1024") MB"
# - GB
else
- return_value="$(echo "scale=$decimal_count; $1 / 1024 / 1024 / 1024" | bc -l ) GB"
+ return_value="$(bc -l <<< "scale=$decimal_count; $1 / 1024 / 1024 / 1024") GB"
fi
@@ -144,17 +143,17 @@
# - Kbit
if (( $1 < 1000000 )); then
- return_value="$(echo "scale=$decimal_count; $1 * 8 / 1000" | bc -l) Kbit"
+ return_value="$(bc -l <<< "scale=$decimal_count; $1 * 8 / 1000") Kbit"
# - MBit
elif (( $1 < 1000000000 )); then
- return_value="$(echo "scale=$decimal_count; $1 * 8 / 1000 / 1000" | bc -l) Mbit"
+ return_value="$(bc -l <<< "scale=$decimal_count; $1 * 8 / 1000 / 1000") Mbit"
# - GBit
else
- return_value="$(echo "scale=$decimal_count; $1 * 8 / 1000 / 1000 / 1000" | bc -l) Gbit"
+ return_value="$(bc -l <<< "scale=$decimal_count; $1 * 8 / 1000 / 1000 / 1000") Gbit"
fi
@@ -171,11 +170,7 @@
setfont /usr/share/consolefonts/Uni3-TerminusBold32x16
# - set small font if insufficent number of lines (320x240)
- if (( $(tput lines) < 10 )); then
-
- setfont /usr/share/consolefonts/Uni3-TerminusBold24x12.psf
-
- fi
+ (( $(tput lines) < 10 )) && setfont /usr/share/consolefonts/Uni3-TerminusBold24x12.psf
#Disable screen blanking on tty1 initially
Disable_Screen_Blanking
@@ -223,7 +218,7 @@
#$C_PERCENT_GRAPH = return text
#Convert to int
- local input_value=$(echo $1 | cut -d. -f1)
+ local input_value=$(cut -d. -f1 <<< $1)
#Cap input value
if (( $input_value > 100 )); then
@@ -322,7 +317,7 @@
if (( $TEMPERATURE_OUTPUT_TYPE == 0 )); then
- TEMPERATURE_CONVERSION_VALUE=$(awk "BEGIN {printf \"%.0f\",$TEMPERATURE_CONVERSION_VALUE * 1.8 + 32"})
+ TEMPERATURE_CONVERSION_VALUE=$(mawk "BEGIN {printf \"%.0f\",$TEMPERATURE_CONVERSION_VALUE * 1.8 + 32}")
TEMPERATURE_CONVERSION_VALUE+="'f"
else
@@ -334,16 +329,12 @@
}
DATE_TIME=0
- Obtain_DATE_TIME(){
-
- DATE_TIME=$(date +"%a %x - %R")
-
- }
+ Obtain_DATE_TIME(){ DATE_TIME=$(date +"%a %x - %R"); }
UPTIME=0
Obtain_UPTIME(){
- local fSeconds=$(awk '{print $1}' <<< $(= 65 )); then
@@ -417,15 +408,11 @@
fi
- CPU_FREQ_1=$(( $( $FP_TEMP
#RAM MB
- MEMORY_TOTAL=$(grep -m1 'Mem: ' $FP_TEMP | awk '{print $2}')
- #MEMORY_CACHED=$(grep -m1 'Mem: ' $FP_TEMP | awk '{print $6}')
- MEMORY_USED=$(( $(grep -m1 'Mem: ' $FP_TEMP | awk '{print $3}') ))
- MEMORY_FREE=$(( $(grep -m1 'Mem: ' $FP_TEMP | awk '{print $7}') ))
- MEMORY_PERCENT=$(echo | awk "{print $MEMORY_USED / $MEMORY_TOTAL * 100}")
+ MEMORY_TOTAL=$(mawk '/Mem: / {print $2;exit}' $FP_TEMP)
+ #MEMORY_CACHED=$(mawk '/Mem: / {print $6;exit}' $FP_TEMP)
+ MEMORY_USED=$(mawk '/Mem: / {print $3;exit}' $FP_TEMP)
+ MEMORY_FREE=$(mawk '/Mem: / {print $7;exit}' $FP_TEMP)
+ MEMORY_PERCENT=$(mawk "{print $MEMORY_USED / $MEMORY_TOTAL * 100}" <<< '')
#convert to interger and graph it
Percent_To_Graph $MEMORY_PERCENT
MEMORY_PERCENT=$C_PERCENT_GRAPH
#SWAP MB
- MEMORY_SWAPTOTAL=$(grep -m1 'Swap: ' $FP_TEMP | awk '{print $2}')
+ MEMORY_SWAPTOTAL=$(mawk '/Swap: / {print $2;exit}' $FP_TEMP)
# - Swap available and active
if (( $MEMORY_SWAPTOTAL > 0 )); then
- MEMORY_SWAPUSED=$(grep -m1 'Swap: ' $FP_TEMP | awk '{print $3}')
- MEMORY_SWAPFREE=$(grep -m1 'Swap: ' $FP_TEMP | awk '{print $4}')
- MEMORY_SWAPERCENT=$( echo | awk "{print $MEMORY_SWAPUSED / $MEMORY_SWAPTOTAL * 100}")
+ MEMORY_SWAPUSED=$(mawk '/Swap: / {print $3;exit}' $FP_TEMP)
+ MEMORY_SWAPFREE=$(mawk '/Swap: / {print $4;exit}' $FP_TEMP)
+ MEMORY_SWAPERCENT=$(mawk "{print $MEMORY_SWAPUSED / $MEMORY_SWAPTOTAL * 100}" <<< '')
#convert to interger and graph it
Percent_To_Graph $MEMORY_SWAPERCENT
@@ -801,7 +788,7 @@
if [[ -f /etc/pihole/gravity.list ]]; then
- PIHOLE_TOTAL_DOMAINS=$(wc -l /etc/pihole/gravity.list | awk '{print $1}')
+ PIHOLE_TOTAL_DOMAINS=$(wc -l /etc/pihole/gravity.list | mawk '{print $1}')
else
@@ -813,7 +800,7 @@
local today=$(date +'%b %e')
- PIHOLE_QUERY_COUNT=$(grep "$today" $pihole_log_file | awk '/query/ {print $7}' | wc -l)
+ PIHOLE_QUERY_COUNT=$(grep "$today" $pihole_log_file | mawk '/query/ {print $7}' | wc -l)
#Prevent / 0 on percentage
if (( $PIHOLE_QUERY_COUNT <= 0 )); then
@@ -821,8 +808,8 @@
fi
- PIHOLE_TOTAL_ADS=$(grep "$today" $pihole_log_file | awk '/\/etc\/pihole\/gravity.list/ {print $7}' | wc -l)
- PIHOLE_PERCENT_ADS=$(echo | awk "{print $PIHOLE_TOTAL_ADS / $PIHOLE_QUERY_COUNT * 100}")
+ PIHOLE_TOTAL_ADS=$(grep "$today" $pihole_log_file | mawk '/\/etc\/pihole\/gravity.list/ {print $7}' | wc -l)
+ PIHOLE_PERCENT_ADS=$(echo | mawk "{print $PIHOLE_TOTAL_ADS / $PIHOLE_QUERY_COUNT * 100}")
#convert to interger and graph it
Percent_To_Graph $PIHOLE_PERCENT_ADS
@@ -835,7 +822,7 @@
else
- PIHOLE_LAST_DOMAIN_BLOCKED=$(tac /var/log/pihole.log | grep -m1 'gravity.list' | awk '{print $6}' | cut -c 1-24 )
+ PIHOLE_LAST_DOMAIN_BLOCKED=$(tac /var/log/pihole.log | mawk '/gravity.list/ {print $6;exit}' | cut -c 1-24 )
fi
@@ -845,11 +832,7 @@
# Scene Settings
#/////////////////////////////////////////////////////////////////////////////////////
RUN_INTRO=0
- if (( $INPUT == 1 )); then
-
- RUN_INTRO=1
-
- fi
+ (( $INPUT == 1 )) && RUN_INTRO=1
#SCENE INDEXS
SCENE_CURRENT=2
@@ -1296,7 +1279,7 @@ _EOF_
systemctl stop dietpi-cloudshell
#Kill all , excluding Menu.
- ps ax | grep '[d]ietpi-cloudshell [1-9]' | awk '{print $1}' > $FP_TEMP
+ ps ax | grep '[d]ietpi-cloudshell [1-9]' | mawk '{print $1}' > $FP_TEMP
while read -r line
do
@@ -1482,16 +1465,16 @@ _EOF_
G_WHIP_MENU_ARRAY=(
- 'Colour' 'Setting: Change the colour scheme.'
- 'Update Rate' 'Setting: Control the time between screen updates.'
- 'Scenes' 'Setting: Toggle which scenes are shown.'
- 'Storage' 'Setting: Set mount locations used for storage stats'
- 'Temperature' "Setting: Output = $temp_output_text"
- 'Net Usage Current' "Setting: Output = $bitbyte_output_text"
- 'Output Display' "Setting: $target_output_text."
- 'Auto screen off' "Setting: $autoscreenoff | Start $BLANK_SCREEN_TIME_HOUR_START h | End $BLANK_SCREEN_TIME_HOUR_END h"
- 'Start / Restart' "Apply settings. Launch on $target_output_text."
- 'Stop' "Stops $G_PROGRAM_NAME."
+ 'Colour' ': Setting: Change the colour scheme.'
+ 'Update Rate' ': Setting: Control the time between screen updates.'
+ 'Scenes' ': Setting: Toggle which scenes are shown.'
+ 'Storage' ': Setting: Set mount locations used for storage stats'
+ 'Temperature' ": Setting: Output = $temp_output_text"
+ 'Net Usage Current' ": Setting: Output = $bitbyte_output_text"
+ 'Output Display' ": Setting: $target_output_text."
+ 'Auto screen off' ": Setting: $autoscreenoff | Start $BLANK_SCREEN_TIME_HOUR_START h | End $BLANK_SCREEN_TIME_HOUR_END h"
+ 'Start / Restart' ": Apply settings. Launch on $target_output_text."
+ 'Stop' ": Stops $G_PROGRAM_NAME."
)
@@ -1599,13 +1582,13 @@ _EOF_
G_WHIP_MENU_ARRAY=(
- '0' 'White'
- '1' 'Red'
- '2' 'Green'
- '3' 'Yellow (Default)'
- '4' 'Blue'
- '5' 'Purple'
- '6' 'Cyan'
+ '0' ': White'
+ '1' ': Red'
+ '2' ': Green'
+ '3' ': Yellow (Default)'
+ '4' ': Blue'
+ '5' ': Purple'
+ '6' ': Cyan'
)
@@ -1722,9 +1705,9 @@ _EOF_
G_WHIP_MENU_ARRAY=(
- 'Toggle' "$blank_screen_at_specific_time_enabled_text"
- 'Start time' "Set which hour to power off screen ($BLANK_SCREEN_TIME_HOUR_START)."
- 'End time' "Set which hour to power on screen ($BLANK_SCREEN_TIME_HOUR_END)."
+ 'Toggle' ": $blank_screen_at_specific_time_enabled_text"
+ 'Start time' ": Set which hour to power off screen ($BLANK_SCREEN_TIME_HOUR_START)."
+ 'End time' ": Set which hour to power on screen ($BLANK_SCREEN_TIME_HOUR_END)."
)
diff --git a/dietpi/dietpi-config b/dietpi/dietpi-config
index b515ff9643..c232cc43b7 100644
--- a/dietpi/dietpi-config
+++ b/dietpi/dietpi-config
@@ -27,10 +27,10 @@
#Grab Inputs
# - target MENU INDEX (valid interger)
- disable_error=1 G_CHECK_VALIDINT $1 && TARGETMENUID=$1
+ disable_error=1 G_CHECK_VALIDINT "$1" && TARGETMENUID=$1
# - Exit DietPi-Config when going back to previous menu?
- if disable_error=1 G_CHECK_VALIDINT $2; then
+ if disable_error=1 G_CHECK_VALIDINT "$2"; then
EXITONBACK=$2
TEXT_MENU_BACK='Exit'
@@ -65,10 +65,10 @@
#/////////////////////////////////////////////////////////////////////////////////////
# MENUS
#/////////////////////////////////////////////////////////////////////////////////////
- TARGETMENUID=${TARGETMENUID:=0}
- EXITONBACK=${EXITONBACK:=0}
+ TARGETMENUID=${TARGETMENUID:-0}
+ EXITONBACK=${EXITONBACK:-0}
- TEXT_MENU_BACK=${TEXT_MENU_BACK:=Back}
+ TEXT_MENU_BACK=${TEXT_MENU_BACK:-Back}
WHIP_SELECTION_PREVIOUS=''
REBOOT_REQUIRED=0
@@ -80,11 +80,16 @@
#TARGETMENUID=0
Menu_Main(){
- G_WHIP_MENU_ARRAY=(
+ G_WHIP_MENU_ARRAY=('1' ': Display Options')
+ # Hide Audio and Performance Options on VM
+ (( $G_HW_MODEL == 20 )) || G_WHIP_MENU_ARRAY+=(
- '1' ': Display Options'
'2' ': Audio Options'
'3' ': Performance Options'
+
+ )
+ G_WHIP_MENU_ARRAY+=(
+
'4' ': Advanced Options'
'5' ': Language/Regional Options'
'6' ': Security Options'
@@ -95,9 +100,7 @@
)
-
- G_WHIP_MENU "Hardware : $G_HW_MODEL_DESCRIPTION"
- if (( $? == 0 )); then
+ if G_WHIP_MENU "Hardware : $G_HW_MODEL_DESCRIPTION"; then
if (( $G_WHIP_RETURNED_VALUE == 1 )); then
@@ -107,24 +110,10 @@
TARGETMENUID=14
- if (( $G_HW_MODEL == 20 )); then
-
- TARGETMENUID=0
- Info_HW_OptionNotSupported
-
- fi
-
elif (( $G_WHIP_RETURNED_VALUE == 3 )); then
TARGETMENUID=4
- if (( $G_HW_MODEL == 20 )); then
-
- TARGETMENUID=0
- Info_HW_OptionNotSupported
-
- fi
-
elif (( $G_WHIP_RETURNED_VALUE == 4 )); then
TARGETMENUID=3
@@ -171,25 +160,18 @@
Menu_Exit(){
# TARGETMENUID = -1 , if we are to exit the menu
-
G_WHIP_SIZE_X_MAX=50
- G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"; then
TARGETMENUID=-1
- #Disable reboot when run from dietpi-software
+ # Disable reboot when run from dietpi-software
pgrep 'dietpi-software' &> /dev/null && REBOOT_REQUIRED=0
# Reboot required
- if (( $REBOOT_REQUIRED )); then
-
- G_WHIP_YESNO 'A reboot is required to apply your new settings.\nWould you like to reboot now?'
- (( $? == 0 )) && reboot
+ (( $REBOOT_REQUIRED )) && G_WHIP_YESNO 'A reboot is required to apply your new settings.\nWould you like to reboot now?' && reboot
- fi
-
- #Return to DietPiConfig main menu
+ # Return to DietPi-Config main menu
elif (( $EXITONBACK == 0 )); then
TARGETMENUID=0
@@ -204,38 +186,27 @@
if (( $G_HW_MODEL < 10 )); then
- local framebuffer_x=$(grep -m1 'framebuffer_width=' /DietPi/config.txt | sed 's/^[^=]*=//')
- local framebuffer_y=$(grep -m1 'framebuffer_height=' /DietPi/config.txt | sed 's/^[^=]*=//')
-
- # 0/180
- if (( $input == 0 )); then
-
- if (( $framebuffer_x < $framebuffer_y )); then
-
- local temp=$framebuffer_x
- framebuffer_x=$framebuffer_y
- framebuffer_y=$temp
-
- G_CONFIG_INJECT 'framebuffer_width=' "framebuffer_width=$framebuffer_x" /DietPi/config.txt
- G_CONFIG_INJECT 'framebuffer_height=' "framebuffer_height=$framebuffer_y" /DietPi/config.txt
-
- fi
+ local framebuffer_x=$(grep -m1 '^[[:blank:]]*framebuffer_width=' /DietPi/config.txt || vcgencmd get_config framebuffer_width)
+ framebuffer_x=${framebuffer_x#*=}; framebuffer_x=${framebuffer_x:-0}
+ local framebuffer_y=$(grep -m1 '^[[:blank:]]*framebuffer_height=' /DietPi/config.txt || vcgencmd get_config framebuffer_height)
+ framebuffer_y=${framebuffer_y#*=}; framebuffer_y=${framebuffer_y:-0}
+ # 0/180 landscape
+ if (( $input == 0 && $framebuffer_x < $framebuffer_y )); then
- # 90/270 | flip XY FB values
- elif (( $input == 1 )); then
+ G_CONFIG_INJECT 'framebuffer_width=' "framebuffer_width=$framebuffer_y" /DietPi/config.txt
+ G_CONFIG_INJECT 'framebuffer_height=' "framebuffer_height=$framebuffer_x" /DietPi/config.txt
- if (( $framebuffer_x > $framebuffer_y )); then
+ # 90/270 portrait | flip XY FB values
+ elif (( $input == 1 && $framebuffer_x > $framebuffer_y )); then
- local temp=$framebuffer_x
- framebuffer_x=$framebuffer_y
- framebuffer_y=$temp
+ G_CONFIG_INJECT 'framebuffer_width=' "framebuffer_width=$framebuffer_y" /DietPi/config.txt
+ G_CONFIG_INJECT 'framebuffer_height=' "framebuffer_height=$framebuffer_x" /DietPi/config.txt
- G_CONFIG_INJECT 'framebuffer_width=' "framebuffer_width=$framebuffer_x" /DietPi/config.txt
- G_CONFIG_INJECT 'framebuffer_height=' "framebuffer_height=$framebuffer_y" /DietPi/config.txt
+ fi
- fi
+ else
- fi
+ Info_HW_OptionNotSupported
fi
@@ -254,79 +225,45 @@
else
- G_WHIP_MENU_ARRAY+=('1' ': Change Resolution')
+ G_WHIP_MENU_ARRAY+=('1' ': Display Resolution')
- # Just offer resolution option for VMs
+ # On VM, only offer resolution option
if (( $G_HW_MODEL != 20 )); then
G_WHIP_MENU_ARRAY+=('2' ': GPU/RAM Memory Split')
- local lcdpanel_text=$(grep -m1 '^CONFIG_LCDPANEL=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
- G_WHIP_MENU_ARRAY+=('3' ": LCD Panel addon: [$lcdpanel_text]")
+ local lcdpanel_text=$(grep -m1 '^[[:blank:]]*CONFIG_LCDPANEL=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
+ G_WHIP_MENU_ARRAY+=('3' ": LCD Panel addon: [${lcdpanel_text:-NONE}]")
fi
fi
- local xorg_dpi_current=$(grep -m1 '^SOFTWARE_XORG_DPI=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
- G_WHIP_MENU_ARRAY+=('17' ": Xorg DPI: [$xorg_dpi_current]")
-
#Display brightness
G_WHIP_MENU_ARRAY+=('16' ': Display Brightness')
+ local xorg_dpi_current=$(grep -m1 '^[[:blank:]]*SOFTWARE_XORG_DPI=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
+ G_WHIP_MENU_ARRAY+=('17' ": X.Org DPI: [${xorg_dpi_current:-N/A}]")
+
(( $G_HW_MODEL != 20 )) && G_WHIP_MENU_ARRAY+=('14' ': LED Control')
#RPi only
if (( $G_HW_MODEL < 10 )); then
- # - Get Current Settings
- local overscan_enabled=$(grep -ci -m1 '^[[:blank:]]*disable_overscan=0' /DietPi/config.txt)
- local overscan_text='[Off]'
- if (( $overscan_enabled )); then
- overscan_text='[On]'
- fi
-
- local hdmi_boost_disabled=$(grep -ci -m1 '#config_hdmi_boost=' /DietPi/config.txt)
- local hdmi_boost_text='[On]'
- if (( $hdmi_boost_disabled )); then
- hdmi_boost_text='[Off]'
- fi
-
- local rpi_camera_module_enabled=$(grep -ci -m1 '^[[:blank:]]*start_x=1' /DietPi/config.txt)
- local rpi_camera_module_text='[Off]'
- if (( $rpi_camera_module_enabled )); then
-
- rpi_camera_module_text='[On]'
-
- fi
-
- local rpi_camera_led_enabled=$(grep -ci -m1 '^[[:blank:]]*disable_camera_led=0' /DietPi/config.txt)
- local rpi_camera_led_text='[Off]'
- if (( $rpi_camera_led_enabled )); then
-
- rpi_camera_led_text='[On]'
-
- fi
+ # HDMI rotation
+ local rotation_hdmi_current=$(grep -m1 '^[[:blank:]]*display_hdmi_rotate=' /DietPi/config.txt | sed 's/^[^=]*=//')
+ G_WHIP_MENU_ARRAY+=('4' ": Rotation (HDMI) : [${rotation_hdmi_current:=0}]")
- local rotation_hdmi_current=$(grep -m1 '^[[:blank:]]*display_rotate=' /DietPi/config.txt | sed 's/^[^=]*=//')
+ # LCD rotation
local rotation_lcd_current=$(grep -m1 '^[[:blank:]]*lcd_rotate=' /DietPi/config.txt | sed 's/^[^=]*=//')
+ G_WHIP_MENU_ARRAY+=('5' ": Rotation (LCD) : [${rotation_lcd_current:=0}]")
- local vc1_key_current=$(grep -m1 '^[[:blank:]]*decode_WVC1=' /DietPi/config.txt | sed 's/^[^=]*=//')
- local mpeg2_key_current=$(grep -m1 '^[[:blank:]]*decode_MPG2=' /DietPi/config.txt | sed 's/^[^=]*=//')
-
- #JustBoom IR Remote
- local justboom_ir_remote_text='[Off]'
- local justboom_ir_remote_enabled=0
- if [ -f /etc/systemd/system/justboom-ir-mpd.service ]; then
-
- justboom_ir_remote_text='[On]'
- justboom_ir_remote_enabled=1
-
- fi
-
- G_WHIP_MENU_ARRAY+=('4' ": Rotation (HDMI) : [$rotation_hdmi_current]")
- G_WHIP_MENU_ARRAY+=('5' ": Rotation (LCD) : [$rotation_lcd_current]")
+ # Display overscan
+ local overscan_disabled=$(grep -ci -m1 '^[[:blank:]]*disable_overscan=1' /DietPi/config.txt)
+ local overscan_text='[On]'
+ (( $overscan_disabled )) && overscan_text='[Off]'
G_WHIP_MENU_ARRAY+=('6' ": Overscan : $overscan_text")
- if (( $overscan_enabled )); then
+ # - Overscan sizes
+ if (( ! $overscan_disabled )); then
local overscan_options=(
@@ -337,20 +274,48 @@
)
- local overscan_left=$(grep -m1 '^[[:blank:]]*overscan_left=' /DietPi/config.txt | sed 's/^[^=]*=//')
- local overscan_right=$(grep -m1 '^[[:blank:]]*overscan_right=' /DietPi/config.txt | sed 's/^[^=]*=//')
- local overscan_top=$(grep -m1 '^[[:blank:]]*overscan_top=' /DietPi/config.txt | sed 's/^[^=]*=//')
- local overscan_bottom=$(grep -m1 '^[[:blank:]]*overscan_bottom=' /DietPi/config.txt | sed 's/^[^=]*=//')
- G_WHIP_MENU_ARRAY+=('15' ": Overscan Compensation [L:$overscan_left] [R:$overscan_right] [T:$overscan_top] [B:$overscan_bottom]")
+ local overscan_left=$(grep -m1 '^[[:blank:]]*overscan_left=' /DietPi/config.txt || vcgencmd get_config overscan_left); overscan_left=${overscan_left#*=}
+ local overscan_right=$(grep -m1 '^[[:blank:]]*overscan_right=' /DietPi/config.txt || vcgencmd get_config overscan_right); overscan_right=${overscan_right#*=}
+ local overscan_top=$(grep -m1 '^[[:blank:]]*overscan_top=' /DietPi/config.txt || vcgencmd get_config overscan_top); overscan_top=${overscan_top#*=}
+ local overscan_bottom=$(grep -m1 '^[[:blank:]]*overscan_bottom=' /DietPi/config.txt || vcgencmd get_config overscan_bottom); overscan_bottom=${overscan_bottom#*=}
+ G_WHIP_MENU_ARRAY+=('15' ": Overscan Compensation [L:${overscan_left:=N/A}] [R:${overscan_right:=N/A}] [T:${overscan_top:=N/A}] [B:${overscan_bottom:=N/A}]")
fi
- G_WHIP_MENU_ARRAY+=('7' ": HDMI Boost : $hdmi_boost_text")
+ # HDMI signal boost
+ local hdmi_boost_current=$({ grep -m1 '^[[:blank:]]*config_hdmi_boost=' /DietPi/config.txt || vcgencmd get_config config_hdmi_boost; } | sed 's/^[^=]*=//')
+ G_WHIP_MENU_ARRAY+=('7' ": HDMI Boost : [${hdmi_boost_current:=N/A}]")
+
+ # RPi camera module
+ local rpi_camera_module_enabled=$(grep -ci -m1 '^[[:blank:]]*start_x=1' /DietPi/config.txt)
+ local rpi_camera_module_text='[Off]'
+ (( $rpi_camera_module_enabled )) && rpi_camera_module_text='[On]'
G_WHIP_MENU_ARRAY+=('8' ": RPi Camera : $rpi_camera_module_text")
+
+ # RPi camera LED
+ local rpi_camera_led_disabled=$(grep -ci -m1 '^[[:blank:]]*disable_camera_led=1' /DietPi/config.txt)
+ local rpi_camera_led_text='[On]'
+ (( $rpi_camera_led_disabled )) && rpi_camera_led_text='[Off]'
G_WHIP_MENU_ARRAY+=('9' ": RPI Camera led : $rpi_camera_led_text")
+
+ # JustBoom IR Remote
+ local justboom_ir_remote_text='[Off]'
+ local justboom_ir_remote_enabled=0
+ if [[ -f /etc/systemd/system/justboom-ir-mpd.service ]]; then
+
+ justboom_ir_remote_text='[On]'
+ justboom_ir_remote_enabled=1
+
+ fi
G_WHIP_MENU_ARRAY+=('11' ": JustBoom IR remote : $justboom_ir_remote_text")
- G_WHIP_MENU_ARRAY+=('12' ": VC1 Key : [$vc1_key_current]")
- G_WHIP_MENU_ARRAY+=('13' ": MPEG2 Key : [$mpeg2_key_current]")
+
+ # VC1 key
+ local vc1_key_current=$(grep -m1 '^[[:blank:]]*decode_WVC1=' /DietPi/config.txt | sed 's/^[^=]*=//')
+ G_WHIP_MENU_ARRAY+=('12' ": VC1 Key : [${vc1_key_current:=none}]")
+
+ # MPEG2 key
+ local mpeg2_key_current=$(grep -m1 '^[[:blank:]]*decode_MPG2=' /DietPi/config.txt | sed 's/^[^=]*=//')
+ G_WHIP_MENU_ARRAY+=('13' ": MPEG2 Key : [${mpeg2_key_current:=none}]")
fi
@@ -370,10 +335,9 @@
fi
- G_WHIP_DEFAULT_ITEM="$WHIP_SELECTION_PREVIOUS"
+ G_WHIP_DEFAULT_ITEM=$WHIP_SELECTION_PREVIOUS
- G_WHIP_MENU 'Please select an option:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select an option:'; then
#Return to this menu
TARGETMENUID=1
@@ -382,14 +346,13 @@
if (( $G_WHIP_RETURNED_VALUE == 15 )); then
- for ((i=0; i<${#overscan_options[@]}; i++))
+ for i in "${overscan_options[@]}"
do
- G_WHIP_DEFAULT_ITEM=${!overscan_options[$i]}
- G_WHIP_INPUTBOX "Please enter a value (pixel count) for ${overscan_options[$i]}.\n - EG: 16"
- if (( $? == 0 )); then
+ G_WHIP_DEFAULT_ITEM=${!i}
+ if G_WHIP_INPUTBOX "Please enter a value (pixel count) for $i\n - EG: 16"; then
- sed -i "/${overscan_options[$i]}=/c ${overscan_options[$i]}=$G_WHIP_RETURNED_VALUE" /DietPi/config.txt
+ G_CONFIG_INJECT "$i=" "$i=$G_WHIP_RETURNED_VALUE" /DietPi/config.txt
REBOOT_REQUIRED=1
else
@@ -406,10 +369,8 @@
elif (( $G_WHIP_RETURNED_VALUE == 3 )); then
- if (( $G_HW_MODEL < 10 ||
- $G_HW_MODEL == 10 ||
- $G_HW_MODEL == 11 ||
- $G_HW_MODEL == 12 )); then
+ # RPi and Odroids only
+ if (( $G_HW_MODEL < 20 )); then
G_WHIP_MENU_ARRAY=()
@@ -420,23 +381,15 @@
G_WHIP_MENU_ARRAY+=('esp01215e' ': Elecrow 1024x600 7" IPS HDMI panel with touch input')
- fi
-
- if (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )); then
+ else
G_WHIP_MENU_ARRAY+=('odroid-lcd35' ': 480x320 panel with touch input')
-
- if (( $G_HW_MODEL == 11 )); then
-
- G_WHIP_MENU_ARRAY+=('odroid-cloudshell' ': 320x240 panel')
-
- fi
+ (( $G_HW_MODEL == 11 )) && G_WHIP_MENU_ARRAY+=('odroid-cloudshell' ': 320x240 panel')
fi
- G_WHIP_DEFAULT_ITEM="$lcdpanel_text"
- G_WHIP_MENU 'Please select an option:'
- if (( $? == 0 )); then
+ G_WHIP_DEFAULT_ITEM=$lcdpanel_text
+ if G_WHIP_MENU 'Please select an option:'; then
/DietPi/dietpi/func/dietpi-set_hardware lcdpanel "$G_WHIP_RETURNED_VALUE"
REBOOT_REQUIRED=1
@@ -467,24 +420,22 @@
#RPI only
if (( $G_HW_MODEL < 10 )); then
- if (( $overscan_enabled )); then
+ if (( $overscan_disabled )); then
- sed -i '/disable_overscan=/c\disable_overscan=1' /DietPi/config.txt
- for ((i=0; i<${#overscan_options[@]}; i++))
- do
+ G_CONFIG_INJECT 'disable_overscan=' 'disable_overscan=0' /DietPi/config.txt
- sed -i "/${overscan_options[$i]}=/c ${overscan_options[$i]}=0" /DietPi/config.txt
-
- done
+ else
- REBOOT_REQUIRED=1
+ G_CONFIG_INJECT 'disable_overscan=' 'disable_overscan=1' /DietPi/config.txt
+ for i in "${overscan_options[@]}"
+ do
- elif (( ! $overscan_enabled )); then
+ G_CONFIG_INJECT "$i=" "#$i=0" /DietPi/config.txt
- sed -i '/disable_overscan=/c\disable_overscan=0' /DietPi/config.txt
- REBOOT_REQUIRED=1
+ done
fi
+ REBOOT_REQUIRED=1
else
@@ -497,27 +448,26 @@
#RPI only
if (( $G_HW_MODEL < 10 )); then
- #Enabled
- if [[ $hdmi_boost_disabled == 0 ]]; then
-
- G_WHIP_YESNO "Current setting: $hdmi_boost_text \n Would you like to disable HDMI Signal Boost?"
- if (( $? == 0 )); then
-
- sed -i '/config_hdmi_boost=/c\#config_hdmi_boost=4' /DietPi/config.txt
- REBOOT_REQUIRED=1
-
- fi
+ G_WHIP_MENU_ARRAY=(
- #Disabled
- elif [[ $hdmi_boost_disabled == 1 ]]; then
+ '0' ': Disabled'
+ '2' ': RPi 1 Default'
+ '5' ': RPi 2+ Default'
+ '6' ''
+ '7' ': High (May increase stability)'
+ '8' ''
+ '9' ''
+ '10' ''
+ '11' ': Max (Not recommended)'
- G_WHIP_YESNO "Current setting: $hdmi_boost_text \n Would you like to enable HDMI Signal Boost? \n \n If you have no display output, or, blinking, selecting Enable may resolve it."
- if (( $? == 0 )); then
+ )
- G_CONFIG_INJECT 'config_hdmi_boost=' 'config_hdmi_boost=4' /DietPi/config.txt
- REBOOT_REQUIRED=1
+ G_WHIP_DEFAULT_ITEM=$hdmi_boost_current
+ G_WHIP_MENU 'Please select a HDMI boost level.\n\nA long (or insufficiently manufactured) cable may required a higher boost setting to achieve correct signal.'
+ if (( $? == 0 )); then
- fi
+ G_CONFIG_INJECT 'config_hdmi_boost=' "config_hdmi_boost=$G_WHIP_RETURNED_VALUE" /DietPi/config.txt
+ REBOOT_REQUIRED=1
fi
@@ -532,17 +482,16 @@
#RPI only
if (( $G_HW_MODEL < 10 )); then
- if (( ! $rpi_camera_module_enabled )); then
+ if (( $rpi_camera_module_enabled )); then
- /DietPi/dietpi/func/dietpi-set_hardware rpi-camera enable
- REBOOT_REQUIRED=1
+ /DietPi/dietpi/func/dietpi-set_hardware rpi-camera disable
else
- /DietPi/dietpi/func/dietpi-set_hardware rpi-camera disable
- REBOOT_REQUIRED=1
+ /DietPi/dietpi/func/dietpi-set_hardware rpi-camera enable
fi
+ REBOOT_REQUIRED=1
else
@@ -555,19 +504,18 @@
#RPI only
if (( $G_HW_MODEL < 10 )); then
- if (( ! $rpi_camera_led_enabled )); then
+ if (( $rpi_camera_led_disabled )); then
- #enable
+ #disable
G_CONFIG_INJECT 'disable_camera_led=' 'disable_camera_led=0' /DietPi/config.txt
- REBOOT_REQUIRED=1
else
- #disable
+ #enable
G_CONFIG_INJECT 'disable_camera_led=' 'disable_camera_led=1' /DietPi/config.txt
- REBOOT_REQUIRED=1
fi
+ REBOOT_REQUIRED=1
else
@@ -578,18 +526,18 @@
elif (( $G_WHIP_RETURNED_VALUE == 10 )); then
# - Enable
- if (( ! $odroid_remote_enabled )); then
+ if (( $odroid_remote_enabled )); then
- G_WHIP_YESNO "This will enable the IR modules, setup Lirc and the Odroid Remote for Odroid C1, C2 and XU4 Cloudshell.\n\nNB: Other remotes can be configured by running 'irrecord' and applying the codes to '/etc/lirc/lircd.conf'\n\nDo you wish to continue?"
- if (( $? == 0 )); then
+ /DietPi/dietpi/func/dietpi-set_hardware remoteir none
- /DietPi/dietpi/func/dietpi-set_hardware remoteir odroid_remote
+ else
- fi
+ if G_WHIP_YESNO "This will enable the IR modules, setup Lirc and the Odroid Remote for Odroid C1, C2 and XU4 Cloudshell.
+\nNB: Other remotes can be configured by running 'irrecord' and applying the codes to '/etc/lirc/lircd.conf'\n\nDo you wish to continue?"; then
- else
+ /DietPi/dietpi/func/dietpi-set_hardware remoteir odroid_remote
- /DietPi/dietpi/func/dietpi-set_hardware remoteir none
+ fi
fi
@@ -598,18 +546,18 @@
elif (( $G_WHIP_RETURNED_VALUE == 11 )); then
# - Enable
- if (( ! $justboom_ir_remote_enabled )); then
+ if (( $justboom_ir_remote_enabled )); then
- G_WHIP_YESNO 'Got a JustBoom IR Remote? Excellent!\n\nDietPi will enable the IR modules, setup Lirc and enable support for MPD controls by default:\n\nDo you wish to continue?'
- if (( $? == 0 )); then
+ /DietPi/dietpi/func/dietpi-set_hardware remoteir none
- /DietPi/dietpi/func/dietpi-set_hardware remoteir justboom_ir_remote
+ else
- fi
+ if G_WHIP_YESNO 'Got a JustBoom IR Remote? Excellent!
+\nDietPi will enable the IR modules, setup Lirc and enable support for MPD controls by default:\n\nDo you wish to continue?'; then
- else
+ /DietPi/dietpi/func/dietpi-set_hardware remoteir justboom_ir_remote
- /DietPi/dietpi/func/dietpi-set_hardware remoteir none
+ fi
fi
@@ -617,25 +565,14 @@
elif (( $G_WHIP_RETURNED_VALUE == 12 )); then
- G_WHIP_DEFAULT_ITEM="$vc1_key_current"
- G_WHIP_INPUTBOX 'Please enter your key for VC1:\n - EG: 0x00000000'
- if (( $? == 0 )); then
-
- if ! grep -qi 'decode_WVC1=' /DietPi/config.txt; then
-
- echo -e "\ndecode_WVC1=0x00000000" >> /DietPi/config.txt
-
- fi
+ G_WHIP_DEFAULT_ITEM=$vc1_key_current
+ if G_WHIP_INPUTBOX 'Please enter your key for VC1:\n - EG: 0x00000000'; then
G_CONFIG_INJECT 'decode_WVC1=' "decode_WVC1=$G_WHIP_RETURNED_VALUE" /DietPi/config.txt
#https://github.com/Fourdee/DietPi/issues/1487
- local current_gpu_mem=$(grep -m1 '^[[:blank:]]*gpu_mem' /DietPi/config.txt | sed 's/^[^=]*=//g')
- if (( $current_gpu_mem < 128 )); then
-
- /DietPi/dietpi/func/dietpi-set_hardware gpumemsplit 128
-
- fi
+ local current_gpu_mem=$(grep -m1 '^[[:blank:]]*gpu_mem_1024' /DietPi/config.txt | sed 's/^[^=]*=//g')
+ (( $current_gpu_mem < 128 )) && /DietPi/dietpi/func/dietpi-set_hardware gpumemsplit 128
REBOOT_REQUIRED=1
@@ -643,25 +580,14 @@
elif (( $G_WHIP_RETURNED_VALUE == 13 )); then
- G_WHIP_DEFAULT_ITEM="$mpeg2_key_current"
- G_WHIP_INPUTBOX 'Please enter your key for MPEG2:\n - EG: 0x00000000'
- if (( $? == 0 )); then
-
- if ! grep -qi 'decode_MPG2=' /DietPi/config.txt; then
-
- echo -e "\ndecode_MPG2=0x00000000" >> /DietPi/config.txt
-
- fi
+ G_WHIP_DEFAULT_ITEM=$mpeg2_key_current
+ if G_WHIP_INPUTBOX 'Please enter your key for MPEG2:\n - EG: 0x00000000'; then
G_CONFIG_INJECT 'decode_MPG2=' "decode_MPG2=$G_WHIP_RETURNED_VALUE" /DietPi/config.txt
#https://github.com/Fourdee/DietPi/issues/1487
- local current_gpu_mem=$(grep -m1 '^[[:blank:]]*gpu_mem' /DietPi/config.txt | sed 's/^[^=]*=//g')
- if (( $current_gpu_mem < 128 )); then
-
- /DietPi/dietpi/func/dietpi-set_hardware gpumemsplit 128
-
- fi
+ local current_gpu_mem=$(grep -m1 '^[[:blank:]]*gpu_mem_1024' /DietPi/config.txt | sed 's/^[^=]*=//g')
+ (( $current_gpu_mem < 128 )) && /DietPi/dietpi/func/dietpi-set_hardware gpumemsplit 128
REBOOT_REQUIRED=1
@@ -680,11 +606,11 @@
)
- G_WHIP_DEFAULT_ITEM="$rotation_hdmi_current"
- G_WHIP_MENU "Please select an option:\n\nNB: If you have the RPi touchscreen, please set this to 0 and use LCD rotation option."
- if (( $? == 0 )); then
+ G_WHIP_DEFAULT_ITEM=$rotation_hdmi_current
+ if G_WHIP_MENU "Please select an option:
+\nNB: If you have the RPi touchscreen, please set this to 0 and use LCD rotation option."; then
- G_CONFIG_INJECT 'display_rotate=' "display_rotate=$G_WHIP_RETURNED_VALUE" /DietPi/config.txt
+ G_CONFIG_INJECT 'display_hdmi_rotate=' "display_hdmi_rotate=$G_WHIP_RETURNED_VALUE" /DietPi/config.txt
# rotation 90/270 | invert x/y on FB (Y > X)
if [[ $G_WHIP_RETURNED_VALUE == '1' || $G_WHIP_RETURNED_VALUE == '3' ]]; then
@@ -698,7 +624,6 @@
fi
-
REBOOT_REQUIRED=1
fi
@@ -712,12 +637,10 @@
)
- G_WHIP_DEFAULT_ITEM="$rotation_lcd_current"
- G_WHIP_MENU 'Please select an option:\n\nNB: This option is for RPi touchscreen.'
- if (( $? == 0 )); then
-
- sed -i "/lcd_rotate=/c\lcd_rotate=$G_WHIP_RETURNED_VALUE" /DietPi/config.txt
+ G_WHIP_DEFAULT_ITEM=$rotation_lcd_current
+ if G_WHIP_MENU 'Please select an option:\n\nNB: This option is for RPi touchscreen.'; then
+ G_CONFIG_INJECT 'lcd_rotate=' "lcd_rotate=$G_WHIP_RETURNED_VALUE" /DietPi/config.txt
REBOOT_REQUIRED=1
fi
@@ -740,29 +663,23 @@
MIN_VALUE=0
MAX_VALUE=255
- local index_apply=0
+ local fp_brightness=''
local current_brightness=''
- for ((i=0; i<${#afp_current_set_brightness[@]}; i++))
+ for fp_brightness in "${afp_current_set_brightness[@]}"
do
- if [[ -f ${afp_current_set_brightness[$i]}/brightness ]]; then
-
- current_brightness=$(<${afp_current_set_brightness[$i]}/brightness)
- if [[ -f ${afp_current_set_brightness[$i]}/max_brightness ]]; then
+ if [[ -f $fp_brightness/brightness ]]; then
- MAX_VALUE=$(<${afp_current_set_brightness[$i]}/max_brightness)
-
- fi
-
- index_apply=$i
+ current_brightness=$(<$fp_brightness/brightness)
+ [[ -f $fp_brightness/max_brightness ]] && MAX_VALUE=$(<$fp_brightness/max_brightness)
break
fi
done
- if disable_error=1 G_CHECK_VALIDINT $current_brightness; then
+ if disable_error=1 G_CHECK_VALIDINT "$current_brightness"; then
G_WHIP_DEFAULT_ITEM=$current_brightness
G_WHIP_INPUTBOX "Please enter a brightness value:\n - Min = $MIN_VALUE | Max = $MAX_VALUE"
@@ -771,7 +688,7 @@
if G_CHECK_VALIDINT $G_WHIP_RETURNED_VALUE $MIN_VALUE $MAX_VALUE; then
# - apply
- echo $G_WHIP_RETURNED_VALUE > ${afp_current_set_brightness[$index_apply]}/brightness
+ echo $G_WHIP_RETURNED_VALUE > $fp_brightness/brightness
fi
@@ -798,12 +715,14 @@
)
G_WHIP_DEFAULT_ITEM=$xorg_dpi_current
- G_WHIP_MENU "Please select a DPI value for Xorg:\n - A higher value will make text and windows larger\n - Has no effect on local terminal (eg: no desktop installed)\n\nNB: Setting will only take effect, once system is restarted."
- if (( $? == 0 )); then
+ if G_WHIP_MENU "Please select a DPI value for Xorg:
+ - A higher value will make text and windows larger
+ - Has no effect on local terminal (eg: no desktop installed)
+ \nNB: Setting will only take effect, once system is restarted."; then
G_CONFIG_INJECT 'SOFTWARE_XORG_DPI=' "SOFTWARE_XORG_DPI=$G_WHIP_RETURNED_VALUE" /DietPi/dietpi.txt
mkdir -p /etc/X11/Xsession.d
- echo -e "xrandr --dpi $G_WHIP_RETURNED_VALUE" > /etc/X11/Xsession.d/99-dietpi-dpi
+ echo "xrandr --dpi $G_WHIP_RETURNED_VALUE" > /etc/X11/Xsession.d/99-dietpi-dpi
REBOOT_REQUIRED=1
fi
@@ -818,8 +737,10 @@
Xorg_Configure(){
- G_WHIP_YESNO "Xorg Configuration:\nNB: This feature will only work if X server is NOT currently running.\n\nPlease ensure:\n - No current X server (desktop) is running\n\nIf a desktop is running, please set 'dietpi-autostart' to 'Console', reboot system, then rerun this option.\n\nWould you like to continue?"
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Xorg Configuration:\nNB: This feature will only work if X server is NOT currently running.
+\nPlease ensure:\n - No current X server (desktop) is running
+\nIf a desktop is running, please set 'dietpi-autostart' to 'Console', reboot system, then rerun this option.
+\nWould you like to continue?"; then
G_RUN_CMD Xorg -configure
mv $HOME/xorg.conf.new /etc/X11/xorg.conf
@@ -837,8 +758,8 @@
#VM
if (( $G_HW_MODEL == 20 )); then
- local current="$(grep -m1 '^[[:blank:]]*GRUB_GFXMODE=' /etc/default/grub | sed 's/^[^=]*=//')"
- [[ ! $current ]] && current='System default'
+ local current=$(grep -m1 '^[[:blank:]]*GRUB_GFXMODE=' /etc/default/grub | sed 's/^[^=]*=//')
+ [[ $current ]] || current='System default'
G_WHIP_MENU_ARRAY=(
@@ -851,9 +772,10 @@
)
- G_WHIP_DEFAULT_ITEM="$current"
- G_WHIP_MENU 'Please select a display resolution. Current: $current\n\nNote: This only affects the virtual screen resolution, not the SSH session.\n You might need to increase the maximum guest screen resolution within your VM software.'
- if (( ! $? )); then
+ G_WHIP_DEFAULT_ITEM=$current
+ if G_WHIP_MENU "Please select a display resolution. Current: $current
+\nNB: This only affects the virtual screen resolution, not the SSH session.
+ You might need to increase the maximum guest screen resolution within your VM software."; then
if [[ $G_WHIP_RETURNED_VALUE == 'System default' ]]; then
@@ -899,20 +821,19 @@
)
- G_WHIP_MENU 'Please select an option:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select an option:'; then
TARGETMENUID=2
if [[ $G_WHIP_RETURNED_VALUE == 'Nvidia' ]]; then
- if (( ! $nvidia_installed )); then
+ if (( $nvidia_installed )); then
- /DietPi/dietpi/dietpi-software install 151
+ /DietPi/dietpi/dietpi-software uninstall 151
else
- /DietPi/dietpi/dietpi-software uninstall 151
+ /DietPi/dietpi/dietpi-software install 151
fi
@@ -920,14 +841,14 @@
elif [[ $G_WHIP_RETURNED_VALUE == 'Intel' ]]; then
- if (( ! $intel_installed )); then
+ if (( $intel_installed )); then
- G_AG_CHECK_INSTALL_PREREQ xserver-xorg-video-intel libgl1-mesa-dri
- Xorg_Configure
+ G_AGP xserver-xorg-video-intel #Must test removal deps...
else
- G_AGP xserver-xorg-video-intel #Must test removal deps...
+ G_AG_CHECK_INSTALL_PREREQ xserver-xorg-video-intel libgl1-mesa-dri
+ Xorg_Configure
fi
@@ -938,20 +859,19 @@
#RPI
elif (( $G_HW_MODEL < 10 )); then
- local framebuffer_x=$(grep -m1 'framebuffer_width=' /DietPi/config.txt | sed 's/^[^=]*=//')
- local framebuffer_y=$(grep -m1 'framebuffer_height=' /DietPi/config.txt | sed 's/^[^=]*=//')
- local current_value=$(grep -m1 '^dtoverlay=vc4-' /DietPi/config.txt | sed 's/^[^=]*=//') #OpenGL check 1st
+ local framebuffer_x=$(grep -m1 '^[[:blank:]]*framebuffer_width=' /DietPi/config.txt || vcgencmd get_config framebuffer_width)
+ framebuffer_x=${framebuffer_x#*=}; framebuffer_x=${framebuffer_x:-0}
+ local framebuffer_y=$(grep -m1 '^[[:blank:]]*framebuffer_height=' /DietPi/config.txt || vcgencmd get_config framebuffer_height)
+ framebuffer_y=${framebuffer_y#*=}; framebuffer_y=${framebuffer_y:-0}
+ local current_value=$(grep -m1 '^[[:blank:]]*dtoverlay=vc4-' /DietPi/config.txt | sed 's/^[^=]*=//') #OpenGL check 1st
if [[ ! $current_value ]]; then
# - FB
current_value="$framebuffer_x X $framebuffer_y"
# - check for headless
- if grep -qi 'CONFIG_HDMI_OUTPUT=0' /DietPi/dietpi.txt; then
-
- current_value='Headless'
-
- fi
+ grep -qi 'hdmi_ignore_hotplug=1' /DietPi/config.txt &&
+ grep -qi 'hdmi_ignore_composite=1' /DietPi/config.txt && current_value='Headless'
fi
@@ -975,42 +895,57 @@
)
- G_WHIP_DEFAULT_ITEM="$current_value"
- G_WHIP_MENU "Hardware: $G_HW_MODEL_DESCRIPTION\nCurrent resolution: $current_value"
- if (( $? == 0 )); then
+ G_WHIP_DEFAULT_ITEM=$current_value
+ if G_WHIP_MENU "Hardware: $G_HW_MODEL_DESCRIPTION\nCurrent resolution: $current_value"; then
REBOOT_REQUIRED=1
#Return to This Menu
TARGETMENUID=2
- # - Always enable HDMI output by default
- G_CONFIG_INJECT 'CONFIG_HDMI_OUTPUT=' 'CONFIG_HDMI_OUTPUT=1' /DietPi/dietpi.txt
+ if [[ $G_WHIP_RETURNED_VALUE == 'Headless' ]]; then
+
+ G_WHIP_YESNO 'Using the Headless option will:
+ - Disable HDMI and composite output
+ - Disable the framebuffer
+ - Lower energy consumption by 0.1+ Watts
+ - Improve RAM performance by 1-5% (VideoCore shares RAM bandwidth)
+ - Lead to some kernel error messages on boot, that can be ignored\n
+Re-enabling HDMI requires a reboot. If you need emergency HDMI output, comment or remove the following lines within "config.txt" on first partition of the SDcard from external system:
+ - hdmi_ignore_hotplug=1
+ - hdmi_ignore_composite=1\n
+More info here: https://www.raspberrypi.org/forums/viewtopic.php?p=105008#p105008
+ and here: https://github.com/raspberrypi/userland/issues/447#issuecomment-404399670' || { REBOOT_REQUIRED=0; return; }
- # - Always set default depth to 16
- G_CONFIG_INJECT 'framebuffer_depth=' 'framebuffer_depth=16' /DietPi/config.txt
+ /DietPi/dietpi/func/dietpi-set_hardware headless 1
+
+ else
+
+ /DietPi/dietpi/func/dietpi-set_hardware headless 0
+
+ fi
# - Always disable composite by default
- sed -i '/sdtv_mode=/c\#sdtv_mode=0' /DietPi/config.txt
+ [[ $G_WHIP_RETURNED_VALUE == 'sdtv_mode'* ]] || sed -i '/sdtv_mode=/c\#sdtv_mode=0' /DietPi/config.txt
- # - Always disable OpenGL by default:
- /DietPi/dietpi/func/dietpi-set_hardware rpi-opengl disable
+ # - Always disable OpenGL by default
+ [[ $G_WHIP_RETURNED_VALUE == 'vc4-'* ]] || /DietPi/dietpi/func/dietpi-set_hardware rpi-opengl disable
if [[ $G_WHIP_RETURNED_VALUE == 'vc4-'* ]]; then
/DietPi/dietpi/func/dietpi-set_hardware rpi-opengl $G_WHIP_RETURNED_VALUE
- elif [[ $G_WHIP_RETURNED_VALUE == 'sdtv_mode'* ]]; then
+ elif [[ $G_WHIP_RETURNED_VALUE != 'Headless' ]]; then
- sed -i "/sdtv_mode=/c $G_WHIP_RETURNED_VALUE" /DietPi/config.txt
- framebuffer_x=720
- framebuffer_y=576
- G_CONFIG_INJECT 'framebuffer_width=' "framebuffer_width=$framebuffer_x" /DietPi/config.txt
- G_CONFIG_INJECT 'framebuffer_height=' "framebuffer_height=$framebuffer_y" /DietPi/config.txt
+ case "$G_WHIP_RETURNED_VALUE" in
- else
+ 'sdtv_mode'*)
- case "$G_WHIP_RETURNED_VALUE" in
+ sed -i "/sdtv_mode=/c\\$G_WHIP_RETURNED_VALUE" /DietPi/config.txt
+ framebuffer_x=720
+ framebuffer_y=576
+
+ ;;
'DietPi-Cloudshell')
@@ -1068,17 +1003,6 @@
;;
- 'Headless')
-
- framebuffer_x=16
- framebuffer_y=16
-
- G_WHIP_MSG "Using the Headless option will: \n - Disable HDMI output \n - Lower energy consumption by 0.1+ Watts \n - Set framebuffer to 16x16xD8 \n - Improve RAM performance by 1-5% (VideoCore shares RAM bandwidth) \n - More info here : https://www.raspberrypi.org/forums/viewtopic.php?p=105008#p105008"
- sed -i "/CONFIG_HDMI_OUTPUT=/c\CONFIG_HDMI_OUTPUT=0" /DietPi/dietpi.txt
- sed -i '/framebuffer_depth=/c\framebuffer_depth=8' /DietPi/config.txt
-
- ;;
-
esac
# - Apply x/y
@@ -1095,7 +1019,7 @@
elif (( $G_HW_MODEL == 10 )); then
#Get Current Values
- local current_resolution=$(grep -m1 'setenv m "' /DietPi/boot.ini | awk -F '"' '{print $2}')
+ local current_resolution=$(mawk -F '"' '/setenv m "/ {print $2;exit}' /DietPi/boot.ini)
G_WHIP_MENU_ARRAY=(
@@ -1107,9 +1031,8 @@
)
- G_WHIP_DEFAULT_ITEM="$current_resolution"
- G_WHIP_MENU "Hardware : $G_HW_MODEL_DESCRIPTION\nCurrent: $current_resolution"
- if (( $? == 0 )); then
+ G_WHIP_DEFAULT_ITEM=$current_resolution
+ if G_WHIP_MENU "Hardware : $G_HW_MODEL_DESCRIPTION\nCurrent: $current_resolution"; then
REBOOT_REQUIRED=1
@@ -1160,7 +1083,7 @@
elif (( $G_HW_MODEL == 11 )); then
#Get Current Values
- local current_resolution="$(grep -m1 'setenv videoconfig \"' /DietPi/boot.ini)"
+ local current_resolution=$(grep -m1 'setenv videoconfig \"' /DietPi/boot.ini)
if [[ $current_resolution == *'1920x1080'* ]]; then
current_resolution='1080p'
@@ -1184,9 +1107,8 @@
)
- G_WHIP_DEFAULT_ITEM="$current_resolution"
- G_WHIP_MENU "Hardware : $G_HW_MODEL_DESCRIPTION \nCurrent: $current_resolution"
- if (( $? == 0 )); then
+ G_WHIP_DEFAULT_ITEM=$current_resolution
+ if G_WHIP_MENU "Hardware : $G_HW_MODEL_DESCRIPTION \nCurrent: $current_resolution"; then
REBOOT_REQUIRED=1
@@ -1209,7 +1131,7 @@
elif (( $G_HW_MODEL == 12 )); then
#Get Current Values
- local current_resolution=$(cat /DietPi/boot.ini | grep -m1 'setenv m "' | awk -F '"' '{print $2}' | sed 's/p/p /')
+ local current_resolution=$(mawk -F '"' '/setenv m "/ {print $2;exit}' /DietPi/boot.ini | sed 's/p/p /')
# - NB: also added space after xxxp, so its easier to read, and selects default item.
G_WHIP_MENU_ARRAY=(
@@ -1231,15 +1153,10 @@
)
- G_WHIP_DEFAULT_ITEM="$current_resolution"
- G_WHIP_MENU "Hardware : $G_HW_MODEL_DESCRIPTION \nCurrent: $current_resolution"
- if (( $? == 0 )); then
-
- if [[ $current_resolution != $G_WHIP_RETURNED_VALUE ]]; then
+ G_WHIP_DEFAULT_ITEM=$current_resolution
+ if G_WHIP_MENU "Hardware : $G_HW_MODEL_DESCRIPTION \nCurrent: $current_resolution"; then
- REBOOT_REQUIRED=1
-
- fi
+ [[ $current_resolution != $G_WHIP_RETURNED_VALUE ]] && REBOOT_REQUIRED=1
# - Always reset vga/dvi options
sed -i '/setenv vout "dvi"/c\# setenv vout "dvi"' /DietPi/boot.ini
@@ -1254,7 +1171,7 @@
fi
#Remove the space from option
- local temp_string=$(echo -e "$G_WHIP_RETURNED_VALUE" | tr -d '[:blank:]')
+ local temp_string=$(echo "$G_WHIP_RETURNED_VALUE" | tr -d '[:blank:]')
sed -i "/setenv m /c\setenv m \"$temp_string\"" /DietPi/boot.ini
@@ -1268,7 +1185,7 @@
#Get Current Values
local current_resolution=$(grep -m1 '^[[:blank:]]*hdmi_mode=' /DietPi/uEnv.txt | sed 's/^[^=]*=//')
- [[ ! $current_resolution ]] && current_resolution='Not set'
+ [[ $current_resolution ]] || current_resolution='Not set'
G_WHIP_MENU_ARRAY=(
@@ -1285,9 +1202,8 @@
)
- G_WHIP_DEFAULT_ITEM="$current_resolution"
- G_WHIP_MENU "Hardware : $G_HW_MODEL_DESCRIPTION \nCurrent: $current_resolution"
- if (( $? == 0 )); then
+ G_WHIP_DEFAULT_ITEM=$current_resolution
+ if G_WHIP_MENU "Hardware : $G_HW_MODEL_DESCRIPTION \nCurrent: $current_resolution"; then
if [[ $current_resolution != $G_WHIP_RETURNED_VALUE ]]; then
@@ -1317,8 +1233,8 @@
G_WHIP_MENU_ARRAY=()
#Swap file
- local swap_size=$(free -m | grep -im1 'Swap:' | awk '{print $2}')
- local swap_location="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
+ local swap_size=$(free -m | mawk '/Swap:/ {print $2;exit}')
+ local swap_location=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
local swap_size_text="$swap_size MB"
(( ! $swap_size )) && swap_size_text='[Off]'
G_WHIP_MENU_ARRAY+=('Swapfile' ": [$swap_size_text | $swap_location]")
@@ -1351,7 +1267,7 @@
local rtc_enabled=0
local rtc_text='Emulated'
- if [[ ! $(which fake-hwclock) ]]; then
+ if ! command -v fake-hwclock &> /dev/null; then
rtc_enabled=1
rtc_text='Hardware'
@@ -1368,11 +1284,7 @@
#Serial console
local serialconsole_state=$(grep -m1 '^[[:blank:]]*CONFIG_SERIAL_CONSOLE_ENABLE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
local serialconsole_text='[Off]'
- if (( $serialconsole_state )); then
-
- serialconsole_text='[On]'
-
- fi
+ (( $serialconsole_state )) && serialconsole_text='[On]'
G_WHIP_MENU_ARRAY+=('Serial console' ": $serialconsole_text")
#Bluetooth
@@ -1393,32 +1305,20 @@
local rpi_i2c_enabled=$(grep -ci -m1 '^[[:blank:]]*dtparam=i2c_arm=on' /DietPi/config.txt)
local rpi_i2c_text='[Off]'
- if (( $rpi_i2c_enabled )); then
-
- rpi_i2c_text='[On]'
+ (( $rpi_i2c_enabled )) && rpi_i2c_text='[On]'
- fi
-
- local rpi_i2cbaudrate_hz="$(grep -m1 '^[[:blank:]]*i2c_arm_baudrate=' /DietPi/config.txt | sed 's/^[^=]*=//')"
+ local rpi_i2cbaudrate_hz=$(grep -m1 '^[[:blank:]]*i2c_arm_baudrate=' /DietPi/config.txt | sed 's/^[^=]*=//')
# Allow commented/non-existent entry, using default value: https://github.com/raspberrypi/firmware/blob/d69aadedb7c146ba5d3b0b45a661e5669a9141c4/boot/overlays/README#L115-L116
rpi_i2cbaudrate_hz="$(( ${rpi_i2cbaudrate_hz:-100000} / 1000 )) kHz"
- local usb_max_current_enabled=$(grep -ci -m1 'max_usb_current=1' /DietPi/config.txt)
+ local usb_max_current_enabled=$(grep -ci -m1 '^[[:blank:]]*max_usb_current=1' /DietPi/config.txt)
local rpi_usbmaxcurrent_text='[Off]'
- if (( $usb_max_current_enabled )); then
-
- rpi_usbmaxcurrent_text='[On]'
-
- fi
+ (( $usb_max_current_enabled )) && rpi_usbmaxcurrent_text='[On]'
if (( $G_HW_MODEL == 3 )); then
local rpi3_usb_boot_bit_enabled=$(vcgencmd otp_dump | grep -m1 '17:' | grep -ci -m1 '3020000a')
local rpi3_usb_boot_bit_enabled_text='[Off]'
- if (( $rpi3_usb_boot_bit_enabled )); then
-
- rpi3_usb_boot_bit_enabled_text='[On]'
-
- fi
+ (( $rpi3_usb_boot_bit_enabled )) && rpi3_usb_boot_bit_enabled_text='[On]'
G_WHIP_MENU_ARRAY+=('USB boot support' ": $rpi3_usb_boot_bit_enabled_text")
@@ -1430,16 +1330,15 @@
fi
- G_WHIP_MENU 'Please select an option:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select an option:'; then
#Return to This Menu
TARGETMENUID=3
if [[ $G_WHIP_RETURNED_VALUE == 'Swapfile' ]]; then
- G_WHIP_YESNO 'Swapfile control has been moved to DietPi-Drive_Manager, would you like to run the application now?\n\nOnce finished, exit to resume DietPi-Config'
- if (( $? == 0 )); then
+ if G_WHIP_YESNO 'Swapfile control has been moved to DietPi-Drive_Manager, would you like to run the application now?
+\nOnce finished, exit to resume DietPi-Config'; then
/DietPi/dietpi/dietpi-drive_manager
@@ -1455,9 +1354,13 @@
G_AGI fake-hwclock
+ systemctl stop fake-hwclock
+
# - allow times in the past
G_CONFIG_INJECT 'FORCE=' 'FORCE=force' /etc/default/fake-hwclock
+ systemctl restart fake-hwclock
+
fi
elif [[ $G_WHIP_RETURNED_VALUE == 'Time sync mode' ]]; then
@@ -1472,7 +1375,7 @@
)
- G_WHIP_DEFAULT_ITEM="$ntpd_mode_current"
+ G_WHIP_DEFAULT_ITEM=$ntpd_mode_current
G_WHIP_MENU 'Here you can adjust the frequency of network time syncs.\n
- Modes 1-3:\nDietPi will launch systemd-timesyncd as a program, rather than a daemon. Once the time has been updated on your system, timesyncd will exit to reduce resource usage.\n
- Mode 4:\nsystemd-timesyncd will run as a background daemon/service. Differences in time will be gradually adjusted over time, rather than instantly.\n
@@ -1486,22 +1389,13 @@
elif [[ $G_WHIP_RETURNED_VALUE == 'Update firmware' ]]; then
- #RPI
- if (( $G_HW_MODEL < 10 )); then
-
- G_WHIP_YESNO "Would you like to update the firmware/kernel for $G_HW_MODEL_DESCRIPTION?\n - This will run G_RPI_UPDATE, a wrapper for rpi-update"
- if (( $? == 0 )); then
-
- G_RPI_UPDATE
- REBOOT_REQUIRED=1
-
- fi
+ local old_firmware=$(ls /lib/modules/)
#PineA64
- elif (( $G_HW_MODEL == 40 )); then
+ if (( $G_HW_MODEL == 40 )); then
- G_WHIP_YESNO "Would you like to update the firmware/kernel for $G_HW_MODEL_DESCRIPTION?\n - This will run longsleep's update scripts to update the U-Boot and kernel."
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Would you like to update the firmware/kernel for $G_HW_MODEL_DESCRIPTION?
+ - This will run longsleep's update scripts to update the U-Boot and kernel."; then
/usr/local/sbin/pine64_update_uboot.sh
/usr/local/sbin/pine64_update_kernel.sh
@@ -1509,25 +1403,25 @@
fi
#G_AGDUG based (not all devices support this)
- else
+ elif G_WHIP_YESNO "Would you like to update the firmware/kernel for $G_HW_MODEL_DESCRIPTION?
+ - This will run G_AGDUG, a wrapper for 'apt-get dist-upgrade'\n - Most (but not all) devices allow APT based firmware updates
+ \nNB: If requested to overwrite the current kernel, press TAB and then ENTER (to confirm)."; then
- G_WHIP_YESNO "Would you like to update the firmware/kernel for $G_HW_MODEL_DESCRIPTION?\n - This will run G_AGDUG, a wrapper for 'apt-get dist-upgrade'\n - Most (but not all) devices allow APT based firmware updates\n\nNB: If requested to overwrite the current kernel, press TAB and then ENTER (to confirm)."
- if (( $? == 0 )); then
-
- G_AGUP
- G_AGDUG
-
- fi
+ G_AGUP
+ G_AGDUG
fi
+ #Reboot required only, if firmware got actually updated
+ [[ $old_firmware != $(ls /lib/modules/) ]] && REBOOT_REQUIRED=1
+
elif [[ $G_WHIP_RETURNED_VALUE == 'Max USB current' ]]; then
#Enabled
if (( $usb_max_current_enabled == 1 )); then
- G_WHIP_YESNO "Current setting: $rpi_usbmaxcurrent_text (1.2AMP) \n Would you like to disable this setting ? \n \n Once Disabled: \n - Max USB current will be limited to 0.6AMP.\n - Shared by all USB ports."
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Current setting: $rpi_usbmaxcurrent_text (1.2AMP)\nWould you like to disable this setting?
+\nOnce Disabled:\n - Max USB current will be limited to 0.6AMP.\n - Shared by all USB ports."; then
sed -i '/max_usb_current=/c\max_usb_current=0' /DietPi/config.txt
REBOOT_REQUIRED=1
@@ -1537,8 +1431,8 @@
#Disabled
elif (( $usb_max_current_enabled == 0 )); then
- G_WHIP_YESNO "Current setting: $rpi_usbmaxcurrent_text (0.6AMP) \n Would you like to enable this setting ? \n \n Once Enabled: \n - Max USB current will be set to 1.2AMP.\n - Shared by all USB ports."
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Current setting: $rpi_usbmaxcurrent_text (0.6AMP)\nWould you like to enable this setting?
+\nOnce Enabled:\n - Max USB current will be set to 1.2AMP.\n - Shared by all USB ports."; then
sed -i '/max_usb_current=/c\max_usb_current=1' /DietPi/config.txt
REBOOT_REQUIRED=1
@@ -1564,8 +1458,7 @@
#remove kHz from current
G_WHIP_DEFAULT_ITEM=$(echo -e "$rpi_i2cbaudrate_hz" | tr -d ' kHz')
- G_WHIP_INPUTBOX 'Please enter the required i2c baudrate frequency (kHz).'
- if (( $? == 0 )); then
+ if G_WHIP_INPUTBOX 'Please enter the required i2c baudrate frequency (kHz).'; then
#check valid int
if G_CHECK_VALIDINT $G_WHIP_RETURNED_VALUE; then
@@ -1579,13 +1472,13 @@
elif [[ $G_WHIP_RETURNED_VALUE == 'Serial console' ]]; then
- if (( $serialconsole_state == 0 )); then
+ if (( $serialconsole_state )); then
- /DietPi/dietpi/func/dietpi-set_hardware serialconsole enable
+ /DietPi/dietpi/func/dietpi-set_hardware serialconsole disable
else
- /DietPi/dietpi/func/dietpi-set_hardware serialconsole disable
+ /DietPi/dietpi/func/dietpi-set_hardware serialconsole enable
fi
REBOOT_REQUIRED=1
@@ -1606,19 +1499,16 @@
if (( ! $rpi3_usb_boot_bit_enabled )); then
- G_WHIP_YESNO 'The following will enable the RPi 3 to boot from USB mass storage devices. A hardware bit "17:3020000a", specific to the device is set to enable the feature.\n\nNB:\n - Not all USB mass storage devices are supported\n - The HW bit which enables this setting is non-reversible\n\nDo you wish to enable USB mass storage boot support?'
- if (( $? == 0 )); then
+ if G_WHIP_YESNO 'The following will enable the RPi 3 to boot from USB mass storage devices. A hardware bit "17:3020000a", specific to the device is set to enable the feature.
+\nNB:\n - Not all USB mass storage devices are supported\n - The HW bit which enables this setting is non-reversible
+\nDo you wish to enable USB mass storage boot support?'; then
/DietPi/dietpi/func/dietpi-set_hardware rpi3_usb_boot enable
REBOOT_REQUIRED=1
# Reboot now?
G_WHIP_YESNO 'A reboot is required to apply this setting.\n\nPlease reboot this system once, the HW bit which allows USB boot support will then be set. After which, USB mass storage devices can be used for booting.\n\nWould you like to reboot the system now?'
- if (( $? == 0 )); then
-
- reboot
-
- fi
+ (( $? )) || reboot
fi
@@ -1656,27 +1546,23 @@
local cpu_temp=$(G_OBTAIN_CPU_TEMP)
local cpu_temp_f='Unknown'
- if disable_error=1 G_CHECK_VALIDINT $cpu_temp; then
+ if disable_error=1 G_CHECK_VALIDINT "$cpu_temp"; then
cpu_temp_f="$(( ( $cpu_temp * 9 / 5 ) + 32 ))'f"
cpu_temp+="'c"
fi
- local memory_total=$(( $(grep -m1 'MemTotal:' /proc/meminfo | awk '{print $2}') / 1000 ))
- local memory_free=$(( $(grep -m1 'MemFree:' /proc/meminfo | awk '{print $2}') / 1000 ))
+ local memory_total=$(( $(mawk '/MemTotal:/ {print $2;exit}' /proc/meminfo) / 1000 ))
+ local memory_free=$(( $(mawk '/MemFree:/ {print $2;exit}' /proc/meminfo) / 1000 ))
local memory_usage=$(( $memory_total - $memory_free ))
#Create Menu List for Whiptail
# - this will list the menu options available for each device.
G_WHIP_MENU_ARRAY=()
- #Overclocking
- if (( $G_HW_MODEL < 10 )); then
-
- G_WHIP_MENU_ARRAY+=('Overclocking' ': Set Profile')
-
- fi
+ #RPi: Overclocking
+ (( $G_HW_MODEL < 10 )) && G_WHIP_MENU_ARRAY+=('Overclocking' ': Set Profile')
#CPU GOV
G_WHIP_MENU_ARRAY+=('CPU Governor' ": [$current_cpu_governor]")
@@ -1706,29 +1592,17 @@
#Define CPU scaling frequency or percent
local type_cpu_freq_info='MHz'
# - Intel
- if [[ -f /sys/devices/system/cpu/intel_pstate/max_perf_pct ]]; then
-
- type_cpu_freq_info='%'
-
- fi
+ [[ -f /sys/devices/system/cpu/intel_pstate/max_perf_pct ]] && type_cpu_freq_info='%'
# - User Scaling Max Freq limit.
local user_frequency_max_current=$(grep -m1 '^[[:blank:]]*CONFIG_CPU_MAX_FREQ=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
local user_frequency_max_text="$user_frequency_max_current $type_cpu_freq_info"
- if (( ! $user_frequency_max_current )); then
-
- user_frequency_max_text='Off'
-
- fi
+ (( $user_frequency_max_current )) || user_frequency_max_text='Off'
# - User Scaling Min Freq limit.
local user_frequency_min_current=$(grep -m1 '^[[:blank:]]*CONFIG_CPU_MIN_FREQ=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
local user_frequency_min_text="$user_frequency_min_current $type_cpu_freq_info"
- if (( ! $user_frequency_min_current )); then
-
- user_frequency_min_text='Off'
-
- fi
+ (( $user_frequency_min_current )) || user_frequency_min_text='Off'
G_WHIP_MENU_ARRAY+=('CPU Frequency Limits' ": Max = [$user_frequency_max_text] | Min = [$user_frequency_min_text]")
@@ -1863,7 +1737,7 @@
# - MAX
if (( $index == 0 )); then
- G_WHIP_DEFAULT_ITEM="$user_frequency_max_current"
+ G_WHIP_DEFAULT_ITEM=$user_frequency_max_current
G_WHIP_MENU "Limit the maximum frequency that your processor can reach.\nThis can be useful for lowering temperature and saving power.\n\nCurrent setting: $user_frequency_max_text"
if (( $? == 0 )); then
@@ -1874,7 +1748,7 @@
# - MIN
else
- G_WHIP_DEFAULT_ITEM="$user_frequency_min_current"
+ G_WHIP_DEFAULT_ITEM=$user_frequency_min_current
G_WHIP_MENU "Limit the minimum frequency that your processor can reach.\nThis can be useful for some timing critical stuff (eg. 1-wire below 480 Mhz won't work).\n\nCurrent setting: $user_frequency_min_text"
if (( $? == 0 )); then
@@ -1950,9 +1824,8 @@
fi
- G_WHIP_DEFAULT_ITEM="$current_cpu_governor"
- G_WHIP_MENU "$Description"
- if (( $? == 0 )); then
+ G_WHIP_DEFAULT_ITEM=$current_cpu_governor
+ if G_WHIP_MENU "$Description"; then
G_CONFIG_INJECT 'CONFIG_CPU_GOVERNOR=' "CONFIG_CPU_GOVERNOR=$G_WHIP_RETURNED_VALUE" /DietPi/dietpi.txt
/DietPi/dietpi/func/dietpi-set_cpu
@@ -2018,19 +1891,14 @@
#Get existing Hostname
local hostname_existing=$(= 512 )); then
- echo 'As above, array is defaulted to RPi1 - 256mb' &> /dev/null
+ G_WHIP_MENU_ARRAY+=(256 ': General Gaming')
+ G_WHIP_MENU_ARRAY+=(320 ': Kodi')
- elif (( $G_HW_MODEL == 1 )); then
+ if (( $ram_mem_total >= 1024 )); then
- available_gpu_values[2]=128
- available_gpu_values[3]=192
+ G_WHIP_MENU_ARRAY+=(448 '')
+ G_WHIP_MENU_ARRAY+=(512 '')
- elif (( $G_HW_MODEL == 2 || $G_HW_MODEL == 3 )); then
-
- available_gpu_values[1]=128
- available_gpu_values[2]=192
- available_gpu_values[3]=256
+ fi
fi
- #Generate text array list for whiptail
- local G_WHIP_MENU_ARRAY=()
- for ((i=0; i<${#option_name[@]}; i++))
- do
-
- G_WHIP_MENU_ARRAY+=("${option_name[$i]}" ": ${available_gpu_values[$i]} MB GPU | $((ram_mem_total - ${available_gpu_values[$i]})) MB RAM")
-
- done
-
+ G_WHIP_DEFAULT_ITEM=$gpu_mem_current
G_WHIP_MENU "Hardware : $G_HW_MODEL_DESCRIPTION\nCurrent: $gpu_mem_current MB GPU | $ram_mem_current MB RAM"
if (( $? == 0 )); then
- #Obtain the selected array index value by matching Option with Option Name
- for ((i=0; i<${#option_name[@]}; i++))
- do
-
- if [[ $G_WHIP_RETURNED_VALUE == ${option_name[$i]} ]]; then
-
- local temp_index=$i
- break
-
- fi
-
- done
-
# Apply
- /DietPi/dietpi/func/dietpi-set_hardware gpumemsplit ${available_gpu_values[$temp_index]}
+ /DietPi/dietpi/func/dietpi-set_hardware gpumemsplit $G_WHIP_RETURNED_VALUE
REBOOT_REQUIRED=1
@@ -2188,10 +2006,6 @@
fi
- #delete [] array
- unset option_name
- unset available_gpu_values
-
#Odroid C1
elif (( $G_HW_MODEL == 10 )); then
@@ -2201,16 +2015,8 @@
local display_output_text='[On]'
local display_vpu_text='[On]'
- if (( $display_output_enabled == 0 )); then
-
- display_output_text='[Off]'
-
- fi
- if (( $display_vpu_enabled == 0 )); then
-
- display_vpu_text='[Off]'
-
- fi
+ (( $display_output_enabled )) || display_output_text='[Off]'
+ (( $display_vpu_enabled )) || display_vpu_text='[Off]'
G_WHIP_MENU_ARRAY=(
@@ -2232,22 +2038,20 @@
'Headless')
- sed -i '/setenv hdmioutput /c\setenv hdmioutput "0"' /DietPi/boot.ini
- sed -i '/setenv vpu /c\setenv vpu "0"' /DietPi/boot.ini
+ /DietPi/dietpi/func/dietpi-set_hardware headless 1
;;
'Server')
- sed -i '/setenv hdmioutput /c\setenv hdmioutput "1"' /DietPi/boot.ini
+ /DietPi/dietpi/func/dietpi-set_hardware headless 0
sed -i '/setenv vpu /c\setenv vpu "0"' /DietPi/boot.ini
;;
'Desktop')
- sed -i '/setenv hdmioutput /c\setenv hdmioutput "1"' /DietPi/boot.ini
- sed -i '/setenv vpu /c\setenv vpu "1"' /DietPi/boot.ini
+ /DietPi/dietpi/func/dietpi-set_hardware headless 0
;;
@@ -2259,14 +2063,10 @@
elif (( $G_HW_MODEL == 12 )); then
#Odroid HDMI/headless extra data
- local display_output_enabled=$(cat /DietPi/boot.ini | grep -ci -m1 '^setenv nographics "0"')
+ local display_output_enabled=$(grep -ci -m1 '^setenv nographics "0"' /DietPi/boot.ini)
local display_output_text='[On]'
- if (( $display_output_enabled == 0 )); then
-
- display_output_text='[Off]'
-
- fi
+ (( $display_output_enabled )) || display_output_text='[Off]'
G_WHIP_MENU_ARRAY=(
@@ -2287,13 +2087,13 @@
'Headless')
- sed -i '/setenv nographics /c\setenv nographics "1"' /DietPi/boot.ini
+ /DietPi/dietpi/func/dietpi-set_hardware headless 1
;;
'Default')
- sed -i '/setenv nographics /c\setenv nographics "0"' /DietPi/boot.ini
+ /DietPi/dietpi/func/dietpi-set_hardware headless 0
;;
@@ -2314,7 +2114,7 @@
TARGETMENUID=0
- local locale_current="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_LOCALE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
+ local locale_current=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_LOCALE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
G_WHIP_MENU_ARRAY=(
@@ -2338,14 +2138,14 @@
G_FILE_EXISTS /usr/share/i18n/SUPPORTED
- cat /usr/share/i18n/SUPPORTED | sed 's/#//g' | awk '{print $1}' | grep 'UTF-8' > /tmp/available_locale
+ cat /usr/share/i18n/SUPPORTED | sed 's/#//g' | mawk '{print $1}' | grep 'UTF-8' > /tmp/available_locale
G_WHIP_MENU_ARRAY=()
local index=0
# convert for whiptail 0-1=1st option 2-3=2nd
while read line
do
- G_WHIP_MENU_ARRAY[$index]="$line"
+ G_WHIP_MENU_ARRAY[$index]=$line
((index++))
G_WHIP_MENU_ARRAY[$index]=''
((index++))
@@ -2353,7 +2153,7 @@
done < /tmp/available_locale
rm /tmp/available_locale
- G_WHIP_DEFAULT_ITEM="$locale_current"
+ G_WHIP_DEFAULT_ITEM=$locale_current
G_WHIP_MENU 'Please select a system locale. DietPi will automatically apply this as the default locale:'
if (( $? == 0 )); then
@@ -2507,34 +2307,25 @@
fi
- #Release all DHCP leases (too slow, quicker to allow router to decide leases)
- #dhclient -r
-
#Drop Connections
- G_DIETPI-NOTIFY 2 'Dropping connections, please wait...'
- ifdown eth$ETH_DEV_INDEX &> /dev/null
- ifdown wlan$WIFI_DEV_INDEX &> /dev/null
+ G_DIETPI-NOTIFY 0 'Dropping connections, please wait...'
+ ifdown eth$ETH_DEV_INDEX --force &> /dev/null
+ ifdown wlan$WIFI_DEV_INDEX --force &> /dev/null
#Kill dhclient
killall dhclient &> /dev/null
+ #Flush, not viable to handle this if change of IP, requires a detect of SSH loss/ip change, then exit script.
+ # ip addr flush dev eth$ETH_DEV_INDEX &> /dev/null
+ # ip addr flush dev wlan$WIFI_DEV_INDEX &> /dev/null
+
#Restart Networking
G_DIETPI-NOTIFY 2 'Restarting network, please wait...'
systemctl daemon-reload
- #systemctl restart networking #: Does exactly the same as ifdown/up that we already do.
#Manually bring up adapters
- if (( $ETH_DISABLED == 0 )); then
-
- ifup eth$ETH_DEV_INDEX
-
- fi
-
- if (( $WIFI_DISABLED == 0 )); then
-
- ifup wlan$WIFI_DEV_INDEX
-
- fi
+ (( $ETH_DISABLED == 0 )) && ifup eth$ETH_DEV_INDEX --force
+ (( $WIFI_DISABLED == 0 )) && ifup wlan$WIFI_DEV_INDEX --force
#Restart all services (required for hotspot)
/DietPi/dietpi/dietpi-services start
@@ -2546,17 +2337,23 @@
#Update network data
Network_GetData
+ G_DIETPI-NOTIFY 0 'Network restarted'
+
+ if ( (( $ETH_MODE_TARGET == 0 )) && [[ $ETH_IP != $ETH_IP_STATIC ]] ) ||
+ ( (( $WIFI_MODE_TARGET == 0 )) && [[ $WIFI_IP != $WIFI_IP_STATIC ]] ); then
+
+ G_WHIP_MSG "IP STATIC address change detected. A reboot is required to apply the new IP.\n\nPlease reboot the system."
+ REBOOT_REQUIRED=1
+
+ fi
+
}
Network_ApplyChanges(){
#Eth
local eth_enabled_text=''
- if (( $ETH_DISABLED )); then
-
- eth_enabled_text='#'
-
- fi
+ (( $ETH_DISABLED )) && eth_enabled_text='#'
local eth_dhcp_static_text='dhcp'
local eth_dns_text='#'
@@ -2564,20 +2361,16 @@
eth_dhcp_static_text='static'
eth_dns_text=''
- ETH_IP="$ETH_IP_STATIC"
- ETH_GATEWAY="$ETH_GATEWAY_STATIC"
- ETH_MASK="$ETH_MASK_STATIC"
- ETH_DNS="$ETH_DNS_STATIC"
+ ETH_IP=$ETH_IP_STATIC
+ ETH_GATEWAY=$ETH_GATEWAY_STATIC
+ ETH_MASK=$ETH_MASK_STATIC
+ ETH_DNS=$ETH_DNS_STATIC
fi
#Wlan
local wifi_enabled_text=''
- if (( $WIFI_DISABLED )); then
-
- wifi_enabled_text='#'
-
- fi
+ (( $WIFI_DISABLED )) && wifi_enabled_text='#'
local wifi_dhcp_static_text='dhcp'
local wifi_dns_text='#'
@@ -2585,10 +2378,10 @@
wifi_dhcp_static_text='static'
wifi_dns_text=''
- WIFI_IP="$WIFI_IP_STATIC"
- WIFI_GATEWAY="$WIFI_GATEWAY_STATIC"
- WIFI_MASK="$WIFI_MASK_STATIC"
- WIFI_DNS="$WIFI_DNS_STATIC"
+ WIFI_IP=$WIFI_IP_STATIC
+ WIFI_GATEWAY=$WIFI_GATEWAY_STATIC
+ WIFI_MASK=$WIFI_MASK_STATIC
+ WIFI_DNS=$WIFI_DNS_STATIC
fi
@@ -2639,6 +2432,9 @@ _EOF_
fi
+ # - Remove wireless-power setting, if not supported by adapter/firmware
+ iwconfig wlan$WIFI_DEV_INDEX power off &> /dev/null || sed -i '/^wireless-power/d' /etc/network/interfaces
+
# - Update WiFi db/wpa_supplicant
/DietPi/dietpi/func/dietpi-wifidb 1
@@ -2656,24 +2452,14 @@ _EOF_
#Ethernet
if (( $1 == 0 )); then
- G_WHIP_DEFAULT_ITEM="$ETH_IP_STATIC"
- G_WHIP_INPUTBOX 'Please enter a new static IP address'
- if (( $? == 0 )); then
-
- ETH_IP_STATIC=$G_WHIP_RETURNED_VALUE
-
- fi
+ G_WHIP_DEFAULT_ITEM=$ETH_IP_STATIC
+ G_WHIP_INPUTBOX 'Please enter a new static IP address' && ETH_IP_STATIC=$G_WHIP_RETURNED_VALUE
#wifi
elif (( $1 == 1 )); then
- G_WHIP_DEFAULT_ITEM="$WIFI_IP_STATIC"
- G_WHIP_INPUTBOX 'Please enter a new static IP address'
- if (( $? == 0 )); then
-
- WIFI_IP_STATIC=$G_WHIP_RETURNED_VALUE
-
- fi
+ G_WHIP_DEFAULT_ITEM=$WIFI_IP_STATIC
+ G_WHIP_INPUTBOX 'Please enter a new static IP address' && WIFI_IP_STATIC=$G_WHIP_RETURNED_VALUE
fi
@@ -2684,24 +2470,14 @@ _EOF_
#Ethernet
if (( $1 == 0 )); then
- G_WHIP_DEFAULT_ITEM="$ETH_GATEWAY_STATIC"
- G_WHIP_INPUTBOX 'Please enter a new static Gateway address'
- if (( $? == 0 )); then
-
- ETH_GATEWAY_STATIC=$G_WHIP_RETURNED_VALUE
-
- fi
+ G_WHIP_DEFAULT_ITEM=$ETH_GATEWAY_STATIC
+ G_WHIP_INPUTBOX 'Please enter a new static Gateway address' && ETH_GATEWAY_STATIC=$G_WHIP_RETURNED_VALUE
#wifi
elif (( $1 == 1 )); then
- G_WHIP_DEFAULT_ITEM="$WIFI_GATEWAY_STATIC"
- G_WHIP_INPUTBOX 'Please enter a new static Gateway address'
- if (( $? == 0 )); then
-
- WIFI_GATEWAY_STATIC=$G_WHIP_RETURNED_VALUE
-
- fi
+ G_WHIP_DEFAULT_ITEM=$WIFI_GATEWAY_STATIC
+ G_WHIP_INPUTBOX 'Please enter a new static Gateway address' && WIFI_GATEWAY_STATIC=$G_WHIP_RETURNED_VALUE
fi
@@ -2712,24 +2488,14 @@ _EOF_
#Ethernet
if (( $1 == 0 )); then
- G_WHIP_DEFAULT_ITEM="$ETH_MASK_STATIC"
- G_WHIP_INPUTBOX 'Please enter a new static Mask address'
- if (( $? == 0 )); then
-
- ETH_MASK_STATIC=$G_WHIP_RETURNED_VALUE
-
- fi
+ G_WHIP_DEFAULT_ITEM=$ETH_MASK_STATIC
+ G_WHIP_INPUTBOX 'Please enter a new static Mask address' && ETH_MASK_STATIC=$G_WHIP_RETURNED_VALUE
#wifi
elif (( $1 == 1 )); then
- G_WHIP_DEFAULT_ITEM="$WIFI_MASK_STATIC"
- G_WHIP_INPUTBOX 'Please enter a new static Mask address'
- if (( $? == 0 )); then
-
- WIFI_MASK_STATIC=$G_WHIP_RETURNED_VALUE
-
- fi
+ G_WHIP_DEFAULT_ITEM=$WIFI_MASK_STATIC
+ G_WHIP_INPUTBOX 'Please enter a new static Mask address' && WIFI_MASK_STATIC=$G_WHIP_RETURNED_VALUE
fi
@@ -2771,20 +2537,16 @@ _EOF_
)
- G_WHIP_DEFAULT_ITEM="$current_value"
+ G_WHIP_DEFAULT_ITEM=$current_value
if G_WHIP_MENU 'Please select a DNS server, or choose custom for manual entry.'; then
case $G_WHIP_RETURNED_VALUE in
'Custom')
- G_WHIP_DEFAULT_ITEM="$current_value"
+ G_WHIP_DEFAULT_ITEM=$current_value
G_WHIP_INPUTBOX 'Please enter a new DNS server address\n - 2 maximum, seperated by a space.\n - eg: 8.8.8.8 8.8.4.4'
- if (( $? == 0 )); then
-
- return_value=$G_WHIP_RETURNED_VALUE
-
- fi
+ (( $? )) || return_value=$G_WHIP_RETURNED_VALUE
;;
@@ -2827,7 +2589,7 @@ _EOF_
)
- G_WHIP_DEFAULT_ITEM="$WIFI_COUNTRYCODE"
+ G_WHIP_DEFAULT_ITEM=$WIFI_COUNTRYCODE
G_WHIP_MENU 'Please select a country, to enable WiFi channels and power ratings allowed in your country.'
if (( $? == 0 )); then
@@ -2835,7 +2597,7 @@ _EOF_
'Manual')
- G_WHIP_DEFAULT_ITEM="$WIFI_COUNTRYCODE"
+ G_WHIP_DEFAULT_ITEM=$WIFI_COUNTRYCODE
G_WHIP_INPUTBOX "Please enter a 2 character country code: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2"
if (( $? == 0 )); then
@@ -2864,7 +2626,7 @@ _EOF_
iw reg set $wifi_country_code_target
# - Check if country code was successfully applied
- WIFI_COUNTRYCODE=$(iw reg get | grep -m1 'country' | awk '{print $2}' | tr -d ':')
+ WIFI_COUNTRYCODE=$(iw reg get | mawk '/country/ {print $2;exit}' | tr -d ':')
if [[ $WIFI_COUNTRYCODE != $wifi_country_code_target ]]; then
G_WHIP_MSG "Country code ($wifi_country_code_target) could not been applied. Please check the country code and try again.\n\nIf problems persist, this may be a limitation with the driver/chipset."
@@ -2913,11 +2675,11 @@ _EOF_
cp /etc/network/interfaces /tmp/net_interfaces
#Reset
- ETH_IP_STATIC=$(cat /tmp/net_interfaces | grep -m1 'address ' | awk '{print $2}')
- ETH_GATEWAY_STATIC=$(cat /tmp/net_interfaces | grep -m1 'gateway ' | awk '{print $2}')
- ETH_MASK_STATIC=$(cat /tmp/net_interfaces | grep -m1 'netmask ' | awk '{print $2}')
- ETH_DNS_STATIC=$(cat /tmp/net_interfaces | grep -m1 'dns-nameservers ' | awk '{print $2,$3}')
- # Remove trailing space in case of single nameserver, due to awk '{print $2,$3}'
+ ETH_IP_STATIC=$(mawk '/address / {print $2;exit}' /tmp/net_interfaces)
+ ETH_GATEWAY_STATIC=$(mawk '/gateway / {print $2;exit}' /tmp/net_interfaces)
+ ETH_MASK_STATIC=$(mawk '/netmask / {print $2;exit}' /tmp/net_interfaces)
+ ETH_DNS_STATIC=$(mawk '/dns-nameservers / {print $2,$3;exit}' /tmp/net_interfaces)
+ # Remove trailing space in case of single nameserver, due to mawk '{print $2,$3}'
ETH_DNS_STATIC=${ETH_DNS_STATIC%[[:blank:]]}
ETH_DEV_INDEX=$(sed -n 1p /DietPi/dietpi/.network)
@@ -2931,11 +2693,11 @@ _EOF_
ETH_MODE=1
ETH_MODE_TARGET=$ETH_MODE
- WIFI_IP_STATIC=$(cat /tmp/net_interfaces | grep 'address ' | sed -n 2p | awk '{print $2}')
- WIFI_GATEWAY_STATIC=$(cat /tmp/net_interfaces | grep 'gateway ' | sed -n 2p | awk '{print $2}')
- WIFI_MASK_STATIC=$(cat /tmp/net_interfaces | grep 'netmask ' | sed -n 2p | awk '{print $2}')
- WIFI_DNS_STATIC=$(cat /tmp/net_interfaces | grep 'dns-nameservers ' | sed -n 2p | awk '{print $2,$3}')
- # Remove trailing space in case of single nameserver, due to awk '{print $2,$3}'
+ WIFI_IP_STATIC=$(mawk '/address / {print $2}' /tmp/net_interfaces | sed -n 2p)
+ WIFI_GATEWAY_STATIC=$(mawk '/gateway / {print $2}' /tmp/net_interfaces | sed -n 2p)
+ WIFI_MASK_STATIC=$(mawk '/netmask / {print $2}' /tmp/net_interfaces | sed -n 2p)
+ WIFI_DNS_STATIC=$(mawk '/dns-nameservers / {print $2,$3}' /tmp/net_interfaces | sed -n 2p)
+ # Remove trailing space in case of single nameserver, due to mawk '{print $2,$3}'
WIFI_DNS_STATIC=${WIFI_DNS_STATIC%[[:blank:]]}
WIFI_DEV_INDEX=$(sed -n 2p /DietPi/dietpi/.network)
@@ -2948,7 +2710,7 @@ _EOF_
WIFI_DNS='0.0.0.0'
WIFI_MODE=1
WIFI_MODE_TARGET=$WIFI_MODE
- which iwgetid &> /dev/null && WIFI_SSID_CURRENT="$(iwgetid -r)"
+ command -v iwgetid &> /dev/null && WIFI_SSID_CURRENT=$(iwgetid -r)
[[ ! $WIFI_SSID_CURRENT ]] && WIFI_SSID_CURRENT='Disconnected / No SSID'
WIFI_CRED_INDEX=0 # Which index of SSID/KEY etc we are editing
@@ -2961,7 +2723,7 @@ _EOF_
WIFI_COUNTRYCODE='GB'
# - Prevent "nl80211 not found" message, when running this command with cfg80211 module disabled.
- which iw &> /dev/null && WIFI_COUNTRYCODE=$(iw reg get | grep -m1 'country' | awk '{print $2}' | tr -d ':')
+ command -v iw &> /dev/null && WIFI_COUNTRYCODE=$(iw reg get | mawk '/country/ {print $2;exit}' | tr -d ':')
# Convert CIDR integer to net mask, e.g. "192.168.0.100/24" (take "24") to "255.255.255.0"
cidr2mask() {
@@ -2970,7 +2732,7 @@ _EOF_
local full_octets=$(( $1 / 8 ))
local partial_octet=$(( $1%8 ))
- for ((i=0; i<4; i++)); do
+ for i in {0..3}; do
if (( $i < $full_octets )); then
@@ -2985,10 +2747,10 @@ _EOF_
mask+=0
fi
- [[ $i < 3 ]] && mask+=.
+ (( $i < 3 )) && mask+=.
done
- echo "$mask"
+ echo $mask
}
@@ -3008,10 +2770,10 @@ _EOF_
#Enabled and Connected
if (( $ETH_DISABLED == 0 && $ETH_CONNECTED == 1 )); then
- ETH_IP=$(ip a s eth$ETH_DEV_INDEX | grep -m1 '^[[:blank:]]*inet ' | awk '{print $2}' | sed 's|/.*$||')
- ETH_GATEWAY=$(ip r | grep -m1 'default' | awk '{print $3}')
- ETH_MASK=$(cidr2mask $(ip a s eth$ETH_DEV_INDEX | grep -m1 '^[[:blank:]]*inet ' | awk '{print $2}' | sed 's|^.*/||'))
- ETH_DNS=$(grep -m1 'nameserver' /etc/resolv.conf | awk '{print $2}')
+ ETH_IP=$(ip a s eth$ETH_DEV_INDEX | grep -m1 '^[[:blank:]]*inet ' | mawk '{print $2}' | sed 's|/.*$||')
+ ETH_GATEWAY=$(ip r | mawk '/default/ {print $3;exit}')
+ ETH_MASK=$(cidr2mask $(ip a s eth$ETH_DEV_INDEX | grep -m1 '^[[:blank:]]*inet ' | mawk '{print $2}' | sed 's|^.*/||'))
+ ETH_DNS=$(mawk '/nameserver/ {print $2;exit}' /etc/resolv.conf)
fi
@@ -3032,17 +2794,17 @@ _EOF_
#Enabled and Connected
if (( $WIFI_DISABLED == 0 && $WIFI_CONNECTED == 1 )); then
- WIFI_IP=$(ip a s wlan$WIFI_DEV_INDEX | grep -m1 '^[[:blank:]]*inet ' | awk '{print $2}' | sed 's|/.*$||')
- WIFI_GATEWAY=$(ip r | grep -m1 'default' | awk '{print $3}')
- WIFI_MASK=$(cidr2mask $(ip a s wlan$WIFI_DEV_INDEX | grep -m1 '^[[:blank:]]*inet ' | awk '{print $2}' | sed 's|^.*/||'))
- WIFI_DNS=$(grep -m1 'nameserver' /etc/resolv.conf | awk '{print $2}')
+ WIFI_IP=$(ip a s wlan$WIFI_DEV_INDEX | grep -m1 '^[[:blank:]]*inet ' | mawk '{print $2}' | sed 's|/.*$||')
+ WIFI_GATEWAY=$(ip r | mawk '/default/ {print $3;exit}')
+ WIFI_MASK=$(cidr2mask $(ip a s wlan$WIFI_DEV_INDEX | grep -m1 '^[[:blank:]]*inet ' | mawk '{print $2}' | sed 's|^.*/||'))
+ WIFI_DNS=$(mawk '/nameserver/ {print $2;exit}' /etc/resolv.conf)
#Get extra wifi stats
- WIFI_BITRATE=$(iwconfig wlan$WIFI_DEV_INDEX | grep -m1 'Bit Rate' | awk '{print $2}' | sed 's/Rate[:=]//g')
- WIFI_SIGNALSTRENGTH=$(iwconfig wlan$WIFI_DEV_INDEX | grep -m1 'Signal level=' | awk '{print $4}' | sed 's/level=//g' | cut -f1 -d "/")
+ WIFI_BITRATE=$(iwconfig wlan$WIFI_DEV_INDEX | mawk '/Bit Rate/ {print $2;exit}' | sed 's/Rate[:=]//g')
+ WIFI_SIGNALSTRENGTH=$(iwconfig wlan$WIFI_DEV_INDEX | mawk '/Signal level=/ {print $4;exit}' | sed 's/level=//g' | cut -f1 -d "/")
# - try and detect if this is dBm (contains -) or %
- if disable_error=1 G_CHECK_VALIDINT $WIFI_SIGNALSTRENGTH -500 -1; then
+ if disable_error=1 G_CHECK_VALIDINT "$WIFI_SIGNALSTRENGTH" -500 -1; then
WIFI_SIGNALSTRENGTH="$WIFI_SIGNALSTRENGTH dBm"
@@ -3057,7 +2819,7 @@ _EOF_
fi
#cleanup tmp
- rm /tmp/net_interfaces &> /dev/null
+ [[ -f /tmp/net_interfaces ]] && rm /tmp/net_interfaces
}
@@ -3093,7 +2855,7 @@ _EOF_
if (( $WIFI_CONNECTED )); then
wlan_connected_text='Connected'
- (( $WIFI_HOTSPOT )) && wlan_connected_text="WiFi Hotspot Mode"
+ (( $WIFI_HOTSPOT )) && wlan_connected_text='WiFi Hotspot Mode'
fi
@@ -3118,6 +2880,7 @@ _EOF_
# - Reset init flag. Ensures Menu_Proxy() reloads current settings.
PROXY_ENABLED=-1
+ G_WHIP_MENU_ARRAY+=('' '●─ Adapter Options ')
G_WHIP_MENU_ARRAY+=('Ethernet' ': Change Wired Network Settings')
G_WHIP_MENU_ARRAY+=('WiFi' ': Change Wireless Network Settings')
@@ -3139,6 +2902,8 @@ _EOF_
fi
+ G_WHIP_MENU_ARRAY+=('' '●─ Additional Options ')
+
#IPv6
local ipv6_status_text='[WARNING] Not supported or disabled on kernel level!'
if [[ -d /proc/sys/net/ipv6 ]]; then
@@ -3293,7 +3058,7 @@ _EOF_
'Test')
- G_WHIP_DEFAULT_ITEM="$INTERNET_TEST_URL"
+ G_WHIP_DEFAULT_ITEM=$INTERNET_TEST_URL
G_WHIP_INPUTBOX 'Press enter a URL address to test (eg: http://google.com)'
if (( $? == 0 )); then
@@ -3346,19 +3111,11 @@ _EOF_
# - Get current Mode details
local mode_current='DHCP'
- if (( $ETH_MODE == 0 )); then
-
- mode_current='STATIC'
-
- fi
+ (( $ETH_MODE == 0 )) && mode_current='STATIC'
# - Target Details
local mode_target='DHCP'
- if (( $ETH_MODE_TARGET == 0 )); then
-
- mode_target='STATIC'
-
- fi
+ (( $ETH_MODE_TARGET == 0 )) && mode_target='STATIC'
G_WHIP_MENU_ARRAY=('' '●─ DHCP/STATIC IP ')
@@ -3366,7 +3123,7 @@ _EOF_
# - show static options
if (( $ETH_MODE_TARGET == 0 )); then
- G_WHIP_MENU_ARRAY+=('Copy' ': Copy Current address to Static')
+ G_WHIP_MENU_ARRAY+=('Copy' ': Copy current address to "Static"')
G_WHIP_MENU_ARRAY+=('Static Ip' ": [$ETH_IP_STATIC]")
G_WHIP_MENU_ARRAY+=('Static Mask' ": [$ETH_MASK_STATIC]")
G_WHIP_MENU_ARRAY+=('Static Gateway' ": [$ETH_GATEWAY_STATIC]")
@@ -3382,8 +3139,8 @@ _EOF_
Net_Update_UsageStats eth$ETH_DEV_INDEX
- G_WHIP_DEFAULT_ITEM="$WHIP_SELECTION_PREVIOUS"
- G_WHIP_MENU "Current Details:\nUsage : Sent = $NET_TX_MB | Recieved = $NET_RX_MB\nMode : $mode_current\nIp : $ETH_IP\nMask : $ETH_MASK\nGateway : $ETH_GATEWAY\nDNS : $ETH_DNS"
+ G_WHIP_DEFAULT_ITEM=$WHIP_SELECTION_PREVIOUS
+ G_WHIP_MENU "Ethernet Details:\nUsage : Sent = $NET_TX_MB | Recieved = $NET_RX_MB\nAddress : IP = $ETH_IP | Mask = $ETH_MASK | Gateway = $ETH_GATEWAY | DNS = $ETH_DNS"
if (( $? == 0 )); then
#Return to this menu
@@ -3396,11 +3153,7 @@ _EOF_
'Change Mode')
((ETH_MODE_TARGET++))
- if (( $ETH_MODE_TARGET >= 2 )); then
-
- ETH_MODE_TARGET=0
-
- fi
+ (( $ETH_MODE_TARGET >= 2 )) && ETH_MODE_TARGET=0
;;
@@ -3465,15 +3218,15 @@ _EOF_
WiFi_Monitor_Disable(){
- systemctl stop dietpi-wifi-monitor.service
- systemctl disable dietpi-wifi-monitor.service
+ systemctl stop dietpi-wifi-monitor
+ systemctl disable dietpi-wifi-monitor
}
WiFi_Monitor_Enable(){
- systemctl enable dietpi-wifi-monitor.service
- G_RUN_CMD systemctl start dietpi-wifi-monitor.service
+ systemctl enable dietpi-wifi-monitor
+ G_RUN_CMD systemctl start dietpi-wifi-monitor
}
@@ -3485,7 +3238,7 @@ _EOF_
Net_Update_UsageStats wlan$ETH_DEV_INDEX
local whip_options_total=0
- local description_text="Current Details:\nUsage : Sent = $NET_TX_MB | Recieved = $NET_RX_MB\n"
+ local description_text="WiFi Details:\nUsage : Sent = $NET_TX_MB | Recieved = $NET_RX_MB\n"
G_WHIP_MENU_ARRAY=('' '●─ Basic Options ')
@@ -3501,49 +3254,56 @@ _EOF_
fi
+ # N enabled?
+ local hotspot_n_enabled=0
+ local hotspot_n_text='Disabled'
+ if grep -q '^ieee80211n=1' /etc/hostapd/hostapd.conf; then
+
+ hotspot_n_enabled=1
+ hotspot_n_text='Enabled'
+
+ fi
+
# toggle
local hotspot_active_state=$(systemctl is-active hostapd | grep -ci -m1 '^active' )
- local hotspot_status_text='Online'
- local hotspot_active_state_text='Enabled, select to turn off hotspot'
+ local hotspot_status_text='Status : '
+ local hotspot_active_state_text='[Enabled] | Select to turn off hotspot'
if (( ! $hotspot_active_state )); then
- hotspot_active_state_text='Disabled, select to turn on hotspot'
- hotspot_status_text='Offline'
+ hotspot_active_state_text='[Disabled] | Select to turn on hotspot'
+ hotspot_status_text+='Offline'
+
+ else
+
+ hotspot_status_text+='Online'
fi
- G_WHIP_MENU_ARRAY+=('SSID' ': Change the wireless hotspot name')
- G_WHIP_MENU_ARRAY+=('Channel' ': Change the wireless channel')
- G_WHIP_MENU_ARRAY+=('Key' ': Change the access key required to connect')
+ G_WHIP_MENU_ARRAY+=('SSID' ": [$HOTSPOT_SSID]")
+ G_WHIP_MENU_ARRAY+=('Channel' ": [$HOTSPOT_CHANNEL]")
+ G_WHIP_MENU_ARRAY+=('Key' ": [$HOTSPOT_KEY]")
+ G_WHIP_MENU_ARRAY+=('802.11 N' ": [$hotspot_n_text]")
- description_text+="SSID : $HOTSPOT_SSID\nChannel : $HOTSPOT_CHANNEL\nKey : $HOTSPOT_KEY\nStatus : $hotspot_status_text"
+ description_text+=$hotspot_status_text
#WiFi Menu
else
# - Get current Mode details
local mode_current='DHCP'
- if (( $WIFI_MODE == 0 )); then
-
- mode_current='STATIC'
-
- fi
+ (( $WIFI_MODE == 0 )) && mode_current='STATIC'
# - Target Details
local mode_target='DHCP'
- if (( $WIFI_MODE_TARGET == 0 )); then
-
- mode_target='STATIC'
-
- fi
+ (( $WIFI_MODE_TARGET == 0 )) && mode_target='STATIC'
G_WHIP_MENU_ARRAY+=('Scan' ': Scan and configure SSID')
- if (( $WIFI_CONNECTED || $(systemctl is-active dietpi-wifi-monitor.service | grep -ci -m1 '^active') )); then
+ if (( $WIFI_CONNECTED )) || systemctl is-active dietpi-wifi-monitor | grep -qi '^active'; then
local wifi_auto_reconnect_text='[Off]'
WIFI_AUTO_RECONNECT_ACTIVE=0
- if systemctl is-active dietpi-wifi-monitor.service | grep -qi '^active'; then
+ if systemctl is-active dietpi-wifi-monitor | grep -qi '^active'; then
WIFI_AUTO_RECONNECT_ACTIVE=1
wifi_auto_reconnect_text='[On]'
@@ -3560,7 +3320,7 @@ _EOF_
# - show static options
if (( $WIFI_MODE_TARGET == 0 )); then
- G_WHIP_MENU_ARRAY+=('Copy' ': Copy Current address to Static')
+ G_WHIP_MENU_ARRAY+=('Copy' ': Copy current address to "Static"')
G_WHIP_MENU_ARRAY+=('Static Ip' ": [$WIFI_IP_STATIC]")
G_WHIP_MENU_ARRAY+=('Static Mask' ": [$WIFI_MASK_STATIC]")
G_WHIP_MENU_ARRAY+=('Static Gateway' ": [$WIFI_GATEWAY_STATIC]")
@@ -3568,7 +3328,7 @@ _EOF_
fi
- description_text+="SSID : $WIFI_SSID_CURRENT | $WIFI_BITRATE Mbit | Strength: $WIFI_SIGNALSTRENGTH\nMode : $mode_current \nIp : $WIFI_IP\nMask : $WIFI_MASK\nDNS : $WIFI_DNS"
+ description_text+="SSID : $WIFI_SSID_CURRENT | $WIFI_BITRATE Mbit | Strength: $WIFI_SIGNALSTRENGTH\nAddress : IP = $WIFI_IP | Mask = $WIFI_MASK | Gateway = $WIFI_GATEWAY | DNS = $WIFI_DNS"
fi
@@ -3598,9 +3358,8 @@ _EOF_
G_WHIP_MENU_ARRAY+=('' '●─ Apply ')
G_WHIP_MENU_ARRAY+=('Apply' ': Save all changes and restart networking')
- G_WHIP_DEFAULT_ITEM="$WHIP_SELECTION_PREVIOUS"
- G_WHIP_MENU "$description_text"
- if (( $? == 0 )); then
+ G_WHIP_DEFAULT_ITEM=$WHIP_SELECTION_PREVIOUS
+ if G_WHIP_MENU "$description_text"; then
#Return to this menu
TARGETMENUID=10
@@ -3611,13 +3370,13 @@ _EOF_
'Auto Reconnect')
- if (( ! $WIFI_AUTO_RECONNECT_ACTIVE )); then
+ if (( $WIFI_AUTO_RECONNECT_ACTIVE )); then
- WiFi_Monitor_Enable
+ WiFi_Monitor_Disable
else
- WiFi_Monitor_Disable
+ WiFi_Monitor_Enable
fi
@@ -3625,25 +3384,16 @@ _EOF_
'Key')
- G_WHIP_DEFAULT_ITEM="$HOTSPOT_KEY"
+ G_WHIP_DEFAULT_ITEM=$HOTSPOT_KEY
G_WHIP_INPUTBOX 'Please enter a key/password for the WiFi hotspot\n - NB: Minimum of 8 characters'
- if (( $? == 0 )); then
-
- HOTSPOT_KEY=$G_WHIP_RETURNED_VALUE
-
- fi
+ (( $? == 0 )) && HOTSPOT_KEY=$G_WHIP_RETURNED_VALUE
;;
'SSID')
- G_WHIP_DEFAULT_ITEM="$HOTSPOT_SSID"
- G_WHIP_INPUTBOX 'Please enter a SSID for the WiFi hotspot'
- if (( $? == 0 )); then
-
- HOTSPOT_SSID=$G_WHIP_RETURNED_VALUE
-
- fi
+ G_WHIP_DEFAULT_ITEM=$HOTSPOT_SSID
+ G_WHIP_INPUTBOX 'Please enter a SSID for the WiFi hotspot' && HOTSPOT_SSID=$G_WHIP_RETURNED_VALUE
;;
@@ -3658,18 +3408,27 @@ _EOF_
do
G_WHIP_MENU_ARRAY+=($i ": $channel_mhz MHz")
- ((channel_mhz += 5 ))
+ ((channel_mhz+=5))
done
G_WHIP_DEFAULT_ITEM=$HOTSPOT_CHANNEL
- G_WHIP_MENU 'Please select a WiFi channel for the hotspot.'
- if (( $? == 0 )); then
+ G_WHIP_MENU 'Please select a WiFi channel for the hotspot.' && HOTSPOT_CHANNEL=$G_WHIP_RETURNED_VALUE
+
+ ;;
+
+ '802.11 N')
+
+ ((hotspot_n_enabled++))
- HOTSPOT_CHANNEL=$G_WHIP_RETURNED_VALUE
+ if (( $hotspot_n_enabled >= 2 )); then
+
+ hotspot_n_enabled=0
fi
+ G_CONFIG_INJECT 'ieee80211n=' "ieee80211n=$hotspot_n_enabled" /etc/hostapd/hostapd.conf
+
;;
'Country')
@@ -3770,11 +3529,11 @@ _EOF_
if (( $hotspot_active_state )); then
- systemctl stop hostapd
+ G_RUN_CMD systemctl stop hostapd
else
- systemctl start hostapd
+ G_RUN_CMD systemctl start hostapd
fi
@@ -3798,8 +3557,7 @@ _EOF_
)
- G_WHIP_MENU 'Please select an option:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select an option:'; then
case "$G_WHIP_RETURNED_VALUE" in
@@ -3827,19 +3585,11 @@ _EOF_
TARGETMENUID=11
# - Init/load previous bench results
- if [[ ! -f /var/lib/dietpi/dietpi-benchmark/results ]]; then
-
- /DietPi/dietpi/func/dietpi-benchmark 0
-
- fi
+ [[ -f /var/lib/dietpi/dietpi-benchmark/results ]] || /DietPi/dietpi/func/dietpi-benchmark 0
. /var/lib/dietpi/dietpi-benchmark/results
# - Sanity for beta testing. As this value won't exist until re-save of /var/lib/dietpi/dietpi-benchmark/results
- if [[ ! $BENCH_NET_LAN_SPEED ]]; then
-
- BENCH_NET_LAN_SPEED='Not Tested'
-
- fi
+ [[ $BENCH_NET_LAN_SPEED ]] || BENCH_NET_LAN_SPEED='Not Tested'
G_WHIP_MENU_ARRAY=(
@@ -3904,11 +3654,11 @@ Additional benchmarks:
'Custom Filesystem')
/DietPi/dietpi/dietpi-drive_manager 1
- local fp_fsbench_custom_mount="$( /dev/null
@@ -4567,15 +4303,11 @@ Additional benchmarks:
# - Check if system supports temp readouts
local cpu_supports_temp=0
local cpu_temp=$(G_OBTAIN_CPU_TEMP)
- if disable_error=1 G_CHECK_VALIDINT $cpu_temp; then
-
- cpu_supports_temp=1
-
- fi
+ disable_error=1 G_CHECK_VALIDINT "$cpu_temp" && cpu_supports_temp=1
# - Loop until stress completed
local remaning_time=0
- while ps aux | grep -qi '[s]tress'
+ while pgrep 'stress' &> /dev/null
do
cpu_temp=$(G_OBTAIN_CPU_TEMP)
@@ -4635,41 +4367,33 @@ Additional benchmarks:
#Update installed software
Load_Installed_Software
- #NoIp Client
+ #No-IP Client
local noip_installed=0
local noip_status='Not Installed'
- local noip_menutext='Install No-Ip now'
+ local noip_menutext='Install No-IP now'
if (( ${aSOFTWARE_INSTALL_STATE[67]:=0} == 2 )); then
noip_installed=1
- noip_status='Offline - Please Enter No-Ip Details'
- noip_menutext='Enter/Setup NoIp Details'
+ noip_status='Offline - Please enter No-IP details'
+ noip_menutext='Enter/Setup No-IP details'
- #Check if noip is running (indicates login details are valid)
- if ps aux | grep -qi '/usr/local/bin/[n]oip2'; then
+ #Check if No-IP is running (indicates login details are valid)
+ if pgrep '/usr/local/bin/noip2' &> /dev/null; then
noip_status='Online / Active'
- noip_menutext='Change NoIp Details'
+ noip_menutext='Change No-IP details'
fi
fi
#APT mirror
- local apt_mirror_current=$(grep -m1 '^[[:blank:]]*deb[[:blank:]]' /etc/apt/sources.list | awk '{print $2}')
- if [[ -z $apt_mirror_current ]]; then
-
- apt_mirror_current='Unknown, no string from scrape'
-
- fi
+ local apt_mirror_current=$(grep -m1 '^[[:blank:]]*deb[[:blank:]]' /etc/apt/sources.list | mawk '{print $2}')
+ [[ $apt_mirror_current ]] || apt_mirror_current='Unknown, no string from scrape'
#NTP mirror
local ntp_mirror_current=$(grep -m1 '^[[:blank:]]*CONFIG_NTP_MIRROR=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
- if [[ -z $ntp_mirror_current ]]; then
-
- ntp_mirror_current='Unknown, no string from scrape'
-
- fi
+ [[ $ntp_mirror_current ]] || ntp_mirror_current='Unknown, no string from scrape'
#Network boot wait
local boot_wait_for_network=$(grep -m1 '^[[:blank:]]*CONFIG_BOOT_WAIT_FOR_NETWORK=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
@@ -4690,16 +4414,17 @@ Additional benchmarks:
G_WHIP_MENU_ARRAY=(
- 'Network Drives' ': Mount/control networked storage'
- 'NoIp' ": [$noip_menutext]"
- 'APT Mirror' ': Select a different APT mirror for sources.list'
- 'NTP Mirror' ': Select a different NTP mirror'
+ '' '●─ Mirror Options '
+ 'APT Mirror' ": [$apt_mirror_current]"
+ 'NTP Mirror' ": [$ntp_mirror_current]"
+ '' '●─ Additional Options '
'Boot Net Wait' ": [$boot_wait_for_network_text]"
+ 'Network Drives' ': Mount/control networked storage'
+ 'No-IP' ": [$noip_menutext]"
)
- G_WHIP_MENU "NoIp status : $noip_status\nAPT mirror : $apt_mirror_current\nNTP mirror : $ntp_mirror_current"
- if (( $? == 0 )); then
+ if G_WHIP_MENU ''; then
#Return to this Menu
TARGETMENUID=16
@@ -4760,17 +4485,15 @@ Additional benchmarks:
fi
- G_WHIP_DEFAULT_ITEM="$apt_mirror_current"
- G_WHIP_MENU 'Please select an APT mirror, or choose custom for manual entry.'
- if (( $? == 0 )); then
+ G_WHIP_DEFAULT_ITEM=$apt_mirror_current
+ if G_WHIP_MENU 'Please select an APT mirror, or choose custom for manual entry.'; then
case $G_WHIP_RETURNED_VALUE in
'Custom')
- G_WHIP_DEFAULT_ITEM="$apt_mirror_current"
- G_WHIP_INPUTBOX 'Please enter a new APT Mirror\n - eg: http://ftp.debian.org/debian'
- if (( $? == 0 )); then
+ G_WHIP_DEFAULT_ITEM=$apt_mirror_current
+ if G_WHIP_INPUTBOX 'Please enter a new APT Mirror\n - eg: http://ftp.debian.org/debian'; then
return_value=$G_WHIP_RETURNED_VALUE
@@ -4809,7 +4532,7 @@ Additional benchmarks:
)
- G_WHIP_DEFAULT_ITEM="$ntp_mirror_current"
+ G_WHIP_DEFAULT_ITEM=$ntp_mirror_current
G_WHIP_MENU 'Please select an NTP mirror:\n
"Gateway": Try to detect and use local router for time sync. Recommended, allows fastest sync and reduces load to the *.pool.ntp.org servers.\n
"Custom": Manually enter local or external NTP server address(es).\n
@@ -4817,7 +4540,7 @@ Additional benchmarks:
Use "*.pool.ntp.org" mirrors, if your device is mobile or should act as local NTP server. Further information: "http://www.pool.ntp.org/zone/@"'
if (( $? == 0 )) && [[ $G_WHIP_RETURNED_VALUE ]]; then
- local new_setting_ntp_mirror="$G_WHIP_RETURNED_VALUE"
+ local new_setting_ntp_mirror=$G_WHIP_RETURNED_VALUE
local previous_setting_ntp_mirror=$(grep -m1 '^[[:blank:]]*CONFIG_NTP_MIRROR=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
local apply=1
@@ -4826,13 +4549,12 @@ Use "*.pool.ntp.org" mirrors, if your device is mobile or should act as local NT
'Custom')
- G_WHIP_DEFAULT_ITEM="$ntp_mirror_current"
- G_WHIP_INPUTBOX 'Please enter one or more (space-separated) NTP mirrors.\n
+ G_WHIP_DEFAULT_ITEM=$ntp_mirror_current
+ if G_WHIP_INPUTBOX 'Please enter one or more (space-separated) NTP mirrors.\n
NB: If you need to use *.pool.ntp.org servers, enter the base domain only. The subdomains 0-3 will be added automatically.
-- Enter "uk.pool.ntp.org" to use [0-3].uk.pool.ntp.org'
- if (( $? == 0 )); then
+- Enter "uk.pool.ntp.org" to use [0-3].uk.pool.ntp.org'; then
- new_setting_ntp_mirror="$G_WHIP_RETURNED_VALUE"
+ new_setting_ntp_mirror=$G_WHIP_RETURNED_VALUE
else
@@ -4848,8 +4570,7 @@ NB: If you need to use *.pool.ntp.org servers, enter the base domain only. The s
G_CONFIG_INJECT 'CONFIG_NTP_MIRROR=' "CONFIG_NTP_MIRROR=$new_setting_ntp_mirror" /DietPi/dietpi.txt
/DietPi/dietpi/func/dietpi-set_software ntpd-mode $(grep -m1 '^[[:blank:]]*CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
- MAX_LOOPS_CHECK=10 /DietPi/dietpi/func/run_ntpd 1
- if (( $? )); then
+ if ! MAX_LOOPS_CHECK=10 /DietPi/dietpi/func/run_ntpd 1; then
G_WHIP_MSG "Time sync failed:\n - $G_WHIP_RETURNED_VALUE\n\nSetting reverted to previous."
@@ -4864,27 +4585,24 @@ NB: If you need to use *.pool.ntp.org servers, enter the base domain only. The s
;;
- 'NoIp')
+ 'No-IP')
#Installed?
if (( ! $noip_installed )); then
- local noip_url_address=''
- G_WHIP_YESNO 'NoIp Client is not installed, would you like to install it now?\n\n- NoIp will allow you to use a fixed web address, regardless of your internet IP\neg: MySuperDooperWebsite.noip2.biz would point to this device!'
- if (( $? == 0 )); then
-
- #Install
- /DietPi/dietpi/dietpi-software install 67
-
- fi
+ G_WHIP_YESNO 'No-IP Client is not installed, would you like to install it now?\n
+- No-IP will allow you to use a fixed web address, regardless of your internet IP.
+ Eg: MySuperDooperWebsite.noip2.biz would always point to this device!' && /DietPi/dietpi/dietpi-software install 67
else
printf '\ec' # clear current terminal screen
- service noip2 stop
+ G_RUN_CMD systemctl stop noip2
+ #Failsafe: Directory required for "noip2 -C" to create the config file there
+ mkdir -p /usr/local/etc
noip2 -C
- read -p 'Press any key to continue.....'
- service noip2 start
+ read -p 'Press any key to continue...'
+ G_RUN_CMD systemctl restart noip2
fi
@@ -4971,15 +4689,15 @@ NB: If you need to use *.pool.ntp.org servers, enter the base domain only. The s
'Address')
- G_WHIP_DEFAULT_ITEM="$PROXY_ADDRESS"
+ G_WHIP_DEFAULT_ITEM=$PROXY_ADDRESS
G_WHIP_INPUTBOX 'Please enter the proxy URL or IP address\n - eg: MyProxy.com'
- (( $? == 0 )) && PROXY_ADDRESS="$G_WHIP_RETURNED_VALUE"
+ (( $? == 0 )) && PROXY_ADDRESS=$G_WHIP_RETURNED_VALUE
;;
'Port')
- G_WHIP_DEFAULT_ITEM="$PROXY_PORT"
+ G_WHIP_DEFAULT_ITEM=$PROXY_PORT
G_WHIP_INPUTBOX 'Please enter the proxy port number\n - eg: 1234'
(( $? == 0 )) && PROXY_PORT=$G_WHIP_RETURNED_VALUE
@@ -4987,17 +4705,17 @@ NB: If you need to use *.pool.ntp.org servers, enter the base domain only. The s
'Username')
- G_WHIP_DEFAULT_ITEM="$PROXY_USERNAME"
+ G_WHIP_DEFAULT_ITEM=$PROXY_USERNAME
G_WHIP_INPUTBOX 'Please enter the proxy username\n - eg: JoeBloggs\n - Leave blank if not required'
- (( $? == 0 )) && PROXY_USERNAME="$G_WHIP_RETURNED_VALUE"
+ (( $? == 0 )) && PROXY_USERNAME=$G_WHIP_RETURNED_VALUE
;;
'Password')
- G_WHIP_DEFAULT_ITEM="$PROXY_PASSWORD"
+ G_WHIP_DEFAULT_ITEM=$PROXY_PASSWORD
G_WHIP_INPUTBOX 'Please enter the proxy password\n - eg: LetMeIn\n - Leave blank if not required'
- (( $? == 0 )) && PROXY_PASSWORD="$G_WHIP_RETURNED_VALUE"
+ (( $? == 0 )) && PROXY_PASSWORD=$G_WHIP_RETURNED_VALUE
;;
@@ -5063,7 +4781,7 @@ _EOF_
while (( $TARGETMENUID >= 0 )); do
printf '\ec' # clear current terminal screen
- G_WHIP_BUTTON_CANCEL_TEXT="$TEXT_MENU_BACK"
+ G_WHIP_BUTTON_CANCEL_TEXT=$TEXT_MENU_BACK
if (( $TARGETMENUID == 0 )); then
diff --git a/dietpi/dietpi-cpuinfo b/dietpi/dietpi-cpuinfo
index 1437d96816..320f1c1200 100644
--- a/dietpi/dietpi-cpuinfo
+++ b/dietpi/dietpi-cpuinfo
@@ -18,36 +18,21 @@
#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
- G_CHECK_ROOT_USER
G_PROGRAM_NAME='DietPi-CPU_info'
+ G_CHECK_ROOT_USER
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
+ #DietPi-Globals exit trap addition
+ G_EXIT_CUSTOM(){ unset aCPU_CURRENT_FREQ aCPU_MIN_FREQ aCPU_MAX_FREQ aCPU_SCALINGAVAILABLE_FREQ; }
+
#Grab Input
INPUT=0
- if disable_error=1 G_CHECK_VALIDINT $1; then
-
- INPUT=$1
-
- fi
+ disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1
- #Exit path for VM
- if (( $G_HW_MODEL == 20 )); then
-
- echo -e '\nNotice: CPU information is not available for VM.\n'
- exit
-
- fi
-
- #Funcs
- CPU_GOV_CURRENT='Unknown'
-
- aCPU_CURRENT_FREQ=0
- aCPU_MIN_FREQ=0
- aCPU_MAX_FREQ=0
- aCPU_SCALINGAVAILABLE_FREQ=0
- CPU_SCALINGSUPPORTED=1
- FP_CPU_SCALINGAVAILABLE_FREQ='/tmp/dietpi-available_cpu_freqs'
+ aCPU_CURRENT_FREQ=()
+ aCPU_MIN_FREQ=()
+ aCPU_MAX_FREQ=()
Obtain_Cpu_Freq(){
for ((i=0; i<$(nproc --all); i++))
@@ -73,7 +58,13 @@
done
- #Obtain available scaling freqs:
+ }
+
+ aCPU_SCALINGAVAILABLE_FREQ=()
+ CPU_SCALINGSUPPORTED=1
+ FP_CPU_SCALINGAVAILABLE_FREQ='/tmp/dietpi-available_cpu_freqs'
+ Obtain_Cpu_Scaling_Freq(){
+
# - Intel
if [[ -f /sys/devices/system/cpu/intel_pstate/max_perf_pct ]]; then
@@ -94,14 +85,14 @@
for ((i=0; i<$(nproc --all); i++))
do
- aCPU_SCALINGAVAILABLE_FREQ[$i]=$(cat /sys/devices/system/cpu/cpu$i/cpufreq/scaling_available_frequencies | tr ' ' '\n' | sed -e 's/[^0-9]//g' | sed '/^$/d')
+ aCPU_SCALINGAVAILABLE_FREQ[$i]=$(tr ' ' '\n' < /sys/devices/system/cpu/cpu$i/cpufreq/scaling_available_frequencies | sed 's/[^0-9]//g' | sed '/^$/d')
done
# - XU4 3.x
elif [[ -f /sys/devices/system/cpu/cpufreq/mp-cpufreq/cpu_freq_table ]]; then
- aCPU_SCALINGAVAILABLE_FREQ[0]=$(cat /sys/devices/system/cpu/cpufreq/mp-cpufreq/cpu_freq_table | tr ' ' '\n' | sed -e 's/[^0-9]//g' | sed '/^$/d')
+ aCPU_SCALINGAVAILABLE_FREQ[0]=$(tr ' ' '\n' < /sys/devices/system/cpu/cpufreq/mp-cpufreq/cpu_freq_table | sed 's/[^0-9]//g' | sed '/^$/d')
else
@@ -111,18 +102,15 @@
}
- CPU_TEMP_CURRENT='Unknown'
- CPU_TEMP_PRINT='Unknown'
-
-
+ CPU_TEMP_CURRENT='N/A'
+ CPU_TEMP_PRINT='N/A'
Obtain_Cpu_Temp(){
CPU_TEMP_CURRENT=$(G_OBTAIN_CPU_TEMP)
- local cpu_temp_current_f='Unknown'
- if disable_error=1 G_CHECK_VALIDINT $CPU_TEMP_CURRENT; then
+ if disable_error=1 G_CHECK_VALIDINT "$CPU_TEMP_CURRENT"; then
- cpu_temp_current_f=$(( ( $CPU_TEMP_CURRENT * 9 / 5 ) + 32 ))
+ local cpu_temp_current_f=$(( $CPU_TEMP_CURRENT * 9/5 + 32 ))
if (( $CPU_TEMP_CURRENT >= 70 )); then
CPU_TEMP_PRINT="\e[1;31mWarning: $CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f | Reducing the life of your device.\e[0m"
@@ -151,12 +139,13 @@
else
- CPU_TEMP_PRINT="\e[1;31mKERNELERR: $CPU_TEMP_CURRENT'c\e[0m"
+ CPU_TEMP_PRINT=$CPU_TEMP_CURRENT
fi
}
+ CPU_GOV_CURRENT='N/A'
Obtain_Cpu_Gov(){
if [[ -f /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor ]]; then
@@ -171,27 +160,30 @@
echo -e "\n \e[38;5;154m─────────────────────────────────────────────────────\e[0m\n \e[1mDietPi CPU Info\n\e[90m Use dietpi-config to change CPU / performance options\e[0m\n \e[38;5;154m─────────────────────────────────────────────────────\e[0m"
- #Processor Type
+ #VM does not support most info
+ (( $G_HW_MODEL == 20 )) && echo -e '\n\e[90m[\e[93mWARNING\e[90m] \e[97mMost CPU information is not available on VM.\e[0m\n'
+
+ #Processor Arch
echo -e " Architecture \e[90m|\e[0m $(uname -m)"
#Current Temp
- echo -e " Temp \e[90m|\e[0m $CPU_TEMP_PRINT"
+ echo -e " Temperature \e[90m|\e[0m $CPU_TEMP_PRINT"
#Current Gov
echo -e " Governor \e[90m|\e[0m $CPU_GOV_CURRENT"
if [[ $CPU_GOV_CURRENT == 'ondemand' || $CPU_GOV_CURRENT == 'conservative' ]]; then
- echo -e " Throttle up \e[90m|\e[0m $(grep -m1 '^CONFIG_CPU_USAGE_THROTTLE_UP=' /DietPi/dietpi.txt | sed 's/.*=//')% CPU usage"
+ echo -e " Throttle up \e[90m|\e[0m $(grep -m1 '^[[:blank:]]*CONFIG_CPU_USAGE_THROTTLE_UP=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')% CPU usage"
fi
#Current Frequency
- echo -e '\n \e[90m Current Freq Min Freq Max Freq\e[0m'
+ (( ${#aCPU_CURRENT_FREQ[@]} )) && echo -e '\n \e[90m Current Freq Min Freq Max Freq\e[0m'
for ((i=0; i<${#aCPU_CURRENT_FREQ[@]}; i++))
do
- echo -e " \e[90mCPU$i |\e[0m $(( ${aCPU_CURRENT_FREQ[$i]} / 1000 )) MHz \e[90m$(( ${aCPU_MIN_FREQ[$i]} / 1000 )) MHz $(( ${aCPU_MAX_FREQ[$i]} / 1000 )) MHz\e[0m"
+ echo -e " \e[90mCPU$i |\e[0m $(( ${aCPU_CURRENT_FREQ[$i]:-0} / 1000 )) MHz \e[90m$(( ${aCPU_MIN_FREQ[$i]:-0} / 1000 )) MHz $(( ${aCPU_MAX_FREQ[$i]:-0} / 1000 )) MHz\e[0m"
done
@@ -210,17 +202,17 @@
#Return mode
if (( $INPUT == 2 )); then
- Obtain_Cpu_Freq
+ Obtain_Cpu_Scaling_Freq
# Export to file
- rm $FP_CPU_SCALINGAVAILABLE_FREQ &> /dev/null
+ > $FP_CPU_SCALINGAVAILABLE_FREQ
if (( $CPU_SCALINGSUPPORTED )); then
- for ((i=0; i<${#aCPU_SCALINGAVAILABLE_FREQ[@]}; i++))
+ for i in ${aCPU_SCALINGAVAILABLE_FREQ[@]}
do
- echo -e "${aCPU_SCALINGAVAILABLE_FREQ[$i]}" >> $FP_CPU_SCALINGAVAILABLE_FREQ
+ echo -e "$i" >> $FP_CPU_SCALINGAVAILABLE_FREQ
done
@@ -240,13 +232,6 @@
fi
- #-----------------------------------------------------------------------------------
- #Delete[] array
- unset aCPU_CURRENT_FREQ
- unset aCPU_MIN_FREQ
- unset aCPU_MAX_FREQ
- unset aCPU_SCALINGAVAILABLE_FREQ
- unset afp_temperature
#-----------------------------------------------------------------------------------
exit
#-----------------------------------------------------------------------------------
diff --git a/dietpi/dietpi-cron b/dietpi/dietpi-cron
index 7387b0782b..795bf72f57 100644
--- a/dietpi/dietpi-cron
+++ b/dietpi/dietpi-cron
@@ -17,8 +17,8 @@
#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
- G_CHECK_ROOT_USER
G_PROGRAM_NAME='DietPi-Cron'
+ G_CHECK_ROOT_USER
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
@@ -43,35 +43,31 @@
Read_Cron_Times(){
#hourly_min
- aCRON_TIME[0]=$(grep -m1 'cron.hourly' /etc/crontab | awk '{print $1}')
+ aCRON_TIME[0]=$(mawk '/cron.hourly/ {print $1;exit}' /etc/crontab)
#daily_min / daily_hour
- aCRON_TIME[1]=$(grep -m1 'cron.daily' /etc/crontab | awk '{print $1}')
- aCRON_TIME[2]=$(grep -m1 'cron.daily' /etc/crontab | awk '{print $2}')
+ aCRON_TIME[1]=$(mawk '/cron.daily/ {print $1;exit}' /etc/crontab)
+ aCRON_TIME[2]=$(mawk '/cron.daily/ {print $2;exit}' /etc/crontab)
#weekly_min / weekly_hour / weekly_day_of_week
- aCRON_TIME[3]=$(grep -m1 'cron.weekly' /etc/crontab | awk '{print $1}')
- aCRON_TIME[4]=$(grep -m1 'cron.weekly' /etc/crontab | awk '{print $2}')
- aCRON_TIME[5]=$(grep -m1 'cron.weekly' /etc/crontab | awk '{print $5}')
+ aCRON_TIME[3]=$(mawk '/cron.weekly/ {print $1;exit}' /etc/crontab)
+ aCRON_TIME[4]=$(mawk '/cron.weekly/ {print $2;exit}' /etc/crontab)
+ aCRON_TIME[5]=$(mawk '/cron.weekly/ {print $5;exit}' /etc/crontab)
#monthly_min / monthly_hour / monthly_day_of_month
- aCRON_TIME[6]=$(grep -m1 'cron.monthly' /etc/crontab | awk '{print $1}')
- aCRON_TIME[7]=$(grep -m1 'cron.monthly' /etc/crontab | awk '{print $2}')
- aCRON_TIME[8]=$(grep -m1 'cron.monthly' /etc/crontab | awk '{print $3}')
+ aCRON_TIME[6]=$(mawk '/cron.monthly/ {print $1;exit}' /etc/crontab)
+ aCRON_TIME[7]=$(mawk '/cron.monthly/ {print $2;exit}' /etc/crontab)
+ aCRON_TIME[8]=$(mawk '/cron.monthly/ {print $3;exit}' /etc/crontab)
#minutely_min
- aCRON_TIME[9]=$(grep -m1 'cron.minutely' /etc/crontab | awk -F'[/ ]' '{print $2}')
+ aCRON_TIME[9]=$(mawk -F'[/ ]' '/cron.minutely/ {print $2;exit}' /etc/crontab)
#Check for valid ints
- for ((i=0; i<${#aCRON_TIME[@]}; i++))
+ for i in "${!aCRON_TIME[@]}"
do
- if ! disable_error=1 G_CHECK_VALIDINT ${aCRON_TIME[$i]}; then
-
- #override
- aCRON_TIME[$i]=1
-
- fi
+ #override
+ disable_error=1 G_CHECK_VALIDINT "${aCRON_TIME[$i]}" || aCRON_TIME[$i]=1
done
@@ -80,16 +76,16 @@
Write_Cron_Times(){
cat << _EOF_ > /etc/crontab
-#Please use dietpi-cron to change cron start times
+# Please use dietpi-cron to change cron start times
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
-# m h dom mon dow user command
-*/${aCRON_TIME[9]} * * * * root cd / && run-parts --report /etc/cron.minutely
-${aCRON_TIME[0]} * * * * root cd / && run-parts --report /etc/cron.hourly
-${aCRON_TIME[1]} ${aCRON_TIME[2]} * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
-${aCRON_TIME[3]} ${aCRON_TIME[4]} * * ${aCRON_TIME[5]} root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
-${aCRON_TIME[6]} ${aCRON_TIME[7]} ${aCRON_TIME[8]} * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
+# m h dom mon dow user command
+*/${aCRON_TIME[9]} * * * * root cd / && run-parts --report /etc/cron.minutely
+${aCRON_TIME[0]} * * * * root cd / && run-parts --report /etc/cron.hourly
+${aCRON_TIME[1]} ${aCRON_TIME[2]} * * * root test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.daily; }
+${aCRON_TIME[3]} ${aCRON_TIME[4]} * * ${aCRON_TIME[5]} root test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.weekly; }
+${aCRON_TIME[6]} ${aCRON_TIME[7]} ${aCRON_TIME[8]} * * root test -x /usr/sbin/anacron || { cd / && run-parts --report /etc/cron.monthly; }
_EOF_
(( ${aCRON_TIME[9]} == 0 )) && sed -i 's|^*/0 |#*/0 |' /etc/crontab
@@ -103,15 +99,12 @@ _EOF_
local max_value=59
G_WHIP_DEFAULT_ITEM=$input_value
- G_WHIP_INPUTBOX "Please enter the execution interval in minutes:\n - Valid range (0 - $max_value)\n - Enter 0 to disable this job"
- if (( $? == 0 )); then
+ if G_WHIP_INPUTBOX "Please enter the execution interval in minutes:
+ - Valid range (0 - $max_value)
+ - Enter 0 to disable this job"; then
#Valid input?
- if G_CHECK_VALIDINT $G_WHIP_RETURNED_VALUE $min_value $max_value; then
-
- input_value=$G_WHIP_RETURNED_VALUE
-
- fi
+ G_CHECK_VALIDINT "$G_WHIP_RETURNED_VALUE" $min_value $max_value && input_value=$G_WHIP_RETURNED_VALUE
fi
@@ -126,15 +119,10 @@ _EOF_
local max_value=59
G_WHIP_DEFAULT_ITEM=$input_value
- G_WHIP_INPUTBOX "Please enter a value for MINUTE:\n - Valid range ($min_value - $max_value)"
- if (( $? == 0 )); then
+ if G_WHIP_INPUTBOX "Please enter a value for MINUTE:\n - Valid range ($min_value - $max_value)"; then
#Valid input?
- if G_CHECK_VALIDINT $G_WHIP_RETURNED_VALUE $min_value $max_value; then
-
- input_value=$G_WHIP_RETURNED_VALUE
-
- fi
+ G_CHECK_VALIDINT "$G_WHIP_RETURNED_VALUE" $min_value $max_value && input_value=$G_WHIP_RETURNED_VALUE
fi
@@ -149,15 +137,10 @@ _EOF_
local max_value=23
G_WHIP_DEFAULT_ITEM=$input_value
- G_WHIP_INPUTBOX "Please enter a value for HOUR (24h):\n - Valid range ($min_value - $max_value)"
- if (( $? == 0 )); then
+ if G_WHIP_INPUTBOX "Please enter a value for HOUR (24h):\n - Valid range ($min_value - $max_value)"; then
#Valid input?
- if G_CHECK_VALIDINT $G_WHIP_RETURNED_VALUE $min_value $max_value; then
-
- input_value=$G_WHIP_RETURNED_VALUE
-
- fi
+ G_CHECK_VALIDINT "$G_WHIP_RETURNED_VALUE" $min_value $max_value && input_value=$G_WHIP_RETURNED_VALUE
fi
@@ -184,12 +167,7 @@ _EOF_
)
G_WHIP_DEFAULT_ITEM=$input_value
- G_WHIP_MENU "Please select a day of the week."
- if (( $? == 0 )); then
-
- input_value=$G_WHIP_RETURNED_VALUE
-
- fi
+ G_WHIP_MENU 'Please select a day of the week.' && input_value=$G_WHIP_RETURNED_VALUE
return $input_value
@@ -202,15 +180,12 @@ _EOF_
local max_value=28
G_WHIP_DEFAULT_ITEM=$input_value
- G_WHIP_INPUTBOX "Please enter a value for DAY of the MONTH:\n - Valid range ($min_value - $max_value)\n - eg: 11 = the 11th day of month"
- if (( $? == 0 )); then
+ if G_WHIP_INPUTBOX "Please enter a value for DAY of the MONTH:
+ - Valid range ($min_value - $max_value)
+ - eg: 11 = the 11th day of month"; then
#Valid input?
- if G_CHECK_VALIDINT $G_WHIP_RETURNED_VALUE $min_value $max_value; then
-
- input_value=$G_WHIP_RETURNED_VALUE
-
- fi
+ G_CHECK_VALIDINT "$G_WHIP_RETURNED_VALUE" $min_value $max_value && input_value=$G_WHIP_RETURNED_VALUE
fi
@@ -222,8 +197,7 @@ _EOF_
Menu_Exit(){
G_WHIP_SIZE_X_MAX=50
- G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"; then
#exit
TARGETMENUID=-1
@@ -241,13 +215,13 @@ _EOF_
case "${aCRON_TIME[9]}" in
- "0")
+ '0')
minute_string='Disabled'
;;
- "1")
+ '1')
minute_string='Every Minute'
@@ -276,27 +250,27 @@ _EOF_
G_WHIP_DEFAULT_ITEM="$PREVIOUS_MENU_SELECTION"
G_WHIP_BUTTON_CANCEL_TEXT='Exit'
- G_WHIP_MENU "$G_PROGRAM_NAME allows you to change the date and times for starting each cron job.\n\n- Example:\nIf you set cron.daily to 22 hours and 20 minutes, all scripts in /etc/cron.daily/* will be run at 10:20pm."
- if (( $? == 0 )); then
+ if G_WHIP_MENU "$G_PROGRAM_NAME allows you to change the date and times for starting each cron job.
+\n- Example:\nIf you set cron.daily to 22 hours and 20 minutes, all scripts in /etc/cron.daily/* will be run at 10:20pm."; then
PREVIOUS_MENU_SELECTION=$G_WHIP_RETURNED_VALUE
case "$G_WHIP_RETURNED_VALUE" in
- "cron.minutely")
+ 'cron.minutely')
Input_Cron_Minutely_Minute ${aCRON_TIME[9]}
aCRON_TIME[9]=$?
;;
- "cron.hourly")
+ 'cron.hourly')
Input_Cron_Minute ${aCRON_TIME[0]}
aCRON_TIME[0]=$?
;;
- "cron.daily")
+ 'cron.daily')
Input_Cron_Hour ${aCRON_TIME[2]}
aCRON_TIME[2]=$?
@@ -305,7 +279,7 @@ _EOF_
aCRON_TIME[1]=$?
;;
- "cron.weekly")
+ 'cron.weekly')
Input_Cron_DayOfWeek ${aCRON_TIME[5]}
aCRON_TIME[5]=$?
@@ -317,7 +291,7 @@ _EOF_
aCRON_TIME[3]=$?
;;
- "cron.monthly")
+ 'cron.monthly')
Input_Cron_DayOfMonth ${aCRON_TIME[8]}
aCRON_TIME[8]=$?
@@ -330,7 +304,7 @@ _EOF_
;;
- "Apply")
+ 'Apply')
Write_Cron_Times
#restart service
@@ -363,18 +337,10 @@ _EOF_
printf '\ec' # clear current terminal screen
- if (( $TARGETMENUID == 0 )); then
-
- Menu_Main
-
- fi
+ (( $TARGETMENUID )) || Menu_Main
done
#-----------------------------------------------------------------------------------
- #delete[]
- unset aDAY_OF_THE_WEEK_TEXT
- unset aCRON_TIME
- #-----------------------------------------------------------------------------------
exit
#-----------------------------------------------------------------------------------
}
diff --git a/dietpi/dietpi-drive_manager b/dietpi/dietpi-drive_manager
index bdf5b5e95c..905ac8269a 100644
--- a/dietpi/dietpi-drive_manager
+++ b/dietpi/dietpi-drive_manager
@@ -24,24 +24,18 @@
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
- #Custom exit trap extension, being called on every kind of script exit, err, int
- G_EXIT_CUSTOM(){
-
- Destroy
-
- }
-
#Grab Input (valid interger)
INPUT=0
- disable_error=1 G_CHECK_VALIDINT $1 && INPUT=$1
+ disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1
EXIT_CODE=0
- DEBUG=${DEBUG:-0}
-
#Service control for script
SERVICE_CONTROL=1
+ #APT pre-req check flag, allows to check for required APT packages only once per session
+ APT_CHECK=0
+
#Return values
FP_DRIVE_MANAGER_SELECTION='/tmp/dietpi-drive_manager_selmnt'
@@ -115,36 +109,36 @@
Init_Drives_and_Refresh(){
#---------------------------------------------------------------
- #Delete arrays before reinit
+ # Reset current index and delete arrays
Destroy
- # - Obtain actual user data location on disk (follows symlinks)
- FP_USERDATA_CURRENT="$(readlink -f $G_FP_DIETPI_USERDATA)"
+ # Obtain actual user data location on disk (follows symlinks)
+ FP_USERDATA_CURRENT=$(readlink -f $G_FP_DIETPI_USERDATA)
- # - Swapfile location
- FP_SWAPFILE_CURRENT="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
+ # Swapfile location
+ FP_SWAPFILE_CURRENT=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
- # - ROOTFS location
+ # RootFS location
FP_ROOTFS_SOURCE=$(findmnt / -o source -n)
- #Recreate FStab
+ # Recreate FStab
cp -a /etc/fstab $FP_TEMP_FSTAB
- # - Grab current tmpfs entries
+ # Grab current tmpfs entries
local tmpfs_mounts=$(grep '^tmpfs[[:blank:]]' $FP_TEMP_FSTAB)
- # - Grab current bind
+ # Grab current bind mounts
local bind_mounts=$(grep '[[:blank:],]bind[[:blank:],]' $FP_TEMP_FSTAB)
- # - Grab current swap
+ # Grab current swap
local swap_mount=$(grep -m1 '[[:blank:]]swap[[:blank:]]' $FP_TEMP_FSTAB)
- # - Grab current network mounts + creds
+ # Grab current network mounts + creds
local net_mounts_samba=$(grep '[[:blank:]]cifs[[:blank:]]' $FP_TEMP_FSTAB)
local net_mounts_nfs=$(grep '[[:blank:]]nfs.*[[:blank:]]' $FP_TEMP_FSTAB)
local net_mounts_ftp=$(grep '^curlftpfs' $FP_TEMP_FSTAB)
- # Force regen (PREP)
+ # Force reset/clean fstab (PREP)
if (( $INPUT == 4 )); then
bind_mounts=''
@@ -154,11 +148,9 @@
net_mounts_ftp=''
local var_log_size=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_RAMLOG_MAXSIZE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
- tmpfs_mounts="
-tmpfs /tmp tmpfs defaults,noatime,nodev,nosuid,mode=1777 0 0
+ tmpfs_mounts="tmpfs /tmp tmpfs defaults,noatime,nodev,nosuid,mode=1777 0 0
tmpfs /var/log tmpfs defaults,size=${var_log_size}m,noatime,nodev,nosuid,mode=1777 0 0
-tmpfs /DietPi tmpfs defaults,size=10m,noatime,nodev,nosuid,mode=1777 0 0
-"
+tmpfs /DietPi tmpfs defaults,size=10m,noatime,nodev,nosuid,mode=1777 0 0"
fi
@@ -189,34 +181,23 @@ $swap_mount
#PHYSICAL DRIVES
#-----------------------------------------------------------" > $FP_TEMP_FSTAB
- #Detect mounted drives and add them to fstab
+ # Detect mounted drives and add them to fstab
G_DIETPI-NOTIFY 2 'Detecting drives, please wait...'
- local cmd_scrape_string=''
- local index=0
- G_DIETPI-NOTIFY 0 'Detecting currently mounted drives, please wait...'
df -Pha | tail -n +2 > .dietpi-drive_manager_df_tmp
# - Remove items from list
- # Bind : https://github.com/Fourdee/DietPi/issues/2013#issuecomment-416394374
+ # Bind: https://github.com/Fourdee/DietPi/issues/2013#issuecomment-416394374
while read line
do
- if [[ ! $line ]]; then
-
- continue
-
- fi
+ [[ $line ]] || continue
# - Bind
- local input_bind_mount_source="$(awk '{print $1}' <<< $line)"
- local input_bind_mount_target="$(awk '{print $2}' <<< $line)"
+ local input_bind_mount_source=$(mawk '{print $1}' <<< $line)
+ local input_bind_mount_target=$(mawk '{print $2}' <<< $line)
sed -i "\#[[:blank:]]$input_bind_mount_target#d" .dietpi-drive_manager_df_tmp
sed -i "\#[[:blank:]]$input_bind_mount_source#d" .dietpi-drive_manager_df_tmp
- if (( $DEBUG )); then
-
- G_DIETPI-NOTIFY 0 "BIND: match removed from df scrape: $input_bind_mount_source > $input_bind_mount_target"
-
- fi
+ [[ $G_DEBUG == 1 ]] && G_DIETPI-NOTIFY 0 " - Detected bind mount and removed from df scrape: $input_bind_mount_source > $input_bind_mount_target"
done <<< "$bind_mounts"
@@ -224,61 +205,49 @@ $swap_mount
while read line
do
- if [[ ! $line ]]; then
-
- continue
+ [[ $line ]] || continue
- elif [[ $(awk '{print $1}' <<< $line) =~ '/' ]]; then
+ if [[ $(mawk '{print $1}' <<< $line) =~ '/' ]]; then
Init_New_Device
aDRIVE_ISMOUNTED[$INDEX_INIT_CURRENT_DEVICE]=1
aDRIVE_ISPARTITIONTABLE[$INDEX_INIT_CURRENT_DEVICE]=1
- aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]=$(awk '{print $1}' <<< $line)
- aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]=$(awk '{print $6}' <<< $line)
- # Workaround for /dev/root under RPi, force physical location
- if [[ ${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]} == '/' ]]; then
-
- aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]=$FP_ROOTFS_SOURCE
-
- fi
+ aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]=$(mawk '{print $1}' <<< $line)
+ aDRIVE_SIZE_TOTAL[$INDEX_INIT_CURRENT_DEVICE]=$(mawk '{print $2}' <<< $line)
+ aDRIVE_SIZE_USED[$INDEX_INIT_CURRENT_DEVICE]=$(mawk '{print $3}' <<< $line)
+ aDRIVE_SIZE_FREE[$INDEX_INIT_CURRENT_DEVICE]=$(mawk '{print $4}' <<< $line)
+ aDRIVE_SIZE_PERCENTUSED[$INDEX_INIT_CURRENT_DEVICE]=$(mawk '{print $5}' <<< $line)
+ aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]=$(mawk '{print $6}' <<< $line)
+ # - Workaround for /dev/root under RPi, force physical location
+ [[ ${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]} == '/' ]] && aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]=$FP_ROOTFS_SOURCE
aDRIVE_SOURCE_DEVICE[$INDEX_INIT_CURRENT_DEVICE]=$(Return_Drive_Without_Partitions ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]})
- # - Networked?
- if [[ ! -d '/sys/block/'${aDRIVE_SOURCE_DEVICE[$INDEX_INIT_CURRENT_DEVICE]} ]]; then
-
- aDRIVE_ISNETWORKED[$INDEX_INIT_CURRENT_DEVICE]=1
- aDRIVE_ISFILESYSTEM[$INDEX_INIT_CURRENT_DEVICE]=1
- aDRIVE_FSTYPE[$INDEX_INIT_CURRENT_DEVICE]='Net'
+ aDRIVE_UUID[$INDEX_INIT_CURRENT_DEVICE]=$(blkid ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]} -s UUID -o value)
+ aDRIVE_PART_UUID[$INDEX_INIT_CURRENT_DEVICE]=$(blkid ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]} -s PARTUUID -o value)
- # - Physical
- else
+ # - Physical?
+ if [[ -d '/sys/block/'${aDRIVE_SOURCE_DEVICE[$INDEX_INIT_CURRENT_DEVICE]} ]]; then
- cmd_scrape_string=$(blkid ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]} -s TYPE -o value)
- if [[ $cmd_scrape_string ]]; then
+ aDRIVE_FSTYPE[$INDEX_INIT_CURRENT_DEVICE]=$(blkid ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]} -s TYPE -o value)
+ [[ ${aDRIVE_FSTYPE[$INDEX_INIT_CURRENT_DEVICE]} ]] && aDRIVE_ISFILESYSTEM[$INDEX_INIT_CURRENT_DEVICE]=1
- aDRIVE_ISFILESYSTEM[$INDEX_INIT_CURRENT_DEVICE]=1
- aDRIVE_FSTYPE[$INDEX_INIT_CURRENT_DEVICE]=$cmd_scrape_string
+ # - Networked
+ else
- fi
+ aDRIVE_ISNETWORKED[$INDEX_INIT_CURRENT_DEVICE]=1
+ aDRIVE_FSTYPE[$INDEX_INIT_CURRENT_DEVICE]='Net'
+ aDRIVE_ISFILESYSTEM[$INDEX_INIT_CURRENT_DEVICE]=1
fi
- G_DIETPI-NOTIFY 2 " - Detected: ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]} > ${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]}"
+ G_DIETPI-NOTIFY 2 " - Detected mounted drive: ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]} > ${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]}"
- aDRIVE_SIZE_TOTAL[$INDEX_INIT_CURRENT_DEVICE]=$(awk '{print $2}' <<< $line)
- aDRIVE_SIZE_USED[$INDEX_INIT_CURRENT_DEVICE]=$(awk '{print $3}' <<< $line)
- aDRIVE_SIZE_FREE[$INDEX_INIT_CURRENT_DEVICE]=$(awk '{print $4}' <<< $line)
- aDRIVE_SIZE_PERCENTUSED[$INDEX_INIT_CURRENT_DEVICE]=$(awk '{print $5}' <<< $line)
-
- aDRIVE_UUID[$INDEX_INIT_CURRENT_DEVICE]=$(blkid ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]} -s UUID -o value)
- aDRIVE_PART_UUID[$INDEX_INIT_CURRENT_DEVICE]=$(blkid ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]} -s PARTUUID -o value)
-
- #RO mounted?
- #NB: We cant use -m1 for initial check as results can be:
- # root@DietPi:~# cat /proc/mounts | grep ' / '
- # rootfs / rootfs rw 0 0
- # /dev/mmcblk0p2 / ext4 ro,noatime,discard,data=ordered 0 0
+ # - RO mounted?
+ # - NB: We cant use -m1 for initial check as results can be:
+ # root@DietPi:~# cat /proc/mounts | grep ' / '
+ # rootfs / rootfs rw 0 0
+ # /dev/mmcblk0p2 / ext4 ro,noatime,discard,data=ordered 0 0
if grep -q "[[:blank:]]${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]}[[:blank:]].*[[:blank:]]ro," /proc/mounts; then
aDRIVE_ISREADONLY_CURRENTLY[$INDEX_INIT_CURRENT_DEVICE]=1
@@ -286,21 +255,18 @@ $swap_mount
# - RootFS RW check
if [[ ${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]} == '/' ]]; then
- G_DIETPI-NOTIFY 2 "RootFS is currently set to R/O. $G_PROGRAM_NAME requires R/W access."
-
- G_WHIP_YESNO "RootFS is currently set to 'Read Only'. $G_PROGRAM_NAME requires 'Read Write' access to function.\n\nWould you like to re-enable 'Read Write' access on RootFS?"
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "RootFS is currently set to \"Read Only (R/O)\". $G_PROGRAM_NAME requires \"Read Write (R/W)\" access to function.\n\nWould you like to re-enable R/W access on RootFS?"; then
G_RUN_CMD mount -v -o rw,remount ${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]}
aDRIVE_ISREADONLY_CURRENTLY[$INDEX_INIT_CURRENT_DEVICE]=0
- G_DIETPI-NOTIFY 0 'RootFS R/W now enabled.'
+ G_DIETPI-NOTIFY 0 'Remounted RootFS with R/W access'
else
/DietPi/dietpi/dietpi-services start
- G_DIETPI-NOTIFY 0 'RootFS currently set to R/O.'
- G_DIETPI-NOTIFY 2 'Please run "dietpi-drive_manager" again, if you want to re-enable RootFS R/W.'
+ G_DIETPI-NOTIFY 1 "RootFS is currently set to R/O. $G_PROGRAM_NAME requires R/W access to function. Aborting..."
+ G_DIETPI-NOTIFY 2 'Rerun "dietpi-drive_manager" to enable RootFS R/W access.'
exit
@@ -314,33 +280,29 @@ $swap_mount
if [[ ${aDRIVE_UUID[$INDEX_INIT_CURRENT_DEVICE]} ]]; then
local string_options=',rw'
- if (( ${aDRIVE_ISREADONLY_CURRENTLY[$INDEX_INIT_CURRENT_DEVICE]} )); then
-
- string_options=',ro'
+ (( ${aDRIVE_ISREADONLY_CURRENTLY[$INDEX_INIT_CURRENT_DEVICE]} )) && string_options=',ro'
- fi
-
- # - UUID or PARTUUID entry?
+ # - Root/BootFS dependant flags
+ # On RPi we need to use PARTUUID for Root/BootFS
local dev_entry="UUID=${aDRIVE_UUID[$INDEX_INIT_CURRENT_DEVICE]}"
- if (( $G_HW_MODEL < 10 )) &&
- [[ ${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]} == '/' || ${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]} == '/boot' ]]; then
-
- dev_entry="PARTUUID=${aDRIVE_PART_UUID[$INDEX_INIT_CURRENT_DEVICE]}"
+ # fsck flag for RootFS, to allow check on reboot and for BootFS, since corruption here is most critical and fsck finishes in no time
+ # nofail: Allow boot to continue, if mount fails, not wanted for Root/BootFS
+ # x-systemd.automount: [ 1166.110202] systemd-fstab-generator[3512]: Ignoring automount option for root device
+ # /boot is removed from local-fs.target by this (on Buster only?), allowing it to mount after RAMdisk starts and unmount before it stops.
+ local fsck_flag=0
+ if [[ ${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]} =~ ^/(boot)?$ ]]; then
- fi
+ (( $G_HW_MODEL < 10 )) && dev_entry="PARTUUID=${aDRIVE_PART_UUID[$INDEX_INIT_CURRENT_DEVICE]}"
+ fsck_flag=1
- # - Non-RootFS flags
- # fsck flag for root device, to allow check on reboot
- # x-systemd.automount: [ 1166.110202] systemd-fstab-generator[3512]: Ignoring automount option for root device
- local fsck_flag=1
- if [[ ${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]} != '/' ]]; then
+ else
string_options+=',nofail,x-systemd.automount'
- fsck_flag=0
fi
# - Additional options for fstype specific items
+ # NFTS: Enable POSIX permissions for NTFS
if [[ ${aDRIVE_FSTYPE[$INDEX_INIT_CURRENT_DEVICE]} == 'ntfs' ]]; then
string_options+=',permissions'
@@ -356,54 +318,40 @@ $swap_mount
done < .dietpi-drive_manager_df_tmp
rm .dietpi-drive_manager_df_tmp
- #Check blkid for unmounted drives, if drive is not mounted, add entry as disabled mount
- G_DIETPI-NOTIFY 0 'Detecting unmounted drives, please wait...'
+ # - Check blkid for unmounted drives, if drive is not mounted, add entry as disabled mount
blkid -o device > .dietpi-drive_manager_blkid_tmp
while read line
do
- if [[ ! $line ]]; then
-
- continue
-
- fi
+ [[ $line ]] || continue
for ((i=0; i<${#aDRIVE_MOUNT_SOURCE[@]}; i++))
do
- if [[ ${aDRIVE_MOUNT_SOURCE[$i]} == $line ]]; then
-
- break
-
- fi
+ [[ ${aDRIVE_MOUNT_SOURCE[$i]} == $line ]] && break
# - New unmounted drive found on system, add entry to fstab
# Must have a valid UUID! (this excludes /dev/mmcblk0)
- if (( $i == ( ${#aDRIVE_MOUNT_SOURCE[@]} - 1 ) )) &&
- [[ $(blkid $line -s UUID -o value) ]]; then
+ if (( $i == ${#aDRIVE_MOUNT_SOURCE[@]} - 1 )); then
+
+ local uuid=$(blkid $line -s UUID -o value)
+ [[ $uuid ]] || break
- G_DIETPI-NOTIFY 2 " - Detected unmounted drive: $line, updating fstab"
+ G_DIETPI-NOTIFY 2 " - Detected unmounted drive: $line"
Init_New_Device
+ aDRIVE_UUID[$INDEX_INIT_CURRENT_DEVICE]=$uuid
aDRIVE_ISPARTITIONTABLE[$INDEX_INIT_CURRENT_DEVICE]=1
aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]=$line
+ aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]="/mnt/${aDRIVE_UUID[$INDEX_INIT_CURRENT_DEVICE]}"
aDRIVE_SOURCE_DEVICE[$INDEX_INIT_CURRENT_DEVICE]=$(Return_Drive_Without_Partitions ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]})
- aDRIVE_UUID[$INDEX_INIT_CURRENT_DEVICE]=$(blkid ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]} -s UUID -o value)
aDRIVE_PART_UUID[$INDEX_INIT_CURRENT_DEVICE]=$(blkid ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]} -s PARTUUID -o value)
+ aDRIVE_FSTYPE[$INDEX_INIT_CURRENT_DEVICE]=$(blkid ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]} -s TYPE -o value)
+ [[ ${aDRIVE_FSTYPE[$INDEX_INIT_CURRENT_DEVICE]} ]] && aDRIVE_ISFILESYSTEM[$INDEX_INIT_CURRENT_DEVICE]=1
- aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]="/mnt/${aDRIVE_UUID[$INDEX_INIT_CURRENT_DEVICE]}"
-
- cmd_scrape_string=$(blkid ${aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]} -s TYPE -o value)
- if [[ $cmd_scrape_string ]]; then
-
- aDRIVE_ISFILESYSTEM[$INDEX_INIT_CURRENT_DEVICE]=1
- aDRIVE_FSTYPE[$INDEX_INIT_CURRENT_DEVICE]=$cmd_scrape_string
-
- fi
-
- echo "#UUID=${aDRIVE_UUID[$INDEX_INIT_CURRENT_DEVICE]} ${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]} auto defaults,x-systemd.automount,noatime,rw,nofail 0 0" >> $FP_TEMP_FSTAB
+ echo "#UUID=${aDRIVE_UUID[$INDEX_INIT_CURRENT_DEVICE]} ${aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]} auto defaults,noatime,rw,nofail,x-systemd.automount 0 0" >> $FP_TEMP_FSTAB
fi
@@ -412,60 +360,41 @@ $swap_mount
done < .dietpi-drive_manager_blkid_tmp
rm .dietpi-drive_manager_blkid_tmp
- #Find drives that have no partitions
- # - Exclude mtdblock devices: https://github.com/Fourdee/DietPi/issues/2067#issuecomment-422400520
+ # - Find drives that have no partitions
+ # Exclude mtdblock devices: https://github.com/Fourdee/DietPi/issues/2067#issuecomment-422400520
lsblk -nro NAME | sed '/^mtdblock[0-9]/d' > .dietpi-drive_manager_lsblk_tmp
while read line
do
- if [[ ! $line ]]; then
-
- continue
-
- fi
-
- local drive_already_exists=0
+ [[ $line ]] || continue
# - Exclude drives already found
- for ((i=0; i<${#aDRIVE_MOUNT_SOURCE[@]}; i++))
+ for i in ${!aDRIVE_MOUNT_SOURCE[@]}
do
- if [[ $line == ${aDRIVE_SOURCE_DEVICE[$i]}* ]]; then
-
- drive_already_exists=1
- break
-
- fi
+ [[ $line == ${aDRIVE_SOURCE_DEVICE[$i]}* ]] && continue 2
done
- if (( ! $drive_already_exists )); then
+ G_DIETPI-NOTIFY 2 " - Detected drive with no partitions: $line"
- G_DIETPI-NOTIFY 2 " - Detected drive with no partitions: $line"
-
- Init_New_Device
+ Init_New_Device
- aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]="/dev/$line"
- aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]="/tmp/$line"
- aDRIVE_SOURCE_DEVICE[$INDEX_INIT_CURRENT_DEVICE]=$line
-
- fi
+ aDRIVE_MOUNT_SOURCE[$INDEX_INIT_CURRENT_DEVICE]="/dev/$line"
+ aDRIVE_MOUNT_TARGET[$INDEX_INIT_CURRENT_DEVICE]="/tmp/$line"
+ aDRIVE_SOURCE_DEVICE[$INDEX_INIT_CURRENT_DEVICE]=$line
done < .dietpi-drive_manager_lsblk_tmp
rm .dietpi-drive_manager_lsblk_tmp
- #Set required global flags, for all drives found
- for ((i=0; i<${#aDRIVE_MOUNT_SOURCE[@]}; i++))
+ # - Set required global flags and deps for all drives found
+ for i in ${!aDRIVE_MOUNT_SOURCE[@]}
do
# - Detect and set ROM drives
- if [[ ${aDRIVE_MOUNT_SOURCE[$i]} == '/dev/sr'* ]]; then
-
- aDRIVE_ISROM[$i]=1
+ [[ ${aDRIVE_MOUNT_SOURCE[$i]} == '/dev/sr'* ]] && aDRIVE_ISROM[$i]=1
- fi
-
- # - Collect needed file system write packages
+ # - Collect required APT packages for FS R/W access
if [[ ${aDRIVE_FSTYPE[$i]} == 'ntfs' ]]; then
local need_ntfs='ntfs-3g'
@@ -478,10 +407,11 @@ $swap_mount
done
- if (( $DEBUG )); then
+ # - Debug drive detection, exit after first init
+ if [[ $G_DEBUG == 1 ]]; then
G_DIETPI-NOTIFY 0 'DEBUG INFO:'
- for ((i=0; i<${#aDRIVE_MOUNT_SOURCE[@]}; i++))
+ for i in ${!aDRIVE_MOUNT_SOURCE[@]}
do
G_DIETPI-NOTIFY 0 "Index=$i
@@ -509,7 +439,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
fi
- #Remove x-systemd.automount if not supported by kernel: https://github.com/Fourdee/DietPi/issues/1607#issuecomment-372030565
+ # - Remove x-systemd.automount if not supported by kernel: https://github.com/Fourdee/DietPi/issues/1607#issuecomment-372030565
if ! modprobe autofs4 --dry-run &> /dev/null; then
sed -i 's/,x-systemd.automount//g' $FP_TEMP_FSTAB
@@ -517,16 +447,16 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
fi
- #Find the drive we are to edit, then set its index (this is due to array list total being not constant)
+ # - Find the drive we are to edit, then set its index (this is due to array list total being not constant)
if [[ $DRIVE_TARGET_BEING_EDITED ]]; then
- for ((i=0; i<${#aDRIVE_MOUNT_SOURCE[@]}; i++))
+ for i in ${!aDRIVE_MOUNT_SOURCE[@]}
do
if [[ $DRIVE_TARGET_BEING_EDITED == ${aDRIVE_MOUNT_TARGET[$i]} ]]; then
INDEX_DRIVE_BEING_EDITED=$i
- (( $DEBUG )) && echo "[DEBUG$i] EDIT | ${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]} | ${aDRIVE_MOUNT_SOURCE[$INDEX_DRIVE_BEING_EDITED]} | ${aDRIVE_SOURCE_DEVICE[$INDEX_DRIVE_BEING_EDITED]}"
+ [[ $G_DEBUG == 1 ]] && echo "[DEBUG$i] EDIT | ${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]} | ${aDRIVE_MOUNT_SOURCE[$INDEX_DRIVE_BEING_EDITED]} | ${aDRIVE_SOURCE_DEVICE[$INDEX_DRIVE_BEING_EDITED]}"
break
fi
@@ -540,12 +470,8 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
rm $FP_TEMP_FSTAB
- # Install needed file system write packages
- if [[ $need_ntfs || $need_hfs ]]; then
-
- G_AG_CHECK_INSTALL_PREREQ $need_ntfs $need_hfs
-
- fi
+ # - Install required APT packages for FS R/W access
+ (( ! $APT_CHECK )) && [[ $need_ntfs || $need_hfs ]] && G_AG_CHECK_INSTALL_PREREQ $need_ntfs $need_hfs && APT_CHECK=1
sync
mount -a
@@ -579,7 +505,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
#MMC/NVMe
else
- echo ${drive%[p][0-9]}
+ echo ${drive%p[0-9]}
fi
@@ -599,7 +525,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
if [[ $G_WHIP_RETURNED_VALUE == '/mnt/'* ]]; then
# - replace spaces with underscores
- target="${G_WHIP_RETURNED_VALUE//[[:space:]]/_}"
+ target=${G_WHIP_RETURNED_VALUE//[[:space:]]/_}
else
@@ -611,7 +537,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
if [[ -d $target ]]; then
- if [[ $(ls -A $target) ]]; then
+ if [[ $(ls -A "$target") ]]; then
G_WHIP_MSG "Error:\n\nThe mount target directory already exists, and, contains data:\n - $target\n\nPlease retry, using a unique mount target location."
apply_mount=0
@@ -619,11 +545,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
else
G_WHIP_YESNO "Warning:\n\nThe mount target directory already exists, however, it does not contain any files or data at this time:\n - $target\n\nDo you wish to ignore this warning, and, mount the drive regardless?"
- if (( $? != 0 )); then
-
- apply_mount=0
-
- fi
+ (( $? )) && apply_mount=0
fi
@@ -654,8 +576,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
local target=$1
- G_ERROR_HANDLER_INFO_ONLY=1 G_RUN_CMD umount $target
- if (( $? == 0 )); then
+ if G_ERROR_HANDLER_INFO_ONLY=1 G_RUN_CMD umount "$target"; then
sed -i "\#[[:space:]]$target[[:space:]]#d" /etc/fstab #Only needed for networked drives currently...
Rm_Empty_Dir "$target"
@@ -671,12 +592,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
systemctl unmask dietpi-fs_partition_resize
G_RUN_CMD systemctl enable dietpi-fs_partition_resize
- G_WHIP_YESNO 'RootFS resize will occur on next reboot.\n\nWould you like to reboot the system now?'
- if (( $? == 0 )); then
-
- reboot
-
- fi
+ G_WHIP_YESNO 'RootFS resize will occur on next reboot.\n\nWould you like to reboot the system now?' && reboot
else
@@ -688,17 +604,12 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
Run_Format(){
- local run_format=0
local info_format_fs_type=''
local info_format_type_output='Drive format' #used in complete message
local text_desc=''
# - No partition table, force drive wipe
- if (( ! ${aDRIVE_ISPARTITIONTABLE[$INDEX_DRIVE_BEING_EDITED]} )); then
-
- FORMAT_MODE=0
-
- fi
+ (( ${aDRIVE_ISPARTITIONTABLE[$INDEX_DRIVE_BEING_EDITED]} )) || FORMAT_MODE=0
if (( $FORMAT_MODE == 0 )); then
@@ -709,21 +620,14 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
text_desc=" - ${aDRIVE_MOUNT_SOURCE[$INDEX_DRIVE_BEING_EDITED]}\n - UUID=${aDRIVE_UUID[$INDEX_DRIVE_BEING_EDITED]}\n - Filesystem type: $format_type_text\n\nALL DATA on this PARTITION will be DELETED.\nDo you wish to continue?"
fi
- G_WHIP_YESNO "Ready to format:\n$text_desc"
- if (( ! $? )); then
-
- run_format=1
-
- fi
-
- if (( $run_format )); then
+ if G_WHIP_YESNO "Ready to format:\n$text_desc"; then
# - Drive format
# Create a new partition table
if (( $FORMAT_MODE == 0 )); then
# - Umount and Zero All Partitions on device
- for ((i=1; i<=9; i++))
+ for i in {1..9}
do
# - Obtain partition location to wipe
@@ -751,12 +655,8 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
G_RUN_CMD dd if=/dev/zero of=/dev/${aDRIVE_SOURCE_DEVICE[$INDEX_DRIVE_BEING_EDITED]} bs=4K count=1337 #Block device wipe
# - Create partition table type
- local parition_table_type='msdos'
- if (( $FORMAT_GPT )); then
-
- parition_table_type='gpt'
-
- fi
+ local parition_table_type='gpt'
+ (( $FORMAT_GPT )) || parition_table_type='msdos'
G_DIETPI-NOTIFY 2 "Creating partition table, with target type: $parition_table_type"
@@ -764,7 +664,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
G_RUN_CMD parted -a optimal /dev/${aDRIVE_SOURCE_DEVICE[$INDEX_DRIVE_BEING_EDITED]} mkpart primary 0% 100%
partprobe /dev/${aDRIVE_SOURCE_DEVICE[$INDEX_DRIVE_BEING_EDITED]}
- sleep 1 # due to systemD automount, wait for it.
+ sleep 1 # due to systemd automount, wait for it.
umount ${aDRIVE_MOUNT_SOURCE[$INDEX_DRIVE_BEING_EDITED]}
# - Generate new aDRIVE_MOUNT_SOURCE location to use
@@ -885,11 +785,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
# Add new rootfs entry
local dev_entry="UUID=${aDRIVE_UUID[$INDEX_DRIVE_BEING_EDITED]}"
- if (( $G_HW_MODEL < 10 )); then
-
- dev_entry="PARTUUID=${aDRIVE_PART_UUID[$INDEX_DRIVE_BEING_EDITED]}"
-
- fi
+ (( $G_HW_MODEL < 10 )) && dev_entry="PARTUUID=${aDRIVE_PART_UUID[$INDEX_DRIVE_BEING_EDITED]}"
sed -i "\@[[:space:]]/[[:space:]]auto@c $dev_entry / auto defaults,noatime 0 1" /etc/fstab
# - Disable Swap
@@ -915,25 +811,21 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
if (( $G_HW_MODEL < 10 )); then
# find current root= and replace
- local rootfs_current=$(awk '{for(i=1;i<=NF;i++) {print $i} }' /boot/cmdline.txt | grep -m1 'root=')
+ local rootfs_current=$(mawk '{for(i=1;i<=NF;i++) {print $i} }' /boot/cmdline.txt | grep -m1 'root=')
sed -i "s#$rootfs_current#root=PARTUUID=${aDRIVE_PART_UUID[$INDEX_DRIVE_BEING_EDITED]}#g" /boot/cmdline.txt
# Add root delay
- if ! grep -qi '[[:space:]]rootdelay=' /boot/cmdline.txt; then
-
- sed -i "s#console=tty1#console=tty1 rootdelay=10#g" /boot/cmdline.txt
-
- fi
+ grep -qi '[[:space:]]rootdelay=' /boot/cmdline.txt || sed -i "s#console=tty1#console=tty1 rootdelay=10#g" /boot/cmdline.txt
# set FS type
- local rootfstype_current=$(awk '{for(i=1;i<=NF;i++) {print $i} }' /boot/cmdline.txt | grep -m1 'rootfstype=')
+ local rootfstype_current=$(mawk '{for(i=1;i<=NF;i++) {print $i} }' /boot/cmdline.txt | grep -m1 'rootfstype=')
sed -i "s#$rootfstype_current#rootfstype=${aDRIVE_FSTYPE[$INDEX_DRIVE_BEING_EDITED]}#g" /boot/cmdline.txt
#C1/C2/XU4 | /DietPi/boot.ini
elif (( $G_HW_MODEL == 10 || $G_HW_MODEL == 11 || $G_HW_MODEL == 12 )); then
# find current root= to replace
- local rootfs_current=$(awk '{for(i=1;i<=NF;i++) {print $i} }' /DietPi/boot.ini | grep -m1 'root=' | sed 's/\"//')
+ local rootfs_current=$(mawk '{for(i=1;i<=NF;i++) {print $i} }' /DietPi/boot.ini | grep -m1 'root=' | sed 's/\"//')
sed -i "s#$rootfs_current#root=UUID=${aDRIVE_UUID[$INDEX_DRIVE_BEING_EDITED]}#g" /DietPi/boot.ini
fi
@@ -963,11 +855,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
fi
- if (( $exit_status )); then
-
- G_WHIP_MSG "Failed to apply:\n\nDue to:\n - $message_result"
-
- fi
+ (( $exit_status )) && G_WHIP_MSG "Failed to apply:\n\nDue to:\n - $message_result"
}
@@ -981,12 +869,12 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
# - Create a nice category list, to match items to their block device (eg: mmcblk0)
local acategory_list=()
- for ((i=0; i<${#aDRIVE_MOUNT_SOURCE[@]}; i++))
+ for i in ${!aDRIVE_MOUNT_SOURCE[@]}
do
local new_cat=1
- for ((j=0; j<${#acategory_list[@]}; j++))
+ for j in ${!acategory_list[@]}
do
if [[ ${aDRIVE_SOURCE_DEVICE[$i]} == ${acategory_list[$j]} ]]; then
@@ -999,33 +887,25 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
done
# - add
- if (( $new_cat )); then
-
- acategory_list+=( ${aDRIVE_SOURCE_DEVICE[$i]} )
-
- fi
+ (( $new_cat )) && acategory_list+=( ${aDRIVE_SOURCE_DEVICE[$i]} )
done
#List all available drives, if no drive found, list info for user.
local drive_available=0
- for ((i=0; i<${#acategory_list[@]}; i++))
+ for i in ${!acategory_list[@]}
do
drive_available=1
G_WHIP_MENU_ARRAY+=('' "●─ ${acategory_list[$i]} ")
- for ((j=0; j<${#aDRIVE_MOUNT_SOURCE[@]}; j++))
+ for j in ${!aDRIVE_MOUNT_SOURCE[@]}
do
if [[ ${aDRIVE_SOURCE_DEVICE[$j]} == ${acategory_list[$i]} ]]; then
local string_fstype=${aDRIVE_FSTYPE[$j]}
- if (( ${aDRIVE_ISNETWORKED[$j]} )); then
-
- string_fstype='Net'
-
- fi
+ (( ${aDRIVE_ISNETWORKED[$j]} )) && string_fstype='Net'
#Drive is fully mounted:
if (( ${aDRIVE_ISMOUNTED[$j]} )); then
@@ -1074,28 +954,23 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
G_WHIP_MENU_ARRAY+=('Add network drive' ': Select to mount networked drives')
- if (( ! $drive_available )); then
+ if (( $drive_available )); then
- G_WHIP_MENU_ARRAY+=('Refresh' ': No drives found. Insert a drive and select this option')
+ G_WHIP_MENU_ARRAY+=('Refresh' ': Scan for recently added/removed drives')
else
- G_WHIP_MENU_ARRAY+=('Refresh' ': Scan for recently added/removed drives')
+ G_WHIP_MENU_ARRAY+=('Refresh' ': No drives found. Insert a drive and select this option')
fi
# - User data
local userdata_location_text="RootFS ($FP_USERDATA_CURRENT)"
- if [[ $FP_USERDATA_CURRENT != $G_FP_DIETPI_USERDATA ]]; then
-
- userdata_location_text="$FP_USERDATA_CURRENT"
-
- fi
+ [[ $FP_USERDATA_CURRENT == $G_FP_DIETPI_USERDATA ]] || userdata_location_text="$FP_USERDATA_CURRENT"
G_WHIP_DEFAULT_ITEM="$MENU_LASTITEM"
G_WHIP_BUTTON_CANCEL_TEXT='Exit'
- G_WHIP_MENU "Please select a drive to see available options.\n - User data location: $userdata_location_text"
- if (( ! $? )); then
+ if G_WHIP_MENU "Please select a drive to see available options.\n - User data location: $userdata_location_text"; then
MENU_LASTITEM="$G_WHIP_RETURNED_VALUE"
@@ -1104,7 +979,6 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
Init_Drives_and_Refresh
-
elif [[ $G_WHIP_RETURNED_VALUE == 'Add network drive' ]]; then
TARGETMENUID=3
@@ -1116,7 +990,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
G_WHIP_MENU_ARRAY=('0' ': Disabled')
local time_info=0
- for (( i=1; i<=240; i++ ))
+ for i in {1..240}
do
time_info=$(( $i * 5 ))
@@ -1125,7 +999,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
done
- for (( i=241; i<=251; i++ ))
+ for i in {241..251}
do
time_info=$(( ( $i - 240 ) * 30 ))
@@ -1135,11 +1009,13 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
done
G_WHIP_DEFAULT_ITEM=241
- G_WHIP_MENU "Please select a idle duration of time, before each drive is powered down:\n - This will be applied to all drives on the system\n - Not all drives support the feature of 'hdparm' and visa versa. End results may vary.\n - You can check status with 'hdparm -C /dev/sd*'"
- if (( $? == 0 )); then
+ if G_WHIP_MENU "Please select a idle duration of time, before each drive is powered down:
+ - This will be applied to all drives on the system
+ - Not all drives support the feature of 'hdparm' and visa versa. End results may vary.
+ - You can check status with 'hdparm -C /dev/sd*'"; then
> /etc/hdparm.conf
- for ((i=0; i<${#aDRIVE_MOUNT_SOURCE[@]}; i++))
+ for i in ${!aDRIVE_MOUNT_SOURCE[@]}
do
if (( ! ${aDRIVE_ISNETWORKED[$i]} )) && ! grep -q "^/dev/${aDRIVE_SOURCE_DEVICE[$i]}$" /etc/hdparm.conf; then
@@ -1325,12 +1201,12 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
local reserved_blocks_percent_current=0
local fp_temp='.dietpi-drive_manager_dumpe2fs'
dumpe2fs -h "${aDRIVE_MOUNT_SOURCE[$INDEX_DRIVE_BEING_EDITED]}" > $fp_temp
- local block_count="$(grep -m1 '^Block count:' $fp_temp | awk '{print $3}')"
- local reserved_block_count="$(grep -m1 '^Reserved block count:' $fp_temp | awk '{print $4}')"
+ local block_count=$(mawk '/^Block count:/ {print $3;exit}' $fp_temp)
+ local reserved_block_count=$(mawk '/^Reserved block count:/ {print $4;exit}' $fp_temp)
rm $fp_temp
- reserved_blocks_percent_current="$(bc -l <<< "scale=3;(100*$reserved_block_count)/$block_count")"
+ reserved_blocks_percent_current=$(bc -l <<< "scale=3;(100*$reserved_block_count)/$block_count")
# Correct rounding to final scale:
- reserved_blocks_percent_current="$(bc -l <<< "scale=2;(($reserved_blocks_percent_current*100)+0.5)/100" | sed 's/^\./0\./' | sed '/.0$/s/0$//' | sed 's/\.0$//')"
+ reserved_blocks_percent_current=$(bc -l <<< "scale=2;(($reserved_blocks_percent_current*100)+0.5)/100" | sed 's/^\./0\./' | sed '/.0$/s/0$//' | sed 's/\.0$//')
G_WHIP_MENU_ARRAY+=('Reserved blocks' ": [$reserved_blocks_percent_current%] | Adjust percentage of reserved blocks on this drive")
fi
@@ -1350,21 +1226,14 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
if ! (( ${aDRIVE_ISROM[$INDEX_DRIVE_BEING_EDITED]} || ${aDRIVE_ISNETWORKED[$INDEX_DRIVE_BEING_EDITED]} )); then
- if (( ! ${aDRIVE_ISREADONLY_CURRENTLY[$INDEX_DRIVE_BEING_EDITED]} )); then
+ # - fsck
+ G_WHIP_MENU_ARRAY+=('Check & Repair' ': Check and optionally repair filesystem')
- # - Disable check&repair for /boot /rootfs
- if [[ ${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]} != '/' && ${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]} != '/boot' ]]; then
+ # - Resize
+ if (( ! ${aDRIVE_ISREADONLY_CURRENTLY[$INDEX_DRIVE_BEING_EDITED]} )) &&
+ [[ ${aDRIVE_FSTYPE[$INDEX_DRIVE_BEING_EDITED]} == 'ext4' ]]; then
- G_WHIP_MENU_ARRAY+=('Check & Repair' ': Check and optionally repair filesystem')
-
- fi
-
- # - Resize
- if [[ ${aDRIVE_FSTYPE[$INDEX_DRIVE_BEING_EDITED]} == 'ext4' ]]; then
-
- G_WHIP_MENU_ARRAY+=('Resize' ': Maximize the available filesystem size')
-
- fi
+ G_WHIP_MENU_ARRAY+=('Resize' ': Maximize the available filesystem size')
fi
@@ -1388,11 +1257,10 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
fi
G_WHIP_BUTTON_CANCEL_TEXT='Back'
- G_WHIP_DEFAULT_ITEM="$MENU_LASTITEM"
- G_WHIP_MENU "$whiptail_desc"
- if (( ! $? )); then
+ G_WHIP_DEFAULT_ITEM=$MENU_LASTITEM
+ if G_WHIP_MENU "$whiptail_desc"; then
- MENU_LASTITEM="$G_WHIP_RETURNED_VALUE"
+ MENU_LASTITEM=$G_WHIP_RETURNED_VALUE
if [[ $G_WHIP_RETURNED_VALUE == 'Mount' ]]; then
@@ -1413,8 +1281,9 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
if [[ $G_WHIP_RETURNED_VALUE == 'Remove' ]]; then
- G_WHIP_YESNO "Do you wish to unmount and remove the following networked drive from this system?\n - ${aDRIVE_MOUNT_SOURCE[$INDEX_DRIVE_BEING_EDITED]} > ${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]}\n\nNB: You can add additional network shares at a later date through the 'dietpi-drive_manager' main menu."
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Do you wish to unmount and remove the following networked drive from this system?
+ - ${aDRIVE_MOUNT_SOURCE[$INDEX_DRIVE_BEING_EDITED]} > ${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]}
+\nNB: You can add additional network shares at a later date through the 'dietpi-drive_manager' main menu."; then
Unmount_Drive ${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]}
TARGETMENUID=0
@@ -1441,17 +1310,14 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
else
G_WHIP_DEFAULT_ITEM=$swapfile_size
- G_WHIP_INPUTBOX "Please input a new value for swapfile size (MB):\n\nSwapfile has a swapiness setting of 1, and, is used only to prevent out of memory errors.\n\n - Recommended value = 1 (auto)\n - 0 = Disable swapfile\n - 1 = Auto size swapfile (2GB - RAM = size)\n - 2 - $max = Manual size"
- if (( $? == 0 )); then
+ if G_WHIP_INPUTBOX "Please input a new value for swapfile size (MB):
+\nSwapfile has a swapiness setting of 1, and, is used only to prevent out of memory errors.
+\n - Recommended value = 1 (auto)\n - 0 = Disable swapfile\n - 1 = Auto size swapfile (2GB - RAM = size)\n - 2 - $max = Manual size"; then
if G_CHECK_VALIDINT $G_WHIP_RETURNED_VALUE $min $max; then
- local fp_target_swapfile='/var/swap'
- if [[ ${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]} != '/' ]]; then
-
- fp_target_swapfile="${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]}/.swapfile"
-
- fi
+ local fp_target_swapfile="${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]}/.swapfile"
+ [[ ${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]} == '/' ]] && fp_target_swapfile='/var/swap'
/DietPi/dietpi/func/dietpi-set_dphys-swapfile $G_WHIP_RETURNED_VALUE "$fp_target_swapfile"
@@ -1463,10 +1329,10 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
elif [[ $G_WHIP_RETURNED_VALUE == 'Reserved blocks' ]]; then
- while true
+ while :
do
- G_WHIP_DEFAULT_ITEM="$reserved_blocks_percent_current"
+ G_WHIP_DEFAULT_ITEM=$reserved_blocks_percent_current
G_WHIP_INPUTBOX 'Ext4 formatted drives allow the reservation of drive space for the root user to assure system functionality, if filled by other users or processes, and to avoid fragmentation of large files.\n\nHowever, on modern drives, the default of 5% reserved blocks is often by orders of magnitude larger than necessary. You may want to reduce the percentage to an absolute reserved space of about 500 MiB, which should be enough, to enable root user starting and maintaining the system. Additionally, on non rootfs drives reserved blocks are not necessary at all.\n\nPlease enter the desired percentage of reserved blocks, e.g. "0.05" for 0.05% or "10" for 10%.\nNote: Only values between "0" and "50" are allowed.'
if (( $? )); then
@@ -1495,11 +1361,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
local fp_target_userdata_dir="${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]}"
# Assign location if under RootFS
- if [[ ${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]} == '/' ]]; then
-
- fp_target_userdata_dir='/mnt'
-
- fi
+ [[ ${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]} == '/' ]] && fp_target_userdata_dir='/mnt'
fp_target_userdata_dir+='/dietpi_userdata'
@@ -1554,10 +1416,13 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
else
- G_WHIP_YESNO "This process will move RootFS data to another location. This may increase filesystem performance when using a USB drive over SD card, however, there are some limitations:\n\n - The SD/EMMC card is still required for the boot process\n\nNB: As this feature is still in testing, we recommend you use this feature on a fresh installation only.\n\nDo you wish to continue?"
- if (( ! $? )); then
+ if G_WHIP_YESNO "This process will move RootFS data to another location. This may increase filesystem performance when using a USB drive over SD card, however, there are some limitations:
+\n - The SD/EMMC card is still required for the boot process
+\nNB: As this feature is still in testing, we recommend you use this feature on a fresh installation only.\n\nDo you wish to continue?"; then
- G_WHIP_MSG 'On the next screen, you will be asked to format the target partition.\n\nPlease see the following recommendations for RootFS target filesystem type:\n\n - Odroid\nRootFS transfer supports ONLY EXT4 format\n\n - RPi\nRootFS transfer supports EXT4, BTRFS and F2FS'
+ G_WHIP_MSG 'On the next screen, you will be asked to format the target partition.
+\nPlease see the following recommendations for RootFS target filesystem type:
+\n - Odroid\nRootFS transfer supports ONLY EXT4 format\n\n - RPi\nRootFS transfer supports EXT4, BTRFS and F2FS'
#NB: We dont enter main loop in this func
TARGETMENUID=2
@@ -1568,11 +1433,7 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
done
- if (( $FORMAT_COMPLETED )); then
-
- RootFS_Move
-
- fi
+ (( $FORMAT_COMPLETED )) && RootFS_Move
fi
@@ -1597,17 +1458,27 @@ aDRIVE_ISPARTITIONTABLE ${aDRIVE_ISPARTITIONTABLE[$i]}
elif [[ $G_WHIP_RETURNED_VALUE == 'Check & Repair' ]]; then
- if (( ${aDRIVE_ISMOUNTED[$INDEX_DRIVE_BEING_EDITED]} )); then
-
- G_WHIP_YESNO 'For safe check and repair, the drive needs to be unmounted.\n\nDo you want to continue with the drive being unmounted automatically?'
- (( $? )) && TARGETMENUID=1 && return
+ if [[ ${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]} == '/' ]]; then
- # - disable swap
- if (( $partition_contains_swapfile )); then
+ if G_WHIP_YESNO 'The root file system can only be checked on reboot.
+\nDo you want to force a file system check of root partition on next reboot?
+\nNB: Logs can be found after reboot either via "journalctl -t systemd-fsck" or "cat /run/initramfs/fsck.log"'; then
- G_RUN_CMD swapoff -a
+ > /forcefsck
+ G_WHIP_YESNO 'Do you want to reboot now?' && reboot
fi
+ return
+
+ fi
+
+ if (( ${aDRIVE_ISMOUNTED[$INDEX_DRIVE_BEING_EDITED]} )); then
+
+ G_WHIP_YESNO 'For safe check and repair, the drive needs to be unmounted.
+\nDo you want to continue with the drive being unmounted automatically?' || { TARGETMENUID=1 && return; }
+
+ # - disable swap
+ (( $partition_contains_swapfile )) && G_RUN_CMD swapoff -a
# - Unmount drive
G_RUN_CMD umount ${aDRIVE_MOUNT_SOURCE[$INDEX_DRIVE_BEING_EDITED]}
@@ -1688,12 +1559,8 @@ NB:
# - Remount all drives
G_RUN_CMD mount -a
- # - re-enable swap
- if (( $partition_contains_swapfile )); then
-
- G_RUN_CMD swapon -a
-
- fi
+ # - Re-enable swap
+ (( $partition_contains_swapfile )) && G_RUN_CMD swapon -a
fi
@@ -1717,19 +1584,11 @@ NB:
FORMAT_COMPLETED=0
- local partition_table_text='MBR'
- if (( $FORMAT_GPT )); then
-
- partition_table_text='GPT'
-
- fi
+ local partition_table_text='GPT'
+ (( $FORMAT_GPT )) || partition_table_text='MBR'
local format_mode_text='Drive'
- if (( $FORMAT_MODE == 1 )); then
-
- format_mode_text='Partition'
-
- fi
+ (( $FORMAT_MODE == 1 )) && format_mode_text='Partition'
local format_type_text='EXT4'
if (( $FORMAT_FILESYSTEM_TYPE == 1 )); then
@@ -1772,19 +1631,14 @@ NB:
fi
- if (( $FORMAT_MODE == 0 )); then
-
- G_WHIP_MENU_ARRAY+=('Partition Type' ": $partition_table_text")
-
- fi
+ (( $FORMAT_MODE == 0 )) && G_WHIP_MENU_ARRAY+=('Partition Type' ": $partition_table_text")
G_WHIP_MENU_ARRAY+=('Filesystem Type' ": $format_type_text")
G_WHIP_MENU_ARRAY+=('Format' ': Start the format process with selected options')
G_WHIP_DEFAULT_ITEM="$MENU_LASTITEM"
G_WHIP_BUTTON_CANCEL_TEXT='Back'
- G_WHIP_MENU 'Please select formatting options:'
- if (( ! $? )); then
+ if G_WHIP_MENU 'Please select formatting options:'; then
MENU_LASTITEM="$G_WHIP_RETURNED_VALUE"
@@ -1811,15 +1665,11 @@ NB:
)
- G_WHIP_MENU "Please select a formatting mode:\n\n - Formatting the drive will DELETE all data on the DRIVE.\n - Formatting the partition, will DELETE all data on the current PARTITION only.\n\nNB: If you are planning to dedicate the drive to this system, it is recommended to format the whole drive where possible, this will ensure full drive capacity is available for use."
+ G_WHIP_MENU 'Please select a formatting mode:\n\n - Formatting the drive will DELETE all data on the DRIVE.\n - Formatting the partition, will DELETE all data on the current PARTITION only.\n\nNB: If you are planning to dedicate the drive to this system, it is recommended to format the whole drive where possible, this will ensure full drive capacity is available for use.'
if (( ! $? )); then
FORMAT_MODE=0
- if [[ ${G_WHIP_RETURNED_VALUE,,} == 'partition' ]]; then
-
- FORMAT_MODE=1
-
- fi
+ [[ ${G_WHIP_RETURNED_VALUE,,} == 'partition' ]] && FORMAT_MODE=1
fi
@@ -1896,7 +1746,7 @@ NB:
Mount_Samba(){
- rm /mnt/samba/readme.txt &> /dev/null
+ [[ -f /mnt/samba/readme.txt ]] && rm /mnt/samba/readme.txt
local samba_clientname=''
local samba_clientshare=''
@@ -1907,46 +1757,26 @@ NB:
while :
do
- G_WHIP_DEFAULT_ITEM="$samba_clientname"
- G_WHIP_INPUTBOX 'Please enter the fileservers IP address\n - eg: 192.168.0.2'
- if (( $? )); then
-
- break
-
- fi
+ G_WHIP_DEFAULT_ITEM=$samba_clientname
+ G_WHIP_INPUTBOX 'Please enter the fileservers IP address\n - eg: 192.168.0.2' || break
samba_clientname="$G_WHIP_RETURNED_VALUE"
- G_WHIP_DEFAULT_ITEM="$samba_clientshare"
- G_WHIP_INPUTBOX 'Please enter the fileservers shared folder name\n - eg: MySharedFolder'
- if (( $? )); then
-
- break
-
- fi
+ G_WHIP_DEFAULT_ITEM=$samba_clientshare
+ G_WHIP_INPUTBOX 'Please enter the fileservers shared folder name\n - eg: MySharedFolder' || break
# NB: Convert spaces into '\040': https://github.com/Fourdee/DietPi/issues/1201#issuecomment-339720271
samba_clientshare="${G_WHIP_RETURNED_VALUE//[[:space:]]/\\\\040}"
- G_WHIP_DEFAULT_ITEM="$samba_clientuser"
- G_WHIP_INPUTBOX 'Please enter the fileservers username\n - eg: JoeBloggs'
- if (( $? )); then
-
- break
+ G_WHIP_DEFAULT_ITEM=$samba_clientuser
+ G_WHIP_INPUTBOX 'Please enter the fileservers username\n - eg: JoeBloggs' || break
+ samba_clientuser=$G_WHIP_RETURNED_VALUE
- fi
- samba_clientuser="$G_WHIP_RETURNED_VALUE"
-
- G_WHIP_DEFAULT_ITEM="$samba_clientpassword"
- G_WHIP_PASSWORD 'Please enter the fileservers password\n - eg: LetMeIn'
- samba_clientpassword="$result"
+ G_WHIP_DEFAULT_ITEM=$samba_clientpassword
+ G_WHIP_PASSWORD 'Please enter the fileservers password\n - eg: LetMeIn' || break
+ samba_clientpassword=$result
unset result
- G_WHIP_DEFAULT_ITEM="$samba_fp_mount_target"
- G_WHIP_INPUTBOX 'Please enter a unique folder name for the mount location (eg: samba). This will be placed in /mnt/'
- if (( $? )); then
-
- break
-
- fi
+ G_WHIP_DEFAULT_ITEM=$samba_fp_mount_target
+ G_WHIP_INPUTBOX 'Please enter a unique folder name for the mount location (eg: samba). This will be placed in /mnt/' || break
samba_fp_mount_target="/mnt/${G_WHIP_RETURNED_VALUE//[[:space:]]/_}"
# - Unmount if connected
@@ -1968,7 +1798,7 @@ NB:
)
- for ((i=0; i<${#acifs_versions[@]}; i++))
+ for i in ${!acifs_versions[@]}
do
G_DIETPI-NOTIFY 2 "Attempting to mount with CIFS version: ${acifs_versions[$i]}"
mount -t cifs -o username="$samba_clientuser",password="$samba_clientpassword",uid=dietpi,gid=dietpi,file_mode=0770,dir_mode=0770,vers=${acifs_versions[$i]} //"$samba_clientname"/"$samba_clientshare" "$samba_fp_mount_target" &> /dev/null
@@ -1986,8 +1816,8 @@ NB:
fi
- # - Last item already failed, re-run for user info
- if (( $i == ( ${#acifs_versions[@]} - 1 ) )); then
+ # - Last item already failed, rerun for user info
+ if (( $i == ${#acifs_versions[@]} - 1 )); then
# - Run mount again, allow user to see error
G_ERROR_HANDLER_INFO_ONLY=1 G_RUN_CMD mount -t cifs -o username="$samba_clientuser",password="$samba_clientpassword",uid=dietpi,gid=dietpi,file_mode=0770,dir_mode=0770,vers=${acifs_versions[$i]} //"$samba_clientname"/"$samba_clientshare" "$samba_fp_mount_target"
@@ -2021,28 +1851,19 @@ NB:
do
G_WHIP_DEFAULT_ITEM="$nfs_server_ip"
- G_WHIP_INPUTBOX 'Please enter the NFS servers IP address (eg: 192.168.0.2).'
- if (( $? )); then
-
- break
-
- fi
+ G_WHIP_INPUTBOX 'Please enter the NFS servers IP address (eg: 192.168.0.2).' || break
nfs_server_ip="$G_WHIP_RETURNED_VALUE"
# - Show current chosen mount target without leading "/mnt/"
- G_WHIP_DEFAULT_ITEM="${nfs_fp_mount_target#/mnt/}"
- G_WHIP_INPUTBOX 'Please enter a unique folder name for the mount location (eg: nfs_client). This will be placed in /mnt/\n\nNB: Please avoid white spaces or special characters for compatibility reasons.'
- if (( $? )); then
-
- break
-
- fi
+ G_WHIP_DEFAULT_ITEM=${nfs_fp_mount_target#/mnt/}
+ G_WHIP_INPUTBOX 'Please enter a unique folder name for the mount location (eg: nfs_client). This will be placed in /mnt/
+\nNB: Please avoid white spaces or special characters for compatibility reasons.' || break
# - Remove leading "/mnt/", in case entered by user
- nfs_fp_mount_target="${G_WHIP_RETURNED_VALUE#/mnt/}"
+ nfs_fp_mount_target=${G_WHIP_RETURNED_VALUE#/mnt/}
# - Remove leading slash and (re-)add "/mnt/" for full mount target path
nfs_fp_mount_target="/mnt/${nfs_fp_mount_target#/}"
# - Replace all spaces (+ tabs etc) with "_"
- nfs_fp_mount_target="${nfs_fp_mount_target//[[:space:]]/_}"
+ nfs_fp_mount_target=${nfs_fp_mount_target//[[:space:]]/_}
# - Unmount if connected
umount $nfs_fp_mount_target &> /dev/null
@@ -2052,8 +1873,7 @@ NB:
#Mount now
mkdir -p $nfs_fp_mount_target
- mount -vt nfs -o port=2049 "$nfs_server_ip":/ $nfs_fp_mount_target &> $fp_tmp
- if (( ! $? )); then
+ if mount -vt nfs -o port=2049 "$nfs_server_ip":/ $nfs_fp_mount_target &> $fp_tmp; then
rm $fp_tmp
@@ -2073,16 +1893,10 @@ NB:
G_WHIP_DEFAULT_ITEM="$nfs_fp_server_share"
G_WHIP_INPUTBOX 'Your NFS server appears to support NFSv3 only. Mounting NFSv3 shares requires the shares path server side to be entered.
-\nPlease enter the absolute path to the share on the NFS server (eg: /mnt/nfs_share).'
- if (( $? )); then
-
- break
-
- fi
+\nPlease enter the absolute path to the share on the NFS server (eg: /mnt/nfs_share).' || break
nfs_fp_server_share="$G_WHIP_RETURNED_VALUE"
- mount -vt nfs -o port=2049 "$nfs_server_ip":"$nfs_fp_server_share" $nfs_fp_mount_target &> $fp_tmp
- if (( ! $? )); then
+ if mount -vt nfs -o port=2049 "$nfs_server_ip":"$nfs_fp_server_share" $nfs_fp_mount_target &> $fp_tmp; then
rm $fp_tmp
@@ -2090,7 +1904,7 @@ NB:
sed -i "\#[[:space:]]$nfs_fp_mount_target[[:space:]]#d" /etc/fstab
echo "$nfs_server_ip:$nfs_fp_server_share $nfs_fp_mount_target nfs auto,_netdev,nofail 0 0" >> /etc/fstab
- DRIVE_TARGET_BEING_EDITED="$nfs_fp_mount_target"
+ DRIVE_TARGET_BEING_EDITED=$nfs_fp_mount_target
TARGETMENUID=1
G_WHIP_MSG "Mount completed. The new mount can be accessed via:\n - $nfs_fp_mount_target"
@@ -2107,14 +1921,13 @@ NB:
Do you want to retry?
Error log:
-$(<$fp_tmp)"
- (( $? )) && break
+$(<$fp_tmp)" || break
fi
done
- rm $fp_tmp &> /dev/null
+ [[ -f $fp_tmp ]] && rm $fp_tmp
Rm_Empty_Dir $nfs_fp_mount_target
}
@@ -2130,8 +1943,7 @@ $(<$fp_tmp)"
)
- G_WHIP_MENU 'Please select a mount location to use:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a mount location to use:'; then
if [[ $G_WHIP_RETURNED_VALUE == 'Samba' ]]; then
@@ -2163,16 +1975,15 @@ $(<$fp_tmp)"
while read line
do
- G_WHIP_MENU_ARRAY+=("$(awk '{print $6}' <<< $line)" ": $(awk '{print $1}' <<< $line) | size: $(awk '{print $2}' <<< $line) | available: $(awk '{print $4}' <<< $line)")
+ G_WHIP_MENU_ARRAY+=("$(mawk '{print $6}' <<< $line)" ": $(mawk '{print $1" | size: "$2" | available: "$4}' <<< $line)")
done < dietpi-drive_manager_selmnt
rm dietpi-drive_manager_selmnt
- G_WHIP_DEFAULT_ITEM="$MENU_LASTITEM"
- G_WHIP_MENU 'Please select a mount location to use:'
- if (( ! $? )); then
+ G_WHIP_DEFAULT_ITEM=$MENU_LASTITEM
+ if G_WHIP_MENU 'Please select a mount location to use:'; then
- local drive_manager_selection="$G_WHIP_RETURNED_VALUE"
+ local drive_manager_selection=$G_WHIP_RETURNED_VALUE
G_DIETPI-NOTIFY 0 "Drive mount selected: $drive_manager_selection"
echo "$drive_manager_selection" > "$FP_DRIVE_MANAGER_SELECTION"
@@ -2184,8 +1995,7 @@ $(<$fp_tmp)"
Menu_Exit(){
G_WHIP_SIZE_X_MAX=50
- G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"
- if (( ! $? )); then
+ if G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"; then
#exit
TARGETMENUID=-1
@@ -2202,18 +2012,10 @@ $(<$fp_tmp)"
#/////////////////////////////////////////////////////////////////////////////////////
# Main Loop
#/////////////////////////////////////////////////////////////////////////////////////
- if (( $INPUT >= 1 )); then
-
- SERVICE_CONTROL=0
-
- fi
+ (( $INPUT >= 1 )) && SERVICE_CONTROL=0
#-----------------------------------------------------------------------------------
# Stop Services
- if (( $SERVICE_CONTROL )); then
-
- /DietPi/dietpi/dietpi-services stop
-
- fi
+ (( $SERVICE_CONTROL )) && /DietPi/dietpi/dietpi-services stop
#-----------------------------------------------------------------------------------
#Generate /etc/fstab based on current drive mounts
if (( $INPUT == 4 )); then
@@ -2258,11 +2060,7 @@ $(<$fp_tmp)"
fi
#-----------------------------------------------------------------------------------
# Start Services
- if (( $SERVICE_CONTROL )); then
-
- /DietPi/dietpi/dietpi-services start
-
- fi
+ (( $SERVICE_CONTROL )) && /DietPi/dietpi/dietpi-services start
#-----------------------------------------------------------------------------------
exit $EXIT_CODE
#-----------------------------------------------------------------------------------
diff --git a/dietpi/dietpi-explorer b/dietpi/dietpi-explorer
index aac007de06..25c7bdb730 100644
--- a/dietpi/dietpi-explorer
+++ b/dietpi/dietpi-explorer
@@ -18,20 +18,17 @@
#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
- G_CHECK_ROOT_USER
G_PROGRAM_NAME='DietPi-Explorer'
+ G_CHECK_ROOT_USER
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
INPUT=0
- if disable_error=1 G_CHECK_VALIDINT $1; then
-
- INPUT=$1
-
- fi
+ disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1
CURRENT_DIRECTORY=''
- TARGET_FP=''
+ TARGET_FP='/home'
+ [[ $2 ]] && TARGET_FP="$2"
CP_MODE=0 #0=CP 1=MV
CP_SOURCE=''
@@ -39,7 +36,7 @@
Process_Copy_Move(){
- if [[ -n $CP_TARGET ]]; then
+ if [[ $CP_TARGET ]]; then
if (( $CP_MODE == 0 )); then
@@ -93,7 +90,7 @@
G_WHIP_MENU_ARRAY+=('Copy' '')
G_WHIP_MENU_ARRAY+=('Move' '')
- if [[ -n $CP_SOURCE && -d $CURRENT_DIRECTORY/$TARGET_FP && $CP_SOURCE != $CURRENT_DIRECTORY/$TARGET_FP ]]; then
+ if [[ $CP_SOURCE && -d $CURRENT_DIRECTORY/$TARGET_FP && $CP_SOURCE != $CURRENT_DIRECTORY/$TARGET_FP ]]; then
if (( $CP_MODE == 0 )); then
@@ -123,25 +120,24 @@
local chmod_current=''
if [[ -d $CURRENT_DIRECTORY/$TARGET_FP ]]; then
- permission_current_user=$(ls -lha $CURRENT_DIRECTORY | grep -m1 $TARGET_FP | awk '{print $3}')
- permission_current_group=$(ls -lha $CURRENT_DIRECTORY | grep -m1 $TARGET_FP | awk '{print $4}')
- permission_current_bit=$(ls -lha $CURRENT_DIRECTORY | grep -m1 $TARGET_FP | awk '{print $1}')
+ permission_current_user=$(ls -lha $CURRENT_DIRECTORY | mawk -v pat="$TARGET_FP" '$0~pat {print $3;exit}')
+ permission_current_group=$(ls -lha $CURRENT_DIRECTORY | mawk -v pat="$TARGET_FP" '$0~pat {print $4;exit}')
+ permission_current_bit=$(ls -lha $CURRENT_DIRECTORY | mawk -v pat="$TARGET_FP" '$0~pat {print $1;exit}')
chmod_current=$(stat --format '%a' $CURRENT_DIRECTORY/$TARGET_FP)
else
- permission_current_user=$(ls -lha $CURRENT_DIRECTORY/$TARGET_FP | awk '{print $3}')
- permission_current_group=$(ls -lha $CURRENT_DIRECTORY/$TARGET_FP | awk '{print $4}')
- permission_current_bit=$(ls -lha $CURRENT_DIRECTORY/$TARGET_FP | awk '{print $1}')
+ permission_current_user=$(ls -lha $CURRENT_DIRECTORY/$TARGET_FP | mawk '{print $3}')
+ permission_current_group=$(ls -lha $CURRENT_DIRECTORY/$TARGET_FP | mawk '{print $4}')
+ permission_current_bit=$(ls -lha $CURRENT_DIRECTORY/$TARGET_FP | mawk '{print $1}')
chmod_current=$(stat --format '%a' $CURRENT_DIRECTORY/$TARGET_FP)
fi
- G_WHIP_MENU "$target_type_info: $CURRENT_DIRECTORY/$TARGET_FP
+ if G_WHIP_MENU "$target_type_info: $CURRENT_DIRECTORY/$TARGET_FP
- Exec permissions : $permission_current_bit ($chmod_current)
- User/Group permissions : $permission_current_user:$permission_current_group
-"
- if (( $? == 0 )); then
+"; then
if [[ $G_WHIP_RETURNED_VALUE == 'Open' ]]; then
@@ -178,8 +174,7 @@
elif [[ $G_WHIP_RETURNED_VALUE == 'Rename' ]]; then
G_WHIP_DEFAULT_ITEM="$TARGET_FP"
- G_WHIP_INPUTBOX "Please enter a new name for '$TARGET_FP'"
- if (( $? == 0 )); then
+ if G_WHIP_INPUTBOX "Please enter a new name for '$TARGET_FP'"; then
G_ERROR_HANDLER_INFO_ONLY=1 G_RUN_CMD mv "$TARGET_FP" "$G_WHIP_RETURNED_VALUE"
@@ -187,8 +182,7 @@
elif [[ $G_WHIP_RETURNED_VALUE == 'Delete' ]]; then
- G_WHIP_YESNO "Delete $CURRENT_DIRECTORY/$TARGET_FP?"
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Delete $CURRENT_DIRECTORY/$TARGET_FP?"; then
G_ERROR_HANDLER_INFO_ONLY=1 G_RUN_CMD rm -R "$CURRENT_DIRECTORY/$TARGET_FP"
@@ -206,8 +200,7 @@
done <<< "$(getent passwd | cut -d: -f1 | sort)"
G_WHIP_DEFAULT_ITEM="$permission_current_user"
- G_WHIP_MENU 'Chown permissions:\n - Please select a User'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Chown permissions:\n - Please select a User'; then
local chown_user="$G_WHIP_RETURNED_VALUE"
@@ -221,8 +214,7 @@
done <<< "$(getent group | cut -d: -f1 | sort)"
G_WHIP_DEFAULT_ITEM="$permission_current_group"
- G_WHIP_MENU 'Chown permissions:\n - Please select a Group'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Chown permissions:\n - Please select a Group'; then
local chown_group="$G_WHIP_RETURNED_VALUE"
G_ERROR_HANDLER_INFO_ONLY=1 G_RUN_CMD chown -R $chown_user:$chown_group "$CURRENT_DIRECTORY/$TARGET_FP"
@@ -234,8 +226,7 @@
elif [[ $G_WHIP_RETURNED_VALUE == 'Chmod' ]]; then
G_WHIP_DEFAULT_ITEM="$chmod_current"
- G_WHIP_INPUTBOX 'Chmod permissions:\n - Please enter a value'
- if (( $? == 0 )); then
+ if G_WHIP_INPUTBOX 'Chmod permissions:\n - Please enter a value'; then
G_ERROR_HANDLER_INFO_ONLY=1 G_RUN_CMD chmod -R $G_WHIP_RETURNED_VALUE "$CURRENT_DIRECTORY/$TARGET_FP"
@@ -292,8 +283,7 @@
G_WHIP_BUTTON_CANCEL_TEXT='Exit'
G_WHIP_DEFAULT_ITEM="$TARGET_FP"
- G_WHIP_MENU "$CURRENT_DIRECTORY"
- if (( $? == 0 )); then
+ if G_WHIP_MENU "$CURRENT_DIRECTORY"; then
TARGET_FP="$G_WHIP_RETURNED_VALUE"
@@ -310,8 +300,7 @@
Menu_Exit(){
G_WHIP_SIZE_X_MAX=50
- G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"
- if (( ! $? )); then
+ if G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"; then
#exit
TARGETMENUID=-1
@@ -330,7 +319,7 @@
#/////////////////////////////////////////////////////////////////////////////////////
#Default to users home dir
- cd "$HOME"
+ cd "$TARGET_FP"
#Start Menu
while (( $TARGETMENUID > -1 ))
@@ -338,11 +327,7 @@
printf '\ec' # clear current terminal screen
- if (( $TARGETMENUID == 0 )); then
-
- Menu_Main
-
- fi
+ (( $TARGETMENUID == 0 )) && Menu_Main
done
diff --git a/dietpi/dietpi-launcher b/dietpi/dietpi-launcher
index 779398b83f..0ec206ff9d 100644
--- a/dietpi/dietpi-launcher
+++ b/dietpi/dietpi-launcher
@@ -41,7 +41,7 @@
G_WHIP_MENU_ARRAY+=('DietPi-AutoStart' ': Choose what software runs after boot.')
- if [[ -r '/DietPi/dietpi/.installed' ]] && grep -qi 'aSOFTWARE_INSTALL_STATE\[62\]=2' /DietPi/dietpi/.installed; then
+ if [[ -f '/DietPi/dietpi/.installed' ]] && grep -qi 'aSOFTWARE_INSTALL_STATE\[62\]=2' /DietPi/dietpi/.installed; then
G_WHIP_MENU_ARRAY+=('DietPi-CloudShell' ': Adjust update rate, scenes settings and more.')
@@ -61,20 +61,21 @@
G_WHIP_MENU_ARRAY+=('' '●─ Misc ')
G_WHIP_MENU_ARRAY+=('DietPi-CpuInfo' ': Displays CPU Temp, frequencies, type etc.')
G_WHIP_MENU_ARRAY+=('DietPi-LetsEncrypt' ': Frontend for Lets Encrypt, free SSL certs')
+ G_WHIP_MENU_ARRAY+=('DietPi-NordVPN' ': GUI to setup a NordVPN connection')
G_WHIP_MENU_ARRAY+=('DietPi-Survey' ': Join or leave our usage program, view upload file.')
G_WHIP_MENU_ARRAY+=('DietPi-BugReport' ': Found a bug? Let us know!')
G_WHIP_MENU_ARRAY+=('DietPi-MorseCode' ': Converts and outputs a text file to morsecode.')
- G_WHIP_DEFAULT_ITEM="$LAST_SELECTED_ITEM"
+ G_WHIP_DEFAULT_ITEM=$LAST_SELECTED_ITEM
G_WHIP_BUTTON_CANCEL_TEXT='Exit'
if G_WHIP_MENU 'Please select a program to run:'; then
if [[ $G_WHIP_RETURNED_VALUE ]]; then
- LAST_SELECTED_ITEM="$G_WHIP_RETURNED_VALUE"
+ LAST_SELECTED_ITEM=$G_WHIP_RETURNED_VALUE
- #convert to lowercase
- local command="${G_WHIP_RETURNED_VALUE,,}"
+ #Convert to lowercase
+ local command=${G_WHIP_RETURNED_VALUE,,}
#Run
if [[ -f /DietPi/dietpi/$command ]]; then
diff --git a/dietpi/dietpi-letsencrypt b/dietpi/dietpi-letsencrypt
index 8f12733828..db466a25bd 100644
--- a/dietpi/dietpi-letsencrypt
+++ b/dietpi/dietpi-letsencrypt
@@ -27,7 +27,7 @@
#Grab Input
INPUT=0
- disable_error=1 G_CHECK_VALIDINT $1 && INPUT=$1
+ disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1
#/////////////////////////////////////////////////////////////////////////////////////
#Globals
@@ -91,8 +91,8 @@
fi
if (( $exit_code )); then
- echo -e "[FAILED] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..." | tee "$FP_LOGFILE"
- (( ! $INPUT )) && G_WHIP_MSG "[FAILURE] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..."
+ echo "[FAILED] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..." | tee "$FP_LOGFILE"
+ (( $INPUT )) || G_WHIP_MSG "[FAILURE] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..."
return 1
fi
@@ -118,8 +118,8 @@
fi
if (( $exit_code )); then
- echo -e "[FAILED] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..." | tee "$FP_LOGFILE"
- (( ! $INPUT )) && G_WHIP_MSG "[FAILURE] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..."
+ echo "[FAILED] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..." | tee "$FP_LOGFILE"
+ (( $INPUT )) || G_WHIP_MSG "[FAILURE] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..."
return 1
fi
@@ -128,8 +128,8 @@
cat "$fp_cert_dir/privkey.pem" "$fp_cert_dir/cert.pem" > "$fp_cert_dir/combined.pem"
if [[ ! -f $fp_cert_dir/combined.pem ]]; then
- echo -e "[FAILED] $fp_cert_dir/combined.pem could not be created. Please check existence of privkey.pem and cert.pem within this folder, as result of CertBot execution. Aborting..." | tee "$FP_LOGFILE"
- (( ! $INPUT )) && G_WHIP_MSG "[FAILED] $fp_cert_dir/combined.pem could not be created. Please check existence of privkey.pem and cert.pem within this folder, as result of CertBot execution. Aborting..."
+ echo "[FAILED] $fp_cert_dir/combined.pem could not be created. Please check existence of privkey.pem and cert.pem within this folder, as result of CertBot execution. Aborting..." | tee "$FP_LOGFILE"
+ (( $INPUT )) || G_WHIP_MSG "[FAILED] $fp_cert_dir/combined.pem could not be created. Please check existence of privkey.pem and cert.pem within this folder, as result of CertBot execution. Aborting..."
return 1
fi
@@ -200,7 +200,7 @@ _EOF_
cat << _EOF_ > /etc/lighttpd/conf-available/99-dietpi-hsts.conf
\$HTTP["scheme"] == "https" {
- setenv.add-response-header = ( "Strict-Transport-Security" => "max-age=31536000; includeSubdomains; preload;" )
+ setenv.add-response-header = ( "Strict-Transport-Security" => "max-age=31536000; includeSubdomains;" )
}
_EOF_
lighttpd-enable-mod dietpi-hsts
@@ -244,12 +244,20 @@ _EOF_
fi
if (( $exit_code )); then
- echo -e "[FAILURE] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..." | tee "$FP_LOGFILE"
- (( ! $INPUT )) && G_WHIP_MSG "[FAILURE] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..."
+ echo "[FAILURE] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..." | tee "$FP_LOGFILE"
+ (( $INPUT )) || G_WHIP_MSG "[FAILURE] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..."
return 1
fi
+ #Apply HSTS header to ownCloud/Nextcloud config
+ if (( $LETSENCRYPT_HSTS )); then
+
+ [[ -f /etc/nginx/sites-dietpi/dietpi-owncloud.conf ]] && sed -i 's/#add_header Strict-Transport-Security/add_header Strict-Transport-Security/g' /etc/nginx/sites-dietpi/dietpi-owncloud.conf
+ [[ -f /etc/nginx/sites-dietpi/dietpi-nextcloud.conf ]] && sed -i 's/#add_header Strict-Transport-Security/add_header Strict-Transport-Security/g' /etc/nginx/sites-dietpi/dietpi-nextcloud.conf
+
+ fi
+
#------------------------------------------------------------------------------------------------------
#Minio
elif pgrep '[m]inio' &> /dev/null; then
@@ -271,8 +279,8 @@ _EOF_
fi
if (( $exit_code )); then
- echo -e "[FAILURE] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..." | tee "$FP_LOGFILE"
- (( ! $INPUT )) && G_WHIP_MSG "[FAILURE] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..."
+ echo "[FAILURE] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..." | tee "$FP_LOGFILE"
+ (( $INPUT )) || G_WHIP_MSG "[FAILURE] CertBot failed with error code ($exit_code), please check it's terminal output. Aborting..."
return 1
fi
@@ -333,12 +341,18 @@ _EOF_
fi
- echo -e '[ INFO ] HTTPS redirect and HSTS is not supported for Minio, thus will be ignored.' | tee "$FP_LOGFILE"
+ echo '[ INFO ] HTTPS redirect and HSTS is not supported for Minio, thus will be ignored.' | tee "$FP_LOGFILE"
else
- echo -e '[FAILURE] No compatible and/or active webserver was found. Aborting...' | tee "$FP_LOGFILE"
- (( ! $INPUT )) && G_WHIP_MSG '[FAILURE] No compatible and/or active webserver was found. Aborting...'
+ echo '[FAILURE] No compatible and/or active webserver was found. Aborting...' | tee "$FP_LOGFILE"
+ (( $INPUT )) || G_WHIP_YESNO '[FAILURE] No compatible and/or active webserver was found.\n
+Currently DietPi-LetsEncrypt configures the following web applications:
+ - Apache2 (webserver)
+ - Nginx (webserver)
+ - Lighttpd (webserver)
+ - Minio S3 (object storage server)\n
+Would you like to switch to DietPi-Software, to install one of the above?' && /DietPi/dietpi/dietpi-software
return 1
fi
@@ -458,8 +472,7 @@ _EOF_
Menu_Exit(){
G_WHIP_SIZE_X_MAX=50
- G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"; then
#exit
TARGETMENUID=-1
@@ -477,18 +490,10 @@ _EOF_
Menu_Main(){
local hsts_text='[Off] | No HTTP Strict Transport Security'
- if (( $LETSENCRYPT_HSTS )); then
-
- hsts_text='[On] | HTTP Strict Transport Security'
-
- fi
+ (( $LETSENCRYPT_HSTS )) && hsts_text='[On] | HTTP Strict Transport Security'
local redirect_text='[Off] | Allows http and https usage'
- if (( $LETSENCRYPT_REDIRECT )); then
-
- redirect_text='[On] | Forces http redirects to https'
-
- fi
+ (( $LETSENCRYPT_REDIRECT )) && redirect_text='[On] | Forces http redirects to https'
G_WHIP_MENU_ARRAY=(
@@ -503,8 +508,7 @@ _EOF_
G_WHIP_DEFAULT_ITEM="$PREVIOUS_MENU_SELECTION"
G_WHIP_BUTTON_CANCEL_TEXT='Exit'
- G_WHIP_MENU 'Please select an option:'
- if (( ! $? )); then
+ if G_WHIP_MENU 'Please select an option:'; then
PREVIOUS_MENU_SELECTION=$G_WHIP_RETURNED_VALUE
@@ -512,7 +516,8 @@ _EOF_
'Domain')
- while true; do
+ while :
+ do
LETSENCRYPT_DOMAIN="$(Input_Box $LETSENCRYPT_DOMAIN Website-Domain)"
[[ $LETSENCRYPT_DOMAIN == *?.?* && ! $(sed 's/\.//g' <<< $LETSENCRYPT_DOMAIN) =~ ^[0-9]*$ ]] && break
@@ -575,11 +580,7 @@ Are you sure that you want to enable HTTP Strict Transport Security?'
'Redirect')
((LETSENCRYPT_REDIRECT++))
- if (( $LETSENCRYPT_REDIRECT > 1 )); then
-
- LETSENCRYPT_REDIRECT=0
-
- fi
+ (( $LETSENCRYPT_REDIRECT > 1 )) && LETSENCRYPT_REDIRECT=0
;;
@@ -613,17 +614,12 @@ Are you sure that you want to enable HTTP Strict Transport Security?'
local input_desc=$2
G_WHIP_DEFAULT_ITEM="$input_value"
- G_WHIP_INPUTBOX "Please enter a value for $input_desc"
- if (( ! $? )); then
+ if G_WHIP_INPUTBOX "Please enter a value for $input_desc"; then
input_value="$G_WHIP_RETURNED_VALUE"
# - Prevent null values
- if [[ -z $input_value ]]; then
-
- input_value='NULL'
-
- fi
+ [[ -z $input_value ]] && input_value='NULL'
fi
@@ -658,7 +654,7 @@ Are you sure that you want to enable HTTP Strict Transport Security?'
else
- echo -e "[FAILURE] CertBot binary not found ( $FP_BINARY ), please install it with DietPi-Software. Aborting..." | tee "$FP_LOGFILE"
+ echo "[FAILURE] CertBot binary not found ( $FP_BINARY ), please install it with DietPi-Software. Aborting..." | tee "$FP_LOGFILE"
fi
@@ -670,11 +666,7 @@ Are you sure that you want to enable HTTP Strict Transport Security?'
printf '\ec' # clear current terminal screen
- if (( $TARGETMENUID == 0 )); then
-
- Menu_Main
-
- fi
+ (( $TARGETMENUID == 0 )) && Menu_Main
done
diff --git a/dietpi/dietpi-morsecode b/dietpi/dietpi-morsecode
index dd1303b22b..80574db918 100644
--- a/dietpi/dietpi-morsecode
+++ b/dietpi/dietpi-morsecode
@@ -24,17 +24,15 @@
#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
- G_CHECK_ROOT_USER
G_PROGRAM_NAME='DietPi-Morsecode'
+ G_CHECK_ROOT_USER
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
- INPUT=0
- if disable_error=1 G_CHECK_VALIDINT $1; then
-
- INPUT=$1
+ G_EXIT_CUSTOM(){ [[ -f $FP_TEXTFILE_LOWERCASE ]] && rm $FP_TEXTFILE_LOWERCASE; }
- fi
+ INPUT=0
+ disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1
#/////////////////////////////////////////////////////////////////////////////////////
# Output Data
@@ -112,14 +110,13 @@
#Define single unit duration (essentially the speed at which the morse code is outputted)
MC_DURATION_UNIT=0.15
#Dash and next char duration ( MC_DURATION_UNIT * 3 )
- MC_DURATION_DASH=$(echo - | awk "{print $MC_DURATION_UNIT * 3}")
+ MC_DURATION_DASH=$(echo - | mawk "{print $MC_DURATION_UNIT * 3}")
#New word duration ( MC_DURATION_UNIT * 7 )
- MC_DURATION_WORD=$(echo - | awk "{print $MC_DURATION_UNIT * 7}")
+ MC_DURATION_WORD=$(echo - | mawk "{print $MC_DURATION_UNIT * 7}")
Mc_Convert_Input_Textfile_Lowercase(){
- echo -e 'DietPi-Morsecode\n'
- echo -e 'Converting input file to lowercase......\n'
+ echo -e 'DietPi-Morsecode\n\nConverting input file to lowercase......\n'
dd if="$FP_TEXTFILE_INPUT" of="$FP_TEXTFILE_LOWERCASE" conv=lcase &> /dev/null
echo -e "Completed\nRendering to Output_Mode $OUTPUT_MODE"
@@ -476,9 +473,6 @@
#Send end of message (AR)
Mc_End_of_Message
#-----------------------------------------------------------------------------------
- #Del temp files
- rm $FP_TEXTFILE_LOWERCASE
- #-----------------------------------------------------------------------------------
exit
#-----------------------------------------------------------------------------------
diff --git a/dietpi/dietpi-process_tool b/dietpi/dietpi-process_tool
index a18f28dd42..2e373b679c 100644
--- a/dietpi/dietpi-process_tool
+++ b/dietpi/dietpi-process_tool
@@ -24,23 +24,6 @@
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
- G_EXIT_CUSTOM(){
-
- #Delete[] Global arrays
- unset aNICE
- unset aAFFINITY
- unset aSCHEDULE_POLICY
- unset aSCHEDULE_PRIORITY
- unset aPID
- unset aNAME
- unset aPROCESS_NAME
- unset aAVAILABLE
- unset aSCHEDULE_AVAILABLE_POLICY
- unset aSCHEDULE_AVAILABLE_PRIORITY_MIN
- unset aSCHEDULE_AVAILABLE_PRIORITY_MAX
-
- }
-
#Grab Input
INPUT=0
disable_error=1 G_CHECK_VALIDINT $1 && INPUT=$1
@@ -50,8 +33,6 @@
#/////////////////////////////////////////////////////////////////////////////////////
EXIT_CODE=0
- MAX_PROGRAMS=0
-
aNICE=()
aAFFINITY=()
aSCHEDULE_POLICY=()
@@ -76,7 +57,7 @@
local print_info=1
(( $HIERARCHY > 1 )) && print_info=0
- for ((i=0; i<$MAX_PROGRAMS; i++))
+ for i in ${!aNAME[@]}
do
if (( ${aAVAILABLE[$i]} )); then
@@ -247,6 +228,7 @@
aNAME[$index]='Jackett';aPROCESS_NAME[$index]='JackettConsole.exe';((index++))
aNAME[$index]='Jack Server';aPROCESS_NAME[$index]='jackd';((index++))
aNAME[$index]='Jconvolver';aPROCESS_NAME[$index]='jconvolver';((index++))
+ aNAME[$index]='Medusa';aPROCESS_NAME[$index]='medusa/start.py';((index++))
aNAME[$index]='Minio';aPROCESS_NAME[$index]='minio';((index++))
aNAME[$index]='MiniDLNA';aPROCESS_NAME[$index]='minidlna';((index++))
aNAME[$index]='Mopidy';aPROCESS_NAME[$index]='mopidy';((index++))
@@ -269,12 +251,10 @@
aNAME[$index]='Pi-hole FTL';aPROCESS_NAME[$index]='pihole-FTL';((index++))
aNAME[$index]='PiJuice';aPROCESS_NAME[$index]='pijuice_sys.py';((index++))
aNAME[$index]='Pi-SPC';aPROCESS_NAME[$index]='sds.sh';((index++))
-
aNAME[$index]='Plex Media Server';aPROCESS_NAME[$index]='Plex Media Server';((index++))
#aNAME[$index]='Plex Plug-in';aPROCESS_NAME[$index]='Plex Plug-in';((index++))
aNAME[$index]='Plex DLNA Server';aPROCESS_NAME[$index]='Plex DLNA Server';((index++))
aNAME[$index]='Plex Tuner Service';aPROCESS_NAME[$index]='Plex Tuner Service';((index++))
-
aNAME[$index]='ProFTP';aPROCESS_NAME[$index]='proftpd';((index++))
aNAME[$index]='qBitTorrent';aPROCESS_NAME[$index]='qbittorrent-nox';((index++))
aNAME[$index]='Radarr';aPROCESS_NAME[$index]='Radarr.exe';((index++))
@@ -290,7 +270,8 @@
aNAME[$index]='Samba Server (Daemon)';aPROCESS_NAME[$index]='smbd';((index++))
aNAME[$index]='Samba Server (NetBios)';aPROCESS_NAME[$index]='nmbd';((index++))
aNAME[$index]='Shairport Sync';aPROCESS_NAME[$index]='shairport-sync';((index++))
- aNAME[$index]='SickRage';aPROCESS_NAME[$index]='SiCKRAGE.py';((index++))
+ aNAME[$index]='SiCKRAGE';aPROCESS_NAME[$index]='SiCKRAGE.py';((index++)) # pre-v6.20 compatibility
+ aNAME[$index]='SickRage';aPROCESS_NAME[$index]='SickBeard.py';((index++)) # pre-v6.17 compatibility
aNAME[$index]='Sonarr';aPROCESS_NAME[$index]='NzbDrone.exe';((index++))
aNAME[$index]='Spotify Connect Web';aPROCESS_NAME[$index]='spotify-connect-web';((index++))
aNAME[$index]='Supervisor';aPROCESS_NAME[$index]='supervisor';((index++))
@@ -332,22 +313,17 @@
done < $fp_include
fi
- MAX_PROGRAMS=${#aNAME[@]}
# - Enable affinity for all cores and all programs by default
local init_affinity_value=0
- if (( $G_HW_CPU_CORES > 1 )); then
-
- init_affinity_value="0-$(( $G_HW_CPU_CORES - 1 ))"
-
- fi
+ (( $G_HW_CPU_CORES > 1 )) && init_affinity_value="0-$(( $G_HW_CPU_CORES - 1 ))"
# - Find out which programs are running (impies installed) | exclude kernel threads ([])
# NB: -L to list all threads in ps output
ps ax --no-headers -o pid -o cmd | sed '/\]$/d' > $FP_PS_LIST
# - Init other arrays
- for ((i=0; i<$MAX_PROGRAMS; i++))
+ for i in ${!aNAME[@]}
do
aNICE[$i]=0
@@ -462,7 +438,7 @@
rm $FP_SETTINGS &> /dev/null
local save_index=0
- for ((i=0; i<$MAX_PROGRAMS; i++))
+ for i in ${!aNAME[@]}
do
if (( ${aAVAILABLE[$i]} )); then
@@ -513,7 +489,7 @@ _EOF_
G_WHIP_MENU_ARRAY=()
- for ((i=0; i<$MAX_PROGRAMS; i++))
+ for i in ${!aNAME[@]}
do
if (( ${aAVAILABLE[$i]} )); then
@@ -532,7 +508,7 @@ _EOF_
#Find selected program index
local index_current=0
- for ((i=0; i<$MAX_PROGRAMS; i++))
+ for i in ${!aNAME[@]}
do
if [[ ${aNAME[$i]} == $G_WHIP_RETURNED_VALUE ]]; then
@@ -553,7 +529,7 @@ _EOF_
else
#return back to this section.
- while true
+ while :
do
#menu, choose nice/affinity etc
@@ -578,7 +554,7 @@ _EOF_
G_WHIP_MENU_ARRAY=()
- for ((i=-20; i<20; i++))
+ for i in {-20..19}
do
local desc=''
if (( $i == -20 )); then
@@ -668,11 +644,7 @@ _EOF_
done
#Update affinity array with new value, if at least 1 item was selected.
- if [[ $new_affinity ]] ; then
-
- aAFFINITY[$index_current]="$new_affinity"
-
- fi
+ [[ $new_affinity ]] && aAFFINITY[$index_current]="$new_affinity"
#Apply
Apply_Process_Tool
@@ -850,11 +822,7 @@ _EOF_
printf '\ec' # clear current terminal screen
- if (( $TARGETMENUID == 0 )); then
-
- Menu_Main
-
- fi
+ (( $TARGETMENUID == 0 )) && Menu_Main
done
@@ -871,6 +839,6 @@ _EOF_
fi
#-----------------------------------------------------------------------------------
- exit ${EXIT_CODE:=0}
+ exit ${EXIT_CODE:-0}
#-----------------------------------------------------------------------------------
}
diff --git a/dietpi/dietpi-services b/dietpi/dietpi-services
index fff08ad010..315f1dbfba 100644
--- a/dietpi/dietpi-services
+++ b/dietpi/dietpi-services
@@ -29,7 +29,7 @@
#Grab Inputs
INPUT_MODE=$1
- INPUT_S2="$2"
+ INPUT_S2=$2
#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
@@ -39,7 +39,6 @@
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
-
aSERVICE_AVAILABLE=()
aSERVICE_NAME=(
@@ -117,7 +116,8 @@
#'moode-worker'
# - Download/BitTorrent
- 'sickrage'
+ 'sickrage' # pre-v6.20 compatibility
+ 'medusa'
'aria2'
'sabnzbd'
'couchpotato'
@@ -218,6 +218,8 @@
aSERVICE_NAME+=('dietpi-boot')
aSERVICE_NAME+=('dietpi-postboot')
aSERVICE_NAME+=('dietpi-wifi-monitor') #: https://github.com/Fourdee/DietPi/issues/1288#issuecomment-350653480
+ aSERVICE_NAME+=('dietpi-nordvpn') #: NordVPN install + client
+ #aSERVICE_NAME+=('wg-quick@wg0') #: Wireguard
fi
@@ -232,7 +234,7 @@
if [[ $line != '#'* ]]; then
- local scrape="${line: +2}"
+ local scrape=${line: +2}
# - Include
if [[ $line == '+ '* ]]; then
@@ -254,7 +256,7 @@
if (( ! $service_known_already_to_dietpi )); then
- aSERVICE_NAME[$index]="$scrape"
+ aSERVICE_NAME[$index]=$scrape
G_DIETPI-NOTIFY 2 "Including custom service: $scrape"
fi
@@ -292,7 +294,7 @@
Process_Includes_Excludes
#Find dpkg program names
- dpkg --get-selections | awk '{print $1}' > $FP_TEMP
+ dpkg --get-selections | grep -v '^lib' | mawk '{print $1}' > $FP_TEMP
aSERVICE_AVAILABLE=()
for ((i=0; i<${#aSERVICE_NAME[@]}; i++))
@@ -303,11 +305,11 @@
if [[ ${aSERVICE_NAME[$i]} ]]; then
# Below Stretch, "mariadb" systemd service does not exist, thus "mysql" init.d service will be used.
- [[ ${aSERVICE_NAME[$i]} == 'mariadb' ]] && (( $G_DISTRO < 4 )) && aSERVICE_NAME[$i]='mysql'
+ (( $G_DISTRO < 4 )) && [[ ${aSERVICE_NAME[$i]} == 'mariadb' ]] && aSERVICE_NAME[$i]='mysql'
if [[ -f /etc/systemd/system/${aSERVICE_NAME[$i]}.service ||
-f /lib/systemd/system/${aSERVICE_NAME[$i]}.service ||
- -f /usr/lib/systemd/system/${aSERVICE_NAME[$i]}.service ||
+ -f /usr/lib/systemd/system/${aSERVICE_NAME[$i]}.service ||
-f /etc/init.d/${aSERVICE_NAME[$i]} ]] ||
grep -qi "^${aSERVICE_NAME[$i]}$" $FP_TEMP; then
@@ -363,7 +365,9 @@
'lighttpd'
'php5-fpm'
'php7.0-fpm'
+ 'php7.1-fpm'
'php7.2-fpm'
+ 'php7.3-fpm'
'mysql'
'avahi-daemon'
@@ -453,7 +457,7 @@
}
- FP_TEMP='/tmp/.dietpi-services_installed'
+ FP_TEMP='dietpi-services_installed'
#/////////////////////////////////////////////////////////////////////////////////////
# Main
@@ -563,7 +567,7 @@ _EOF_
fi
- systemctl daemon-reload &> /dev/null
+ systemctl daemon-reload
if [[ $INPUT_MODE == 'unmask' || $INPUT_MODE == 'enable' ]]; then
@@ -609,8 +613,7 @@ _EOF_
#Single use case, basically a alias for systemd
if [[ $INPUT_S2 ]]; then
- systemctl $INPUT_MODE $INPUT_S2 &> /dev/null
- if (( ! $? )); then
+ if systemctl $INPUT_MODE $INPUT_S2 &> /dev/null; then
G_DIETPI-NOTIFY 0 "$INPUT_MODE $INPUT_S2"
@@ -623,7 +626,7 @@ _EOF_
#All services controlled
else
- Set_Running_State "$INPUT_MODE"
+ Set_Running_State $INPUT_MODE
fi
@@ -635,10 +638,6 @@ _EOF_
fi
#-----------------------------------------------------------------------------------
- rm $FP_TEMP
- unset aSERVICE_NAME
- unset aSERVICE_AVAILABLE
- #-----------------------------------------------------------------------------------
exit
#-----------------------------------------------------------------------------------
}
diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software
index 82fb8b28f0..f1ee9f1b70 100644
--- a/dietpi/dietpi-software
+++ b/dietpi/dietpi-software
@@ -11,7 +11,6 @@
# Info:
# - filename /DietPi/dietpi/dietpi-software
# - Installs "ready to run" software with optimizations unique to the device.
- # - Runs dietpi-update during 1st run setup.
# - Generates and uses /DietPi/dietpi/.installed (software list) # -1=selected for uninstall, 0=not installed, 1=selected for install, 2=installed
#
# Usage:
@@ -30,41 +29,6 @@
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
- # Custom exit trap
- G_EXIT_CUSTOM(){
-
- unset aSOFTWARE_CATEGORIES_DIETPI
- unset aSOFTWARE_CATEGORIES_LINUX
-
- unset aSOFTWARE_CATEGORY_INDEX
- unset aSOFTWARE_TYPE
- unset aSOFTWARE_WHIP_NAME
- unset aSOFTWARE_WHIP_DESC
- unset aSOFTWARE_ONLINEDOC_URL
- unset aSOFTWARE_INSTALL_STATE
-
- unset aSOFTWARE_REQUIRES_USERINPUT
-
- unset aSOFTWARE_REQUIRES_ALSA
- unset aSOFTWARE_REQUIRES_XSERVERXORG
- unset aSOFTWARE_REQUIRES_MYSQL
- unset aSOFTWARE_REQUIRES_SQLITE
- unset aSOFTWARE_REQUIRES_WEBSERVER
- unset aSOFTWARE_REQUIRES_PHP
- unset aSOFTWARE_REQUIRES_DESKTOP
- unset aSOFTWARE_REQUIRES_GIT
- unset aSOFTWARE_REQUIRES_BUILDESSENTIAL
- unset aSOFTWARE_REQUIRES_RSYSLOG
- unset aSOFTWARE_REQUIRES_FFMPEG
- unset aSOFTWARE_REQUIRES_JAVA_JRE_JDK
- unset aSOFTWARE_REQUIRES_NODEJS
-
- unset aSOFTWARE_AVAIL_G_HW_MODEL
- unset aSOFTWARE_AVAIL_G_HW_ARCH
- unset aSOFTWARE_AVAIL_G_DISTRO
-
- }
-
#/////////////////////////////////////////////////////////////////////////////////////
#Filepath
#/////////////////////////////////////////////////////////////////////////////////////
@@ -145,7 +109,7 @@ _EOF_
[[ -f $fp_target ]] && . $fp_target
#Always reset choice system during first run to defaults: https://github.com/Fourdee/DietPi/issues/1122
- if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
+ if (( $G_DIETPI_INSTALL_STAGE == 1 )); then
INDEX_SSHSERVER_CURRENT=-1
INDEX_SSHSERVER_TARGET=-1
@@ -165,71 +129,13 @@ _EOF_
}
- Reset_Timesync(){
-
- killall -w /DietPi/dietpi/func/run_ntpd &> /dev/null
-
- }
-
Check_Internet_and_NTPD(){
# Internet
# - Use /etc/apt/sources.list for connection test
- local internet_url_test="$(grep -m1 '^[[:blank:]]*deb ' /etc/apt/sources.list | awk '{print $2}')"
- optional_cmd_inputs='--no-check-certificate' G_CHECK_URL "$internet_url_test" # Will exit on failure here then prompt user to configure network
-
- # Timesync
- until /DietPi/dietpi/func/run_ntpd
- do
-
- # - Ask
- if (( $G_USER_INPUTS )); then
-
- G_WHIP_MENU_ARRAY=(
-
- 'Retry' ': (Recommended) Rerun network time sync'
- 'NTP mirror' ': Change the NTP mirror used'
- 'NTP mode' ': Change the NTP mode (eg: daemon + drift)'
- 'Override' ': (NOT RECOMMENDED) Ignore failure and override time sync status'
-
- )
-
- G_WHIP_MENU 'Network time sync has not yet completed, or, failed to update.\nTo prevent issues with outdated system time during installations, please select an option below.\n
-NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then "NTP mode".\n"Override" is a last resort and may cause follow-up issues due to incorrect system clock time.'
- if (( ! $? )); then
-
- if [[ $G_WHIP_RETURNED_VALUE == 'Retry' ]]; then
-
- Reset_Timesync
-
- elif [[ $G_WHIP_RETURNED_VALUE == 'NTP mirror' ]]; then
-
- G_WHIP_MSG 'DietPi-Config will now be launched, on the next screen:\n - Select "NTP Mirror"\n - Select a different NTP mirror\n\nOnce completed, exit dietpi-config to resume setup'
- /DietPi/dietpi/dietpi-config 16 1
-
- elif [[ $G_WHIP_RETURNED_VALUE == 'NTP mode' ]]; then
-
- G_WHIP_MSG 'DietPi-Config will now be launched, on the next screen:\n - Select "Time sync mode"\n - Select a different time sync mode (eg: Daemon + Drift)\n\nOnce completed, exit dietpi-config to resume setup'
- /DietPi/dietpi/dietpi-config 3 1
-
- elif [[ $G_WHIP_RETURNED_VALUE == 'Override' ]]; then
-
- Reset_Timesync
- echo 0 > /DietPi/dietpi/.timesync_exit_status
- echo 1 > /var/lib/dietpi/.ntpd_override
-
- fi
-
- fi
-
- # - Endless retry
- else
-
- Reset_Timesync
+ optional_cmd_inputs='--no-check-certificate' G_CHECK_URL "$(grep -m1 '^[[:blank:]]*deb ' /etc/apt/sources.list | awk '{print $2}')" # Will exit on failure here then prompt user to configure network
- fi
-
- done
+ /DietPi/dietpi/func/run_ntpd
}
@@ -260,7 +166,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
fi
# - Failsafe
- if [[ -z $GLOBAL_PW ]]; then
+ if [[ ! $GLOBAL_PW ]]; then
GLOBAL_PW='dietpi'
G_DIETPI-NOTIFY 1 "Unable to obtain GLOBAL_PW from dietpi.txt (1st run automation only), and, /var/lib/dietpi/dietpi-software/.GLOBAL_PW.bin\n\nThe following fallback GLOBAL_PW will be used:\n - $GLOBAL_PW"
@@ -289,7 +195,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
#PHP5/7 specific directories, apt package-, module- and command names
# - and Distro specific MariaDB service name
FP_PHP_BASE_DIR='/etc/php/7.0'
- PHP_APT_PACKAGE_NAME='php'
+ PHP_APT_PACKAGE_NAME='php7.0'
PHP_BINARY='php'
MARIADB_SERVICE='mariadb'
if (( $G_DISTRO < 4 )); then
@@ -306,7 +212,6 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
fi
- #
USBDRIVE=0
#Choices Made?
@@ -436,7 +341,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
'●─ Webserver Stacks ' #13
'●─ Pi-hole ' #14
'●─ File Servers ' #15
- '●─ VPN Servers ' #16
+ '●─ VPN ' #16
'●─ Advanced Networking ' #17
'●─ Home Automation ' #18
'●─ Printing ' #19
@@ -465,7 +370,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
#Before adding, please check 'dietpi-software list | grep null' to list NULL (available) IDs for use.
#Assign UNIQUE ID to each item
- local software_id=0
+ local software_id=-1
#Desktops
#--------------------------------------------------------------------------------
@@ -579,10 +484,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
aSOFTWARE_CATEGORY_INDEX[$software_id]=1
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_REQUIRES_DESKTOP[$software_id]=1
- aSOFTWARE_ONLINEDOC_URL[$software_id]='f=8&t=5&start=60#p2071'
-
- # - ARMv8
- aSOFTWARE_AVAIL_G_HW_ARCH[$software_id,3]=0
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p=2071#p2071'
#------------------
software_id=120
@@ -665,26 +567,26 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
#------------------
software_id=33
- aSOFTWARE_WHIP_NAME[$software_id]='AirSonic'
+ aSOFTWARE_WHIP_NAME[$software_id]='Airsonic'
aSOFTWARE_WHIP_DESC[$software_id]='web interface media streaming server'
aSOFTWARE_CATEGORY_INDEX[$software_id]=2
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_REQUIRES_ALSA[$software_id]=1
aSOFTWARE_REQUIRES_JAVA_JRE_JDK[$software_id]=1
aSOFTWARE_REQUIRES_FFMPEG[$software_id]=1
- aSOFTWARE_ONLINEDOC_URL[$software_id]='f=8&t=5&p=11280#p11280'
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p=11280#p11280'
#------------------
software_id=34
- aSOFTWARE_WHIP_NAME[$software_id]='SubSonic 6'
+ aSOFTWARE_WHIP_NAME[$software_id]='Subsonic'
aSOFTWARE_WHIP_DESC[$software_id]='web interface media streaming server'
aSOFTWARE_CATEGORY_INDEX[$software_id]=2
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_REQUIRES_ALSA[$software_id]=1
aSOFTWARE_REQUIRES_FFMPEG[$software_id]=1
aSOFTWARE_REQUIRES_JAVA_JRE_JDK[$software_id]=1
- aSOFTWARE_ONLINEDOC_URL[$software_id]='f=8&t=5&start=30#p213'
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p=213#p213'
#------------------
software_id=35
@@ -1018,12 +920,11 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
#------------------
software_id=116
- aSOFTWARE_WHIP_NAME[$software_id]='SiCKRAGE'
- aSOFTWARE_WHIP_DESC[$software_id]='automatically download TV shows'
+ aSOFTWARE_WHIP_NAME[$software_id]='Medusa'
+ aSOFTWARE_WHIP_DESC[$software_id]='Automatic Video Library Manager for TV Shows'
aSOFTWARE_CATEGORY_INDEX[$software_id]=3
- aSOFTWARE_TYPE[$software_id]=-1
- aSOFTWARE_REQUIRES_BUILDESSENTIAL[$software_id]=1
- aSOFTWARE_ONLINEDOC_URL[$software_id]='f=8&t=5&p=3327#p3327'
+ aSOFTWARE_TYPE[$software_id]=0
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p=3327#p3327'
#------------------
software_id=132
@@ -1092,10 +993,10 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
software_id=147
aSOFTWARE_WHIP_NAME[$software_id]='Jackett'
- aSOFTWARE_WHIP_DESC[$software_id]='api Support for your torrent trackers.'
+ aSOFTWARE_WHIP_DESC[$software_id]='API support for your torrent trackers'
aSOFTWARE_CATEGORY_INDEX[$software_id]=3
aSOFTWARE_TYPE[$software_id]=0
- aSOFTWARE_ONLINEDOC_URL[$software_id]='f=8&t=5&p=7503#p7503'
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p=7503#p7503'
#------------------
software_id=149
@@ -1121,25 +1022,27 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
software_id=47
aSOFTWARE_WHIP_NAME[$software_id]='ownCloud'
- aSOFTWARE_WHIP_DESC[$software_id]='your very own cloud (eg: dropbox)'
+ aSOFTWARE_WHIP_DESC[$software_id]='File sync, sharing and collaboration platform'
aSOFTWARE_CATEGORY_INDEX[$software_id]=4
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_REQUIRES_WEBSERVER[$software_id]=1
aSOFTWARE_REQUIRES_PHP[$software_id]=1
aSOFTWARE_REQUIRES_MYSQL[$software_id]=1
- aSOFTWARE_ONLINEDOC_URL[$software_id]='f=8&t=5#p47'
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p=47#p47'
+ # Current ownCloud 10.0.10 does not support PHP7.3 (Buster): https://doc.owncloud.org/server/administration_manual/installation/system_requirements.html
+ aSOFTWARE_AVAIL_G_DISTRO[$software_id,5]=0
#------------------
software_id=114
aSOFTWARE_WHIP_NAME[$software_id]='Nextcloud'
- aSOFTWARE_WHIP_DESC[$software_id]='A safe home for all your data'
+ aSOFTWARE_WHIP_DESC[$software_id]='File sync, sharing and collaboration platform'
aSOFTWARE_CATEGORY_INDEX[$software_id]=4
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_REQUIRES_WEBSERVER[$software_id]=1
aSOFTWARE_REQUIRES_PHP[$software_id]=1
aSOFTWARE_REQUIRES_MYSQL[$software_id]=1
- aSOFTWARE_ONLINEDOC_URL[$software_id]='f=8&t=5&p=3026#p3026'
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p=3026#p3026'
#------------------
software_id=168
@@ -1151,7 +1054,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
#Currently requires manual domain and TURN server port input.
# - To resolve: Default port 5349 could be used, but reliable method to get external domain/static IP is required.
aSOFTWARE_REQUIRES_USERINPUT[$software_id]=1
- aSOFTWARE_ONLINEDOC_URL[$software_id]='f=8&t=5&p=15227#p15227'
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p=15227#p15227'
#------------------
software_id=48
@@ -1815,7 +1718,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
aSOFTWARE_WHIP_DESC[$software_id]='platform for analytics and monitoring'
aSOFTWARE_CATEGORY_INDEX[$software_id]=11
aSOFTWARE_TYPE[$software_id]=0
- aSOFTWARE_ONLINEDOC_URL[$software_id]='f=8&t=5&p=12524#p12524'
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p=12524#p12524'
#System security
@@ -2034,7 +1937,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
#------------------
- #VPN servers
+ #VPN
#--------------------------------------------------------------------------------
software_id=97
@@ -2043,21 +1946,55 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
aSOFTWARE_CATEGORY_INDEX[$software_id]=16
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_REQUIRES_RSYSLOG[$software_id]=1
- aSOFTWARE_ONLINEDOC_URL[$software_id]='f=8&t=5&p=613#p613'
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p=613#p613'
#------------------
software_id=117
aSOFTWARE_WHIP_NAME[$software_id]='PiVPN'
- aSOFTWARE_WHIP_DESC[$software_id]='openvpn installer & management tool'
+ aSOFTWARE_WHIP_DESC[$software_id]='openvpn server install & management tool'
aSOFTWARE_CATEGORY_INDEX[$software_id]=16
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_REQUIRES_RSYSLOG[$software_id]=1
aSOFTWARE_REQUIRES_GIT[$software_id]=1
- aSOFTWARE_ONLINEDOC_URL[$software_id]='https://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=3469#p3469'
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p=3469#p3469'
aSOFTWARE_REQUIRES_USERINPUT[$software_id]=1
#------------------
+ software_id=171
+
+ aSOFTWARE_WHIP_NAME[$software_id]='DietPi-NordVPN'
+ aSOFTWARE_WHIP_DESC[$software_id]='vpn client with connection gui'
+ aSOFTWARE_CATEGORY_INDEX[$software_id]=16
+ aSOFTWARE_TYPE[$software_id]=0
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p15975#p15975'
+
+ #------------------
+ software_id=172
+
+ aSOFTWARE_WHIP_NAME[$software_id]='WireGuard'
+ aSOFTWARE_WHIP_DESC[$software_id]='an extremely simple yet fast and modern VPN'
+ aSOFTWARE_CATEGORY_INDEX[$software_id]=16
+ aSOFTWARE_TYPE[$software_id]=0
+ aSOFTWARE_ONLINEDOC_URL[$software_id]='p=16308#p16308'
+ # Required to ask for public domain/IP and desired VPN server port
+ aSOFTWARE_REQUIRES_USERINPUT[$software_id]=1
+
+ # Disable all
+ for ((i=0; i<=$MAX_G_HW_MODEL; i++))
+ do
+
+ aSOFTWARE_AVAIL_G_HW_MODEL[$software_id,$i]=0
+
+ done
+ # Enable RPi/x86_64/Odroids
+ if (( $G_HW_MODEL < 10 ||
+ $G_HW_ARCH == 10 ||
+ $G_HW_MODEL == 10 || $G_HW_MODEL == 11 || $G_HW_MODEL == 12 || $G_HW_MODEL == 14 )); then
+
+ aSOFTWARE_AVAIL_G_HW_MODEL[$software_id,$G_HW_MODEL]=1
+
+ fi
#Advanced Networking
@@ -2339,6 +2276,13 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
aSOFTWARE_CATEGORY_INDEX[$software_id]=6
aSOFTWARE_TYPE[$software_id]=1
#------------------
+ software_id=170
+
+ aSOFTWARE_WHIP_NAME[$software_id]='Unrar'
+ aSOFTWARE_WHIP_DESC[$software_id]='unarchiver for .rar files'
+ aSOFTWARE_CATEGORY_INDEX[$software_id]=6
+ aSOFTWARE_TYPE[$software_id]=1
+ #------------------
#Text Editors
#--------------------------------------------------------------------------------
@@ -2421,7 +2365,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
#------------------
software_id=103
- aSOFTWARE_WHIP_NAME[$software_id]='DietPi-Ramlog'
+ aSOFTWARE_WHIP_NAME[$software_id]='DietPi-RAMlog'
aSOFTWARE_WHIP_DESC[$software_id]='minimal, optimized logging'
aSOFTWARE_CATEGORY_INDEX[$software_id]=0
aSOFTWARE_TYPE[$software_id]=-1
@@ -2494,7 +2438,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" "Checking for prerequisite software"
- local software_id=0
+ local software_id=-1
#-------------------------------------------------------------------------
#Pre-req software, for items that do not have their own array aSOFTWARE_REQUIRES_SOFTWARENAME
@@ -2656,6 +2600,20 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
fi
+ #Software that requires unrar
+ # rtorrent
+ # Medusa
+ # SABnzbd
+ software_id=170
+ if (( ${aSOFTWARE_INSTALL_STATE[107]} == 1 ||
+ ${aSOFTWARE_INSTALL_STATE[116]} == 1 ||
+ ${aSOFTWARE_INSTALL_STATE[139]} == 1 )); then
+
+ aSOFTWARE_INSTALL_STATE[$software_id]=1
+ G_DIETPI-NOTIFY 2 "${aSOFTWARE_WHIP_NAME[$software_id]} will be installed"
+
+ fi
+
#-------------------------------------------------------------------------
#WEBSERVER - Manual stack install
# - Define extra DietPi install flags for WEBSERVER_STACKS
@@ -3166,6 +3124,8 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
fi
+ [[ -f $target ]] && G_WHIP_MSG "[INFO] Configuration/data updated for:\n - $target"
+
G_RUN_CMD cp -f $file $target
elif [[ $type == deb ]]; then
@@ -3253,7 +3213,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
#--------------------------------------------------------------
#Install Software
- local software_id=0
+ local software_id=-1
#Desktop LXDE
software_id=23
@@ -3334,26 +3294,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
-
- INSTALL_URL_ADDRESS='https://dietpi.com/downloads/binaries/all/nomachine_6.1.6_'
- #x86_64
- if (( $G_HW_ARCH == 10 )); then
-
- INSTALL_URL_ADDRESS+='9_amd64.deb'
-
- #arm6 (RPi1)
- elif (( $G_HW_ARCH == 1 )); then
-
- INSTALL_URL_ADDRESS+='4_armv6hf.deb'
-
- #arm7+ (RPi 2/3)
- elif (( $G_HW_ARCH == 2 )); then
-
- INSTALL_URL_ADDRESS+='4_armhf.deb'
-
- fi
-
- Download_Install "$INSTALL_URL_ADDRESS"
+ Download_Install "https://dietpi.com/downloads/binaries/all/nomachine_6.4.6_$G_HW_ARCH_DESCRIPTION.deb"
fi
@@ -3382,6 +3323,17 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
+
+ # Link disk cache to RAM: https://github.com/Fourdee/DietPi/issues/2396
+ # - Remove previous disk cache dir or symlink
+ [[ -e /var/cache/samba ]] && rm -R /var/cache/samba
+ # - Pre-create RAM cache dir
+ mkdir -p /var/run/samba-cache
+ # - Link disk cache to RAM
+ ln -s /var/run/samba-cache /var/cache/samba
+ # - Create RAM cache dir automatically on boot
+ echo 'd /var/run/samba-cache - - - - -' > /etc/tmpfiles.d/dietpi-samba_cache.conf
+
G_AGI samba
fi
@@ -3415,7 +3367,10 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
- G_AGI apache2
+ local package_list='apache2'
+ # - Install certbot module on Stretch+, if certbot was already installed
+ (( ${aSOFTWARE_INSTALL_STATE[93]} == 2 && $G_DISTRO > 3 )) && package_list+=' python-certbot-apache'
+ G_AGI $package_list
fi
@@ -3424,7 +3379,10 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
- G_AGI nginx-light
+ local package_list='nginx-light'
+ # - Install certbot module on Stretch+, if certbot was already installed
+ (( ${aSOFTWARE_INSTALL_STATE[93]} == 2 && $G_DISTRO > 3 )) && package_list+=' python-certbot-nginx'
+ G_AGI $package_list
fi
@@ -3433,8 +3391,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
-
- #NB: RPi | Perl required, else 'lighttpd-enable-mod fastcgi' = Can't locate Term/ReadLine.pm
+ # - NB: RPi | Perl required, else 'lighttpd-enable-mod fastcgi' = Can't locate Term/ReadLine.pm
G_AGI lighttpd perl
fi
@@ -3521,7 +3478,7 @@ NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then
Banner_Installing
local package_list='redis-server'
# Install php-redis module, if PHP was already installed
- (( ${aSOFTWARE_INSTALL_STATE[89]} == 2 )) && package_list+=" $PHP_APT_PACKAGE_NAME-redis"
+ (( ${aSOFTWARE_INSTALL_STATE[89]} == 2 )) && package_list+=" $PHP_BINARY-redis"
G_AGI $package_list
fi
@@ -3629,12 +3586,12 @@ We work around this error by running APT a second time. Please do not worry and
#Jessie-
if (( $G_DISTRO < 4 )); then
- #MPD not available in Jessie Repo for ARMv8
+ # MPD not available in Jessie repo for ARMv8
if (( $G_HW_ARCH == 3 )); then
- #libupnp6 for net discov with upnp/avahi
+ # libupnp6 for net discov with upnp/avahi
DEPS_LIST='libupnp6 libwrap0 libmpdclient2 libao-common libao4 libasound2 libasound2-data libasyncns0 libaudiofile1 libavahi-client3 libavahi-common-data libavahi-common3 libavcodec56 libavformat56 libavresample2 libavutil54 libbinio1ldbl libcaca0 libcdio-cdda1 libcdio-paranoia1 libcdio13 libcups2 libcurl3-gnutls libdirectfb-1.2-9 libdnet libfaad2 libflac8 libfluidsynth1 libgme0 libgomp1 libgsm1 libice6 libid3tag0 libiso9660-8 libjack-jackd2-0 libjson-c2 libldb1 libmad0 libmikmod3 libmms0 libmodplug1 libmp3lame0 libmpcdec6 libmpg123-0 libnfs4 libntdb1 libogg0 libopenal-data libopenal1 libopenjpeg5 libopus0 liborc-0.4-0 libpulse0 libresid-builder0c2a libroar2 libsamplerate0 libschroedinger-1.0-0 libsdl1.2debian libshout3 libsidplay2 libsidutils0 libslp1 libsm6 libsmbclient libsndfile1 libsoxr0 libspeex1 libspeexdsp1 libsqlite3-0 libtalloc2 libtdb1 libtevent0 libtheora0 libupnp6 libva1 libvorbis0a libvorbisenc2 libvorbisfile3 libvpx1 libwavpack1 libwbclient0 libwildmidi-config libwildmidi1 libx11-6 libx11-data libx11-xcb1 libx264-142 libxau6 libxcb1 libxdmcp6 libxext6 libxi6 libxtst6 libxvidcore4 libyajl2 libzzip-0-13 mime-support python python-talloc python2.7 samba-libs x11-common file'
- Download_Install 'https://dietpi.com/downloads/binaries/all/mpd_0.19.21_arm64.deb'
+ Download_Install 'https://dietpi.com/downloads/binaries/all/mpd_0.20.18-1_armv8.deb'
else
@@ -3645,49 +3602,23 @@ We work around this error by running APT a second time. Please do not worry and
#Stretch
elif (( $G_DISTRO == 4 )); then
- INSTALL_URL_ADDRESS='https://dietpi.com/downloads/binaries/all/mpd_0.20.21-1_'
- #armv6
- if (( $G_HW_ARCH == 1 )); then
-
- INSTALL_URL_ADDRESS+='armv6.deb'
-
- #armv7+
- elif (( $G_HW_ARCH == 2 )); then
-
- INSTALL_URL_ADDRESS+='armv7.deb'
-
- #ARMv8
- elif (( $G_HW_ARCH == 3 )); then
-
- INSTALL_URL_ADDRESS+='armv8.deb'
-
- #x86_64
- elif (( $G_HW_ARCH == 10 )); then
-
- INSTALL_URL_ADDRESS+='amd64.deb'
-
- fi
-
- apt-mark unhold mpd &> /dev/null #??? Not required for dpkg -i installs
-
- DEPS_LIST='libsqlite3-0 libupnp6 libwrap0 libmpdclient2 libflac8 libyajl2 libavahi-client3 libvorbisfile3 libwavpack1 libmad0 libmpg123-0 libopus0 libavformat57 libfaad2 libcdio-paranoia1 libiso9660-8 libshout3 libid3tag0'
- Download_Install "$INSTALL_URL_ADDRESS"
-
- apt-mark hold mpd # prevent repo updates from overwriting
+ DEPS_LIST='libnfs8 libsmbclient libsqlite3-0 libupnp6 libwrap0 libmpdclient2 libflac8 libyajl2 libavahi-client3 libvorbisfile3 libwavpack1 libmad0 libmpg123-0 libopus0 libavformat57 libfaad2 libcdio-paranoia1 libiso9660-8 libshout3 libid3tag0'
+ Download_Install "https://dietpi.com/downloads/binaries/all/mpd_0.20.23-1_$G_HW_ARCH_DESCRIPTION.deb"
+ # Prevent APT repo updates from overwriting
+ apt-mark hold mpd
#Buster+
else
# libcdio-paranoia1 and libiso9660-8 not available, but ibcdio-paranoia2 and libiso9660-11 instead
- # Buster repo version > 0.20.18, thus stay with APT for now:
+ # Buster repo version >= 0.20.23, thus stay with APT for now:
G_AGI mpd
fi
fi
- #Forums PHPBB
- software_id=54
+ software_id=54 # Forums phpBB
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
@@ -3701,7 +3632,7 @@ We work around this error by running APT a second time. Please do not worry and
else
- Download_Install 'https://www.phpbb.com/files/release/phpBB-3.2.4.tar.bz2' /var/www
+ Download_Install 'https://www.phpbb.com/files/release/phpBB-3.2.5.tar.bz2' /var/www
fi
@@ -3789,7 +3720,7 @@ _EOF_
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
- DEPS_LIST="$PHP_APT_PACKAGE_NAME-intl" # https://doc.owncloud.org/server/latest/admin_manual/installation/source_installation.html#php-extensions
+ DEPS_LIST="$PHP_APT_PACKAGE_NAME-intl" # https://doc.owncloud.org/server/administration_manual/installation/manual_installation.html#php-extensions
if [[ -f /var/www/owncloud/occ ]]; then
@@ -3808,7 +3739,7 @@ _EOF_
else
- Download_Install 'https://download.owncloud.org/community/owncloud-latest.zip' /var/www
+ Download_Install 'https://download.owncloud.org/community/owncloud-latest.tar.bz2' /var/www
fi
@@ -3825,7 +3756,7 @@ _EOF_
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
- DEPS_LIST="$PHP_APT_PACKAGE_NAME-intl" # https://docs.nextcloud.com/server/13/admin_manual/installation/source_installation.html#prerequisites-label
+ DEPS_LIST="$PHP_APT_PACKAGE_NAME-intl" # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
if [[ -f /var/www/nextcloud/occ ]]; then
@@ -3845,11 +3776,11 @@ _EOF_
elif (( $G_DISTRO < 4 )); then
G_DIETPI-NOTIFY 2 'PHP5 support was dropped with NC14, latest NC13 will be installed instead'
- Download_Install 'https://download.nextcloud.com/server/releases/latest-13.zip' /var/www
+ Download_Install 'https://download.nextcloud.com/server/releases/latest-13.tar.bz2' /var/www
else
- Download_Install 'https://download.nextcloud.com/server/releases/latest.zip' /var/www
+ Download_Install 'https://download.nextcloud.com/server/releases/latest.tar.bz2' /var/www
fi
@@ -3878,6 +3809,32 @@ _EOF_
Banner_Installing
+ # Jessie: https://github.com/Fourdee/DietPi/issues/1620#issuecomment-373086888
+ if (( $G_DISTRO == 3 )); then
+
+ INSTALL_URL_ADDRESS='https://dietpi.com/downloads/binaries/all/libssl1.1_1.1.0f-3+deb9u1_'
+
+ # - ARMv7
+ if (( $G_HW_ARCH < 3 )); then
+
+ INSTALL_URL_ADDRESS+='armhf.deb'
+
+ # - ARM64
+ elif (( $G_HW_ARCH == 3 )); then
+
+ INSTALL_URL_ADDRESS+='arm64.deb'
+
+ # - x86_64
+ elif (( $G_HW_ARCH == 10 )); then
+
+ INSTALL_URL_ADDRESS+='amd64.deb'
+
+ fi
+
+ Download_Install "$INSTALL_URL_ADDRESS"
+
+ fi
+
Download_Install 'https://dietpi.com/downloads/binaries/all/ympd_1.2.3.7z'
local binary_name='ympd_'
@@ -3902,7 +3859,17 @@ _EOF_
binary_name+='amd64'
fi
- binary_name+="_$G_DISTRO_NAME"
+
+ # Buster workaround, since we have no Buster binaries yet
+ if (( $G_DISTRO > 3 )); then
+
+ binary_name+='_stretch'
+
+ else
+
+ binary_name+="_$G_DISTRO_NAME"
+
+ fi
mv "$binary_name" /usr/bin/ympd
chmod +x /usr/bin/ympd
@@ -4012,9 +3979,13 @@ _EOF_
INSTALL_URL_ADDRESS='https://apt.mopidy.com/mopidy.gpg'
G_CHECK_URL "$INSTALL_URL_ADDRESS"
+ # Install our config file only, if not yet existent, to preserve manual user config.
+ # - This needs to be done prior to APT install, since this would otherwise install a default config file as well.
+ [[ -f /etc/mopidy/mopidy.conf ]] || dps_index=$software_id Download_Install 'mopidy.conf' /etc/mopidy/mopidy.conf
+
wget -q -O - "$INSTALL_URL_ADDRESS" | apt-key add -
# No Buster list available yet, use stretch.list for testing:
- if (( $G_DISTRO > 4 )); then
+ if (( $G_DISTRO > 3 )); then
wget https://apt.mopidy.com/stretch.list -O /etc/apt/sources.list.d/mopidy.list
@@ -4102,26 +4073,27 @@ _EOF_
Banner_Installing
- #x32 x64
- if (( $G_HW_MODEL == 20 || $G_HW_MODEL == 21 )); then
+ #x86_x64
+ if (( $G_HW_ARCH == 10 )); then
- INSTALL_URL_ADDRESS="https://dietpi.com/downloads/binaries/all/noip_x32_x64.zip"
+ INSTALL_URL_ADDRESS='https://dietpi.com/downloads/binaries/all/noip_x32_x64.zip'
#ARMv8
- elif (( ( $G_HW_MODEL == 12 ) || ( $G_HW_MODEL >= 40 && $G_HW_MODEL < 50 ) )); then
+ elif (( $G_HW_ARCH == 3 )); then
- INSTALL_URL_ADDRESS="https://dietpi.com/downloads/binaries/all/noip_arm64.zip"
+ INSTALL_URL_ADDRESS='https://dietpi.com/downloads/binaries/all/noip_arm64.zip'
- #armv6+
+ #ARMv6/7
else
- INSTALL_URL_ADDRESS="https://dietpi.com/downloads/binaries/all/noip_armhf.zip"
+ INSTALL_URL_ADDRESS='https://dietpi.com/downloads/binaries/all/noip_armhf.zip'
fi
- #NoIp Binary install
+ #NoIp binary install
Download_Install "$INSTALL_URL_ADDRESS"
+ mkdir -p /usr/local/bin
mv noip_binary /usr/local/bin/noip2
chmod +x /usr/local/bin/noip2
@@ -4137,7 +4109,7 @@ _EOF_
G_BACKUP_FP $G_FP_DIETPI_USERDATA/amiberry/conf/autostart.uae
DEPS_LIST='libmpg123-0 libxml2 mpeg2dec libmpeg2-4 libsndio6.1'
- Download_Install 'https://dietpi.com/downloads/binaries/all/amiberry_v2.19.7z' $G_FP_DIETPI_USERDATA
+ Download_Install 'https://dietpi.com/downloads/binaries/all/amiberry_v2.24.7z' $G_FP_DIETPI_USERDATA
fi
@@ -4311,8 +4283,7 @@ _EOF_
fi
- #PIHOLE
- software_id=93
+ software_id=93 # Pi-hole
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
@@ -4339,17 +4310,21 @@ _EOF_
fi
- #AirSonic
- software_id=33
+ software_id=33 # Airsonic
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
- Download_Install 'https://dietpi.com/downloads/binaries/all/airsonic.7z' $G_FP_DIETPI_USERDATA/airsonic
+
+ INSTALL_URL_ADDRESS='https://api.github.com/repos/airsonic/airsonic/releases/latest'
+ G_CHECK_URL "$INSTALL_URL_ADDRESS" #full filepath below, returns --spider error :(
+ INSTALL_URL_ADDRESS=$(curl -s "$INSTALL_URL_ADDRESS" | grep -m1 'browser_download_url.*\.war"' | cut -d \" -f 4)
+
+ mkdir -p $G_FP_DIETPI_USERDATA/airsonic
+ wget "$INSTALL_URL_ADDRESS" -O $G_FP_DIETPI_USERDATA/airsonic/airsonic.war
fi
- #SUBSONIC 6
- software_id=34
+ software_id=34 # Subsonic
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
@@ -4369,11 +4344,7 @@ _EOF_
fi
#WEBIOPI requires RPIGPIO
- if (( ${aSOFTWARE_INSTALL_STATE[71]} == 1 )); then
-
- aSOFTWARE_INSTALL_STATE[69]=1
-
- fi
+ (( ${aSOFTWARE_INSTALL_STATE[71]} == 1 )) && aSOFTWARE_INSTALL_STATE[69]=1
#RPIGPIO
software_id=69
@@ -4437,11 +4408,7 @@ _EOF_
local package_list='python python3'
# - RPi, pre-reqs GPIO control for Node-Red
- if (( $G_HW_MODEL < 10 )); then
-
- package_list+=' python-rpi.gpio'
-
- fi
+ (( $G_HW_MODEL < 10 )) && package_list+=' python-rpi.gpio'
G_AGI $package_list
# - Serialport fails to build unless below flags are provided
@@ -4467,17 +4434,17 @@ _EOF_
INSTALL_URL_ADDRESS='https://api.github.com/repos/blynkkk/blynk-server/releases/latest'
G_CHECK_URL "$INSTALL_URL_ADDRESS"
- useradd -rM blynk -G dietpi -s /usr/sbin/nologin
- mkdir -p $G_FP_DIETPI_USERDATA/blynk
-
- INSTALL_URL_ADDRESS=$(curl -s $INSTALL_URL_ADDRESS | grep -m1 'browser_download_url' | cut -d \" -f 4)
- G_RUN_CMD wget "$INSTALL_URL_ADDRESS" -O $G_FP_DIETPI_USERDATA/blynk/blynkserver.jar
+ INSTALL_URL_ADDRESS=$(curl -s "$INSTALL_URL_ADDRESS" | grep -m1 'browser_download_url' | cut -d \" -f 4)
+ mkdir -p $G_FP_DIETPI_USERDATA/blynk/data
+ G_THREAD_START wget "$INSTALL_URL_ADDRESS" -O $G_FP_DIETPI_USERDATA/blynk/blynkserver.jar
# - Install Blynk JS Libary
G_AGI python
npm i -g --unsafe-perm onoff
npm i -g --unsafe-perm blynk-library
+ G_THREAD_WAIT
+
fi
#NAA Daemon
@@ -4503,17 +4470,17 @@ _EOF_
# - ARMv6/7
if (( $G_HW_ARCH <= 2 )); then
- apackages+=('https://www.signalyst.eu/bins/naa/linux/stretch/networkaudiod_3.5.4-38_armhf.deb')
+ apackages+=('https://www.signalyst.eu/bins/naa/linux/stretch/networkaudiod_3.5.5-39_armhf.deb')
# - ARMv8
elif (( $G_HW_ARCH == 3 )); then
- apackages+=('https://www.signalyst.eu/bins/naa/linux/xenial/networkaudiod_3.5.4-38_arm64.deb')
+ apackages+=('https://www.signalyst.eu/bins/naa/linux/xenial/networkaudiod_3.5.5-39_arm64.deb')
# - x86_64
else
- apackages+=('https://www.signalyst.eu/bins/naa/linux/stretch/networkaudiod_3.5.4-38_amd64.deb')
+ apackages+=('https://www.signalyst.eu/bins/naa/linux/stretch/networkaudiod_3.5.5-39_amd64.deb')
fi
@@ -4591,11 +4558,7 @@ _EOF_
#LCD panels can be enabled in Dietpi-config > display options
# XU4 enable cloudshell
- if (( $G_HW_MODEL == 11 )); then
-
- /DietPi/dietpi/func/dietpi-set_hardware lcdpanel odroid-cloudshell
-
- fi
+ (( $G_HW_MODEL == 11 )) && /DietPi/dietpi/func/dietpi-set_hardware lcdpanel odroid-cloudshell
fi
@@ -4670,7 +4633,7 @@ _EOF_
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
- Download_Install 'https://wordpress.org/latest.zip' /var/www
+ Download_Install 'https://wordpress.org/latest.tar.gz' /var/www
fi
@@ -4723,17 +4686,6 @@ _EOF_
Banner_Installing
- # INSTALL_URL_ADDRESS='https://www.realvnc.com/download/binary/latest/debian/arm/'
- # G_CHECK_URL "$INSTALL_URL_ADDRESS"
-
- # wget "$INSTALL_URL_ADDRESS" -O package.tar.gz
- # G_RUN_CMD tar xvf package.tar.gz
- # rm package.tar.gz
-
- # dpkg -i VNC*.deb
-
- # rm VNC*.deb
-
# - Available in Raspbian apt
G_AGI realvnc-vnc-server
@@ -4761,7 +4713,7 @@ _EOF_
G_CHECK_URL "$INSTALL_URL_ADDRESS"
curl -sL "$INSTALL_URL_ADDRESS" | apt-key add -
- echo -e "deb https://repos.influxdata.com/debian $G_DISTRO_NAME stable" > /etc/apt/sources.list.d/influxdb.list
+ echo "deb https://repos.influxdata.com/debian $G_DISTRO_NAME stable" > /etc/apt/sources.list.d/influxdb.list
G_AGUP
G_AGI influxdb
@@ -4774,44 +4726,24 @@ _EOF_
Banner_Installing
- if (( $G_HW_ARCH == 10 )); then
-
- INSTALL_URL_ADDRESS='https://packagecloud.io/install/repositories/grafana/stable/script.deb.sh'
- G_CHECK_URL "$INSTALL_URL_ADDRESS"
-
- wget "$INSTALL_URL_ADDRESS" -O $software_id.sh
- chmod +x $software_id.sh
- ./$software_id.sh
-
- rm $software_id.sh
-
- else
+ # APT repo GPG key
+ INSTALL_URL_ADDRESS='https://packages.grafana.com/gpg.key'
+ local deb_address='deb https://packages.grafana.com/oss/deb stable main'
+ if (( $G_HW_ARCH == 1 )); then
INSTALL_URL_ADDRESS='https://bintray.com/user/downloadSubjectPublicKey?username=bintray'
- G_CHECK_URL "$INSTALL_URL_ADDRESS"
-
- curl -sL "$INSTALL_URL_ADDRESS" | apt-key add -
-
- local deb_address=''
- if (( $G_HW_ARCH == 3 )); then
-
- deb_address='https://bintray.com/fg2it/deb-arm64/grafana-on-raspberry/'
-
- elif (( $G_HW_ARCH == 1 )); then
-
- deb_address='https://dl.bintray.com/fg2it/deb-rpi-1b'
-
- else
+ deb_address="deb https://dl.bintray.com/fg2it/deb-rpi-1b $G_DISTRO_NAME main"
- deb_address='https://dl.bintray.com/fg2it/deb'
-
- fi
+ fi
- echo "deb $deb_address $G_DISTRO_NAME main" > /etc/apt/sources.list.d/grafana.list
- G_AGUP
+ G_CHECK_URL "$INSTALL_URL_ADDRESS"
+ curl -sL "$INSTALL_URL_ADDRESS" | apt-key add -
- fi
+ # APT repo source & update
+ echo "$deb_address" > /etc/apt/sources.list.d/grafana.list
+ G_AGUP
+ # APT package
G_AGI grafana
fi
@@ -4920,19 +4852,106 @@ _EOF_
fi
+ #WireGuard
+ software_id=172
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
+
+ Banner_Installing
+
+ # Kernel headers and matching kernel image required for wireguard-dkms to build the wireguard kernel module
+ local kernel_packages=''
+ # - x86_64
+ if (( $G_HW_ARCH == 10 )); then
+
+ kernel_packages='linux-image-amd64 linux-headers-amd64'
+
+ # - RPi
+ elif (( $G_HW_MODEL < 10 )); then
+
+ kernel_packages='raspberrypi-bootloader raspberrypi-kernel libraspberrypi-bin libraspberrypi0 raspberrypi-kernel-headers'
+
+ # - Odroid C1
+ elif (( $G_HW_MODEL == 10 )); then
+
+ kernel_packages='linux-image-armhf-odroid-c1 linux-headers-armhf-odroid-c1'
+
+ # - Odroid XU4
+ elif (( $G_HW_MODEL == 11 )); then
+
+ kernel_packages='linux-image-4.14-armhf-odroid-xu4 linux-headers-4.14-armhf-odroid-xu4'
+
+ # - Odroid C2
+ elif (( $G_HW_MODEL == 12 )); then
+
+ kernel_packages='linux-image-arm64-odroid-c2 linux-headers-arm64-odroid-c2'
+
+ # - Odroid N1
+ elif (( $G_HW_MODEL == 14 )); then
+
+ kernel_packages='linux-image-arm64-odroid-n1 linux-headers-arm64-odroid-n1'
+
+ # - Rock64
+ elif (( $G_HW_MODEL == 43 )); then
+
+ kernel_packages='linux-headers-rockchip64'
+
+ fi
+
+ # Odroids need to purge before we install, else, does not update to latest version...
+ (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )) && G_AGP $kernel_packages
+
+ # Since G_AGUG does not upgrade packages with changed dependencies, in case of kernel image meta packages, those need to be installed via G_AGI.
+ G_AGI $kernel_packages # apt-get install overrides hold state
+
+ # Add Debian "sid" repo, which contains the wireguard packages
+ echo 'deb https://deb.debian.org/debian/ sid main' > /etc/apt/sources.list.d/dietpi-wireguard.list
+ # - Set "sid" priority low enough to only install packages that are not available in main repo(s)
+ echo -e 'Package: *\nPin: release n=sid\nPin-Priority: 99' > /etc/apt/preferences.d/dietpi-wireguard
+ G_AGUP
+
+ # Check for existing WireGuard install
+ local existing_install=0
+ dpkg-query -s wireguard-dkms &> /dev/null && existing_install=1
+
+ # iptables required to forward incoming VPN traffic to internet interface
+ # qrencode required to print client config QR code to console
+ G_AGI wireguard iptables qrencode
+
+ # If no fresh install, reconfigure to rebuild WireGuard kernel module against current kernel headers
+ (( $existing_install )) && G_RUN_CMD dpkg-reconfigure wireguard-dkms
+
+ unset kernel_packages existing_install
+
+ fi
+
+ #DietPi-NordVPN
+ software_id=171
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
+
+ Banner_Installing
+ G_AGI openvpn
+
+ Download_Install 'https://downloads.nordcdn.com/configs/archives/servers/ovpn.zip' /etc/openvpn
+
+ mkdir -p /var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn
+
+ G_WHIP_MSG "DietPi-NordVPN has been installed.\nOnce DietPi-Software has finished all other installations, you can run the GUI using the following command:\n - dietpi-nordvpn"
+
+ fi
+
#LETSENCRYPT
software_id=92
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
- if (( $G_DISTRO >= 4 )); then
+ if (( $G_DISTRO > 3 )); then
- if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[83]} > 0 )); then
G_AGI certbot python-certbot-apache
- elif (( ${aSOFTWARE_INSTALL_STATE[85]} >= 1 )); then
+ elif (( ${aSOFTWARE_INSTALL_STATE[85]} > 0 )); then
G_AGI certbot python-certbot-nginx
@@ -4960,11 +4979,7 @@ _EOF_
fi
#TORHOTSPOT requires WIFIHOTSPOT:
- if (( ${aSOFTWARE_INSTALL_STATE[61]} == 1 )); then
-
- aSOFTWARE_INSTALL_STATE[60]=1
-
- fi
+ (( ${aSOFTWARE_INSTALL_STATE[61]} == 1 )) && aSOFTWARE_INSTALL_STATE[60]=1
#WIFIHOTSPOT
software_id=60
@@ -5040,60 +5055,12 @@ _EOF_
Banner_Installing
- INSTALL_URL_ADDRESS='https://dietpi.com/downloads/binaries/all/shairport-sync_3.1.7_'
+ INSTALL_URL_ADDRESS="https://dietpi.com/downloads/binaries/all/shairport-sync_3.2.2_$G_HW_ARCH_DESCRIPTION.7z"
- # - ARMv6
- if (( $G_HW_ARCH == 1 )); then
-
- INSTALL_URL_ADDRESS+='armv6.7z'
-
- # - ARMv7
- elif (( $G_HW_ARCH == 2 )); then
-
- INSTALL_URL_ADDRESS+='armv7.7z'
-
- # - ARM64
- elif (( $G_HW_ARCH == 3 )); then
-
- INSTALL_URL_ADDRESS+='armv8.7z'
-
- # - x86_64
- elif (( $G_HW_ARCH == 10 )); then
-
- INSTALL_URL_ADDRESS+='amd64.7z'
-
- fi
-
- # This occured on C2: shairport-sync : Depends: libpopt-dev but it is not installed
- #G_AGI libpopt-dev
- DEPS_LIST='openssl libsoxr0 libavahi-client3 libtool libconfig9 libpopt0 libdaemon0'
- Download_Install "$INSTALL_URL_ADDRESS" /
-
- #Jessie: https://github.com/Fourdee/DietPi/issues/1620#issuecomment-373086888
- if (( $G_DISTRO == 3 )); then
-
- INSTALL_URL_ADDRESS='https://dietpi.com/downloads/binaries/all/libssl1.1_1.1.0f-3+deb9u1_'
-
- # - ARMv7
- if (( $G_HW_ARCH == 2 )); then
-
- INSTALL_URL_ADDRESS+='armhf.deb'
-
- # - ARM64
- elif (( $G_HW_ARCH == 3 )); then
-
- INSTALL_URL_ADDRESS+='arm64.deb'
-
- # - x86_64
- elif (( $G_HW_ARCH == 10 )); then
-
- INSTALL_URL_ADDRESS+='amd64.deb'
-
- fi
-
- Download_Install "$INSTALL_URL_ADDRESS"
-
- fi
+ # This occured on C2: shairport-sync : Depends: libpopt-dev but it is not installed
+ #G_AGI libpopt-dev
+ DEPS_LIST='openssl libsoxr0 libavahi-client3 libtool libconfig9 libpopt0 libdaemon0'
+ Download_Install "$INSTALL_URL_ADDRESS" /
fi
@@ -5198,32 +5165,8 @@ _EOF_
Banner_Installing
- INSTALL_URL_ADDRESS='https://dietpi.com/downloads/binaries/all/netdata_1.9.0_'
-
- #armv6
- if (( $G_HW_ARCH == 1 )); then
-
- INSTALL_URL_ADDRESS+='armv6.deb'
-
- #armv7+
- elif (( $G_HW_ARCH == 2 )); then
-
- INSTALL_URL_ADDRESS+='armv7.deb'
-
- #ARMv8
- elif (( $G_HW_ARCH == 3 )); then
-
- INSTALL_URL_ADDRESS+='armv8.deb'
-
- #amd64
- elif (( $G_HW_ARCH == 10 )); then
-
- INSTALL_URL_ADDRESS+='amd64.deb'
-
- fi
-
DEPS_LIST='zlib1g-dev'
- Download_Install "$INSTALL_URL_ADDRESS"
+ Download_Install "https://dietpi.com/downloads/binaries/all/netdata_1.11.1-1_$G_HW_ARCH_DESCRIPTION.deb"
fi
@@ -5287,12 +5230,12 @@ _EOF_
#x86_64
if (( $G_HW_ARCH == 10 )); then
- Download_Install 'https://downloads.plex.tv/plex-media-server/1.13.8.5395-10d48da0d/plexmediaserver_1.13.8.5395-10d48da0d_amd64.deb'
+ Download_Install 'https://downloads.plex.tv/plex-media-server/1.14.0.5470-9d51fdfaa/plexmediaserver_1.14.0.5470-9d51fdfaa_amd64.deb'
#ARM
else
- INSTALL_URL_ADDRESS='http://dev2day.de/pms/'
+ INSTALL_URL_ADDRESS='https://dev2day.de/pms/'
G_CHECK_URL "$INSTALL_URL_ADDRESS"
echo "deb [arch=armhf] $INSTALL_URL_ADDRESS $G_DISTRO_NAME main" > /etc/apt/sources.list.d/plex.list
@@ -5423,26 +5366,19 @@ _EOF_
DEPS_LIST='rtorrent screen' #mediainfo
# On Jessie, nginx-full is needed for SCGI module: https://github.com/Fourdee/DietPi/issues/1240
- (( $G_DISTRO < 4 && ${aSOFTWARE_INSTALL_STATE[85]} >= 1 )) && DEPS_LIST+=' nginx-full'
+ (( $G_DISTRO < 4 && ${aSOFTWARE_INSTALL_STATE[85]} > 0 )) && DEPS_LIST+=' nginx-full'
+
+ # Get current version string
+ INSTALL_URL_ADDRESS='https://api.github.com/repos/Novik/ruTorrent/releases/latest'
+ G_CHECK_URL "$INSTALL_URL_ADDRESS"
+ local version_string=$(curl -s "$INSTALL_URL_ADDRESS" | grep -m1 '^[[:blank:]]*"tag_name":' | cut -d \" -f 4)
- Download_Install 'http://bintray.com/novik65/generic/download_file?file_path=ruTorrent-3.7.zip'
+ Download_Install "https://github.com/Novik/ruTorrent/archive/$version_string.tar.gz"
mkdir -p /var/www/rutorrent
mv ruTorrent-*/* /var/www/rutorrent/
rm -R ruTorrent-*
- #Raspbian "unrar-free" only available in repos
- if (( $G_HW_MODEL < 10 )); then
-
- #G_AGI unrar-free #Does not support all rar formats, better use "unrar-nonfree" from Debian repo
- Download_Install "https://dietpi.com/downloads/binaries/rpi/unrar-armhf-$G_DISTRO_NAME.deb"
-
- else
-
- G_AGI unrar #https://github.com/Fourdee/DietPi/issues/176#issuecomment-240101365
-
- fi
-
fi
#Aria2
@@ -5499,36 +5435,28 @@ _EOF_
fi
- #SICKRAGE
+ #Medusa
software_id=116
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
- DEPS_LIST='python python-pip python-dev python-setuptools libffi-dev libssl-dev libxmlsec1-dev libxml2-dev'
- Download_Install 'https://github.com/SiCKRAGE/SiCKRAGE/archive/master.zip'
+ DEPS_LIST='python'
- mkdir -p $G_FP_DIETPI_USERDATA/sickrage
- cp -R SiCKRAGE-*/* $G_FP_DIETPI_USERDATA/sickrage/
- rm -R SiCKRAGE-*
+ if [[ -d $G_FP_DIETPI_USERDATA/medusa ]]; then
- #Raspbian "unrar-free" only available in repos
- if (( $G_HW_MODEL < 10 )); then
-
- #G_AGI unrar-free #Does not support all rar formats, better use "unrar-nonfree" from Debian repo
- Download_Install "https://dietpi.com/downloads/binaries/rpi/unrar-armhf-$G_DISTRO_NAME.deb"
+ G_AGI $DEPS_LIST
+ G_DIETPI-NOTIFY 2 "${aSOFTWARE_WHIP_NAME[$software_id]} install dir \"$G_FP_DIETPI_USERDATA/medusa\" already exists. Download and install steps will be skipped.
+ - If you want to update ${aSOFTWARE_WHIP_NAME[$software_id]}, please use the internal updater from WebUI.
+ - if you need to reinstall (e.g. broken instance), please manually backup your config files+data, remove the install dir and rerun \"dietpi-software (re)install $software_id\"."
else
- G_AGI unrar #https://github.com/Fourdee/DietPi/issues/176#issuecomment-240101365
+ Download_Install 'https://github.com/pymedusa/Medusa/archive/master.zip' $G_FP_DIETPI_USERDATA
+ mv $G_FP_DIETPI_USERDATA/Medusa-master $G_FP_DIETPI_USERDATA/medusa
fi
- G_RUN_CMD pip install wheel
-
- G_DIETPI-NOTIFY 2 'Installing/building pre-reqs for SiCKRAGE, this can take up to 10 minutes on a NanoPC-T4/RK3399, please wait and do NOT interrupt the process...'
- G_RUN_CMD pip install -r $G_FP_DIETPI_USERDATA/sickrage/requirements.txt
-
fi
#SYNCTHING
@@ -5764,18 +5692,6 @@ _EOF_
mv /etc/sabnzbd/sabnzbd-"$version"/* /etc/sabnzbd/
rm -R /etc/sabnzbd/sabnzbd-"$version"
- #Raspbian "unrar-free" only available in repos
- if (( $G_HW_MODEL < 10 )); then
-
- #G_AGI unrar-free #Does not support all rar formats, better use "unrar-nonfree" from Debian repo
- Download_Install "https://dietpi.com/downloads/binaries/rpi/unrar-armhf-$G_DISTRO_NAME.deb"
-
- else
-
- G_AGI unrar #https://github.com/Fourdee/DietPi/issues/176#issuecomment-240101365
-
- fi
-
pip install cheetah cryptography sabyenc
fi
@@ -5799,16 +5715,10 @@ _EOF_
Banner_Installing
- INSTALL_URL_ADDRESS='https://github.com/CouchPotato/CouchPotatoServer/archive/master.zip'
- G_CHECK_URL "$INSTALL_URL_ADDRESS"
-
- G_AGI libffi-dev libssl-dev python-lxml python3-lxml
-
- wget "$INSTALL_URL_ADDRESS" -O package.zip
- G_RUN_CMD unzip -o package.zip
- rm package.zip
+ DEPS_LIST='libffi-dev libssl-dev python-lxml python3-lxml'
+ Download_Install 'https://github.com/CouchPotato/CouchPotatoServer/archive/master.zip'
- rm -R /etc/couchpotato &> /dev/null
+ [[ -d /etc/couchpotato ]] && rm -R /etc/couchpotato
mv CouchPotato* /etc/couchpotato
pip install --upgrade pyopenssl
@@ -5877,7 +5787,7 @@ _EOF_
INSTALL_URL_ADDRESS='https://api.github.com/repos/Radarr/Radarr/releases'
G_CHECK_URL "$INSTALL_URL_ADDRESS" #full filepath below, returns --spider error :(
- INSTALL_URL_ADDRESS="$(curl -s $INSTALL_URL_ADDRESS | grep -m1 'browser_download_url.*linux.tar.gz' | cut -d \" -f 4)"
+ INSTALL_URL_ADDRESS=$(curl -s "$INSTALL_URL_ADDRESS" | grep -m1 'browser_download_url.*linux.tar.gz' | cut -d \" -f 4)
DEPS_LIST='mediainfo'
no_check_url=1 Download_Install "$INSTALL_URL_ADDRESS" /opt
@@ -5892,7 +5802,7 @@ _EOF_
INSTALL_URL_ADDRESS='https://api.github.com/repos/Lidarr/Lidarr/releases'
G_CHECK_URL "$INSTALL_URL_ADDRESS"
- INSTALL_URL_ADDRESS="$(curl -s $INSTALL_URL_ADDRESS | grep -m1 'browser_download_url.*linux.tar.gz' | cut -d \" -f 4)"
+ INSTALL_URL_ADDRESS=$(curl -s "$INSTALL_URL_ADDRESS" | grep -m1 'browser_download_url.*linux.tar.gz' | cut -d \" -f 4)
DEPS_LIST='mediainfo'
no_check_url=1 Download_Install "$INSTALL_URL_ADDRESS" /opt
@@ -5931,9 +5841,9 @@ _EOF_
Banner_Installing
- INSTALL_URL_ADDRESS='https://api.github.com/repos/Jackett/Jackett/releases'
+ INSTALL_URL_ADDRESS='https://api.github.com/repos/Jackett/Jackett/releases/latest'
G_CHECK_URL "$INSTALL_URL_ADDRESS" #full filepath below, returns --spider error :(
- INSTALL_URL_ADDRESS="$(curl -s $INSTALL_URL_ADDRESS | grep -m1 'browser_download_url.*Jackett.Binaries.Mono.tar.gz' | cut -d \" -f 4)"
+ INSTALL_URL_ADDRESS=$(curl -s "$INSTALL_URL_ADDRESS" | grep -m1 'browser_download_url.*Jackett.Binaries.Mono.tar.gz' | cut -d \" -f 4)
no_check_url=1 Download_Install "$INSTALL_URL_ADDRESS" /opt
@@ -6166,7 +6076,7 @@ Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix
Banner_Installing
- INSTALL_URL_ADDRESS='https://dl.gitea.io/gitea/1.4/gitea-1.4-'
+ INSTALL_URL_ADDRESS='https://dl.gitea.io/gitea/1.7/gitea-1.7-'
#armv6
if (( $G_HW_ARCH == 1 )); then
@@ -6334,7 +6244,7 @@ Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix
Install_Linux_Software(){
- local software_id=0
+ local software_id=-1
software_id=5
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
@@ -6345,10 +6255,10 @@ Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix
#Apply soundcard
local soundcard="$(grep -m1 '^[[:blank:]]*CONFIG_SOUNDCARD=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
+ soundcard=${soundcard:-none}
# - RPi enable internal HDMI+Analogue if currently set to 'none'
- if (( $G_HW_MODEL < 10 )) &&
- [[ $soundcard == 'none' || $soundcard == 'default' ]]; then
+ if (( $G_HW_MODEL < 10 )) && [[ $soundcard == 'none' || $soundcard == 'default' ]]; then
soundcard='rpi-bcm2835-ultrahq'
@@ -6678,8 +6588,8 @@ Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix
Banner_Installing
- #Remove information file
- rm /mnt/nfs_client/readme.txt &> /dev/null
+ # Remove information file
+ [[ -f /mnt/nfs_client/readme.txt ]] && rm /mnt/nfs_client/readme.txt
# "netbase" is needed for mounting NFSv3: https://github.com/Fourdee/DietPi/issues/1898#issuecomment-406247814
G_AGI nfs-common netbase
@@ -6690,43 +6600,66 @@ Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
- G_AGI dropbear
- #set to start on next boot
+ # Mark target SSH server choice, if not selected via menu or first run setup
+ INDEX_SSHSERVER_TARGET=-1
+
+ # Stop OpenSSH service to unbind port 22
+ systemctl -q is-active ssh && systemctl stop ssh
+
+ # On Stretch+ Dropbear packages have been split, install "dropbear-run" only, to have active service, but "skip dropbear-initramfs"
+ if (( $G_DISTRO < 4 )); then
+
+ G_AGI dropbear
+ # ECDSA key is not generated (or converted from OpenSSH) automatically on Jessie
+ [[ -f /etc/dropbear/dropbear_ecdsa_host_key ]] || dropbearkey -t ecdsa -f /etc/dropbear/dropbear_ecdsa_host_key
+
+ else
+
+ G_AGI dropbear-run
+
+ fi
+
+ # Enable Dropbear daemon
G_CONFIG_INJECT 'NO_START=' 'NO_START=0' /etc/default/dropbear
+ # Failsafe: Enable Dropbear service
+ systemctl enable dropbear
+
+ # Mark OpenSSH for uninstall and update choice system
+ dpkg-query -s 'openssh-server' &> /dev/null && aSOFTWARE_INSTALL_STATE[105]=-1 && UNINSTALL_REQUIRED=1
+ INDEX_SSHSERVER_CURRENT=-1
+
fi
software_id=105
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
- G_AGI openssh-server
+ # Mark target SSH server choice, if not selected via menu or first run setup
+ INDEX_SSHSERVER_TARGET=-2
- # - Remove all references before adding the entry: https://github.com/Fourdee/DietPi/issues/604
- sed -i '/PermitRootLogin[[:space:]]/d' /etc/ssh/sshd_config
- echo -e '\n\n#Allow root login over SSH\nPermitRootLogin yes' >> /etc/ssh/sshd_config
+ # Stop Dropbear service to unbind port 22
+ systemctl -q is-active dropbear && systemctl stop dropbear
- #Generate host keys
- # - remove all previous
- rm /etc/ssh/ssh_host_key
- rm /etc/ssh/ssh_host_rsa_key
- rm /etc/ssh/ssh_host_dsa_key
+ G_AGI openssh-server
- # - Generate
- ssh-keygen -f /etc/ssh/ssh_host_key -N '' -t rsa1
- ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N '' -t rsa
- ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa
+ # SSH server package also installs client.
+ aSOFTWARE_INSTALL_STATE[0]=2
- # - Set permissions
- chmod -R 700 /etc/ssh/
+ # Allow root login
+ G_CONFIG_INJECT 'PermitRootLogin[[:blank:]]' 'PermitRootLogin yes' /etc/ssh/sshd_config
- #Restart ssh server now so root users can login during setup.
- systemctl restart ssh
+ # Reload SSH server now so root users can login during setup.
+ systemctl reload ssh
- #SSH server package also installs client.
- aSOFTWARE_INSTALL_STATE[0]=2
+ # Failsafe: Enable OpenSSH service
+ systemctl enable ssh
+
+ # Mark Dropbear for uninstall and update choice system
+ grep -q '^dropbear[^[:blank:]]*[[:blank:]]' <<< "$(dpkg --get-selections)" && aSOFTWARE_INSTALL_STATE[104]=-1 && UNINSTALL_REQUIRED=1
+ INDEX_SSHSERVER_CURRENT=-2
fi
@@ -6736,12 +6669,10 @@ Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix
Banner_Installing
l_message='Copy /var/log skeletons to temporary storage' G_RUN_CMD /DietPi/dietpi/func/dietpi-ramlog 1
- #Install (add tmpfs mount to fstab)
+ # Install (add tmpfs mount to fstab)
local tmpfs_max_size=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_RAMLOG_MAXSIZE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
sed -i '/[[:space:]]\/var\/log[[:space:]]/d' /etc/fstab
- cat << _EOF_ >> /etc/fstab
-tmpfs /var/log tmpfs defaults,size=${tmpfs_max_size}m,noatime,nodev,nosuid,mode=1777 0 0
-_EOF_
+ echo "tmpfs /var/log tmpfs defaults,size=${tmpfs_max_size}m,noatime,nodev,nosuid,mode=1777 0 0" >> /etc/fstab
systemctl enable dietpi-ramlog
fi
@@ -6788,7 +6719,7 @@ _EOF_
fi
- software_id=8
+ software_id=8 # Java
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Installing
@@ -6797,19 +6728,16 @@ _EOF_
if (( $G_DISTRO == 3 )); then
cat << _EOF_ > /etc/apt/preferences.d/99-dietpi-openjdk-8-jdk
-Package: openjdk-8-jdk
+Package: ca-certificates-java java-common openjdk-8-*
Pin: release a=jessie-backports
Pin-Priority: 990
_EOF_
- G_AGI openjdk-8-jdk -t jessie-backports
+ G_AGI openjdk-8-jre-headless openjdk-8-jdk-headless -t jessie-backports
else
- # - Workaround to allow install: https://github.com/Fourdee/DietPi/issues/1340#issuecomment-389902031
- local packages='ca-certificates-java openjdk-8-jre-headless openjdk-8-jdk-headless'
- apt-get install -y -qq $packages
- G_AGI $packages
+ G_AGI openjdk-8-jre-headless openjdk-8-jdk-headless
fi
@@ -6825,6 +6753,7 @@ _EOF_
wget "$INSTALL_URL_ADDRESS" -O node_install.sh
chmod +x node_install.sh
+ mkdir -p /usr/local # failsafe
./node_install.sh
rm node_install.sh
@@ -6936,7 +6865,7 @@ _EOF_
G_DIETPI-NOTIFY 2 "ha_python_version: $ha_python_version"
# Install needed libraries
- G_AGI libssl-dev git cmake libc-ares-dev uuid-dev daemon curl libgnutls28-dev libgnutlsxx28 nmap net-tools sudo libglib2.0-dev libudev-dev swig libssl-dev libusb-1.0-0 gcc libssl-dev libffi-dev libbz2-dev zlib1g-dev libreadline-dev libsqlite3-dev libncurses5-dev libncursesw5-dev
+ G_AGI cmake daemon gcc nmap net-tools swig uuid-dev libc-ares-dev libgnutls28-dev libgnutlsxx28 libglib2.0-dev libudev-dev libusb-1.0-0 libssl-dev libffi-dev libbz2-dev zlib1g-dev libreadline-dev libsqlite3-dev libncurses5-dev libncursesw5-dev
if (( $G_DISTRO < 4 )); then
G_AGI libmysqlclient-dev
@@ -6982,6 +6911,26 @@ _EOF_
fi
+ #Unrar
+ software_id=170
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
+
+ Banner_Installing
+
+ #Raspbian "unrar-free" only available in repos
+ if (( $G_HW_MODEL < 10 )); then
+
+ #G_AGI unrar-free #Does not support all rar formats, better use "unrar-nonfree" from Debian repo
+ Download_Install "https://dietpi.com/downloads/binaries/rpi/unrar-armhf-$G_DISTRO_NAME.deb"
+
+ else
+
+ G_AGI unrar #https://github.com/Fourdee/DietPi/issues/176#issuecomment-240101365
+
+ fi
+
+ fi
+
#-------------------------------------------------------------------
#Reset error handler (eg: for usermsg clear set in Banner_Installing)
G_ERROR_HANDLER_RESET
@@ -6991,43 +6940,31 @@ _EOF_
Apply_SSHServer_Choices(){
- #Work out which SSH Server needs installing from IDs (if any)
+ #Work out which SSH server needs installing from IDs (if any)
#Work out which SSH server needs removing (if any)
if (( $INDEX_SSHSERVER_TARGET != $INDEX_SSHSERVER_CURRENT )); then
- # Run uninstall of old SSH servers, after install loop
- UNINSTALL_REQUIRED=1
-
# - No SSH server
if (( $INDEX_SSHSERVER_TARGET == 0 )); then
- (( aSOFTWARE_INSTALL_STATE[104] == 2 )) && aSOFTWARE_INSTALL_STATE[104]=-1
- (( aSOFTWARE_INSTALL_STATE[105] == 2 )) && aSOFTWARE_INSTALL_STATE[105]=-1
+ # Check currently installed SSH servers via "dpkg --get-selections" to be failsafe
+ local dpkg_out="$(dpkg --get-selections)"
+
+ grep -q '^dropbear[^[:blank:]]*[[:blank:]]' <<< "$dpkg_out" && aSOFTWARE_INSTALL_STATE[104]=-1 && UNINSTALL_REQUIRED=1
+ grep -q '^openssh-server[[:blank:]]' <<< "$dpkg_out" && aSOFTWARE_INSTALL_STATE[105]=-1 && UNINSTALL_REQUIRED=1
# - Dropbear
elif (( $INDEX_SSHSERVER_TARGET == -1 )); then
aSOFTWARE_INSTALL_STATE[104]=1
- (( aSOFTWARE_INSTALL_STATE[105] == 2 )) && aSOFTWARE_INSTALL_STATE[105]=-1
- # - Openssh
+ # - OpenSSH
elif (( $INDEX_SSHSERVER_TARGET == -2 )); then
aSOFTWARE_INSTALL_STATE[105]=1
- (( aSOFTWARE_INSTALL_STATE[104] == 2 )) && aSOFTWARE_INSTALL_STATE[104]=-1
fi
- #Inform user (From testing, stopping SSH server services does not disconnect user, however, just incase it does in the future)
- G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Stopping SSH servers'
-
- #stop all SSH server services
- systemctl stop ssh &> /dev/null
- systemctl stop dropbear &> /dev/null
-
- #Update Current SSHSERVER index
- INDEX_SSHSERVER_CURRENT=$INDEX_SSHSERVER_TARGET
-
fi
}
@@ -7044,20 +6981,20 @@ _EOF_
#No File server
if (( $INDEX_FILESERVER_TARGET == 0 )); then
- (( aSOFTWARE_INSTALL_STATE[94] == 2 )) && aSOFTWARE_INSTALL_STATE[94]=-1
- (( aSOFTWARE_INSTALL_STATE[96] == 2 )) && aSOFTWARE_INSTALL_STATE[96]=-1
+ (( ${aSOFTWARE_INSTALL_STATE[94]} == 2 )) && aSOFTWARE_INSTALL_STATE[94]=-1
+ (( ${aSOFTWARE_INSTALL_STATE[96]} == 2 )) && aSOFTWARE_INSTALL_STATE[96]=-1
#ProFTP
elif (( $INDEX_FILESERVER_TARGET == -1 )); then
aSOFTWARE_INSTALL_STATE[94]=1
- (( aSOFTWARE_INSTALL_STATE[96] == 2 )) && aSOFTWARE_INSTALL_STATE[96]=-1
+ (( ${aSOFTWARE_INSTALL_STATE[96]} == 2 )) && aSOFTWARE_INSTALL_STATE[96]=-1
#Samba
elif (( $INDEX_FILESERVER_TARGET == -2 )); then
aSOFTWARE_INSTALL_STATE[96]=1
- (( aSOFTWARE_INSTALL_STATE[94] == 2 )) && aSOFTWARE_INSTALL_STATE[94]=-1
+ (( ${aSOFTWARE_INSTALL_STATE[94]} == 2 )) && aSOFTWARE_INSTALL_STATE[94]=-1
fi
@@ -7080,30 +7017,30 @@ _EOF_
#None
if (( $INDEX_LOGGING_TARGET == 0 )); then
- (( aSOFTWARE_INSTALL_STATE[101] == 2 )) && aSOFTWARE_INSTALL_STATE[101]=-1
- (( aSOFTWARE_INSTALL_STATE[102] == 2 )) && aSOFTWARE_INSTALL_STATE[102]=-1
- (( aSOFTWARE_INSTALL_STATE[103] == 2 )) && aSOFTWARE_INSTALL_STATE[103]=-1
+ (( ${aSOFTWARE_INSTALL_STATE[101]} == 2 )) && aSOFTWARE_INSTALL_STATE[101]=-1
+ (( ${aSOFTWARE_INSTALL_STATE[102]} == 2 )) && aSOFTWARE_INSTALL_STATE[102]=-1
+ (( ${aSOFTWARE_INSTALL_STATE[103]} == 2 )) && aSOFTWARE_INSTALL_STATE[103]=-1
#Ramlog - clear every hour
elif (( $INDEX_LOGGING_TARGET == -1 )); then
aSOFTWARE_INSTALL_STATE[103]=1
- (( aSOFTWARE_INSTALL_STATE[101] == 2 )) && aSOFTWARE_INSTALL_STATE[101]=-1
- (( aSOFTWARE_INSTALL_STATE[102] == 2 )) && aSOFTWARE_INSTALL_STATE[102]=-1
+ (( ${aSOFTWARE_INSTALL_STATE[101]} == 2 )) && aSOFTWARE_INSTALL_STATE[101]=-1
+ (( ${aSOFTWARE_INSTALL_STATE[102]} == 2 )) && aSOFTWARE_INSTALL_STATE[102]=-1
#Ramlog - backup every 1H to $HOME/logfile_storage, then clear.
elif (( $INDEX_LOGGING_TARGET == -2 )); then
aSOFTWARE_INSTALL_STATE[103]=1
- (( aSOFTWARE_INSTALL_STATE[101] == 2 )) && aSOFTWARE_INSTALL_STATE[101]=-1
- (( aSOFTWARE_INSTALL_STATE[102] == 2 )) && aSOFTWARE_INSTALL_STATE[102]=-1
+ (( ${aSOFTWARE_INSTALL_STATE[101]} == 2 )) && aSOFTWARE_INSTALL_STATE[101]=-1
+ (( ${aSOFTWARE_INSTALL_STATE[102]} == 2 )) && aSOFTWARE_INSTALL_STATE[102]=-1
#Logrotate + rsyslog - logs to disk
elif (( $INDEX_LOGGING_TARGET == -3 )); then
aSOFTWARE_INSTALL_STATE[101]=1
aSOFTWARE_INSTALL_STATE[102]=1
- (( aSOFTWARE_INSTALL_STATE[103] == 2 )) && aSOFTWARE_INSTALL_STATE[103]=-1
+ (( ${aSOFTWARE_INSTALL_STATE[103]} == 2 )) && aSOFTWARE_INSTALL_STATE[103]=-1
fi
@@ -7167,7 +7104,7 @@ _EOF_
# Copy/Set optimised Software settings.
# Set install states to 2 (installed).
- local software_id=0
+ local software_id=-1
#DESKTOP_LXDE
software_id=23
@@ -7191,14 +7128,11 @@ _EOF_
G_THREAD_START wget https://raw.githubusercontent.com/Fourdee/DietPi/$G_GITBRANCH/.conf/desktop/lxde/lxde-rc.xml -O $HOME/.config/openbox/lxde-rc.xml
# - Remove Lxrandr Menu item (monitor configuration tool as we set res in dietpi-config)
- rm /usr/share/applications/lxrandr.desktop &> /dev/null
+ [[ -f /usr/share/applications/lxrandr.desktop ]] && rm /usr/share/applications/lxrandr.desktop
# - Disable Trash
G_CONFIG_INJECT 'use_trash=' 'use_trash=0' /etc/xdg/libfm/libfm.conf
- # - file manager desktop icon
- ln -sf /usr/share/applications/pcmanfm.desktop $HOME/Desktop/pcmanfm.desktop
-
# - Firefox optimizations
# ??? These keep adding new entries, ignore existing entry???
# G_CONFIG_INJECT 'extensions.update.enabled' 'pref("extensions.update.enabled", false);' /etc/firefox-esr/firefox-esr.js
@@ -7210,6 +7144,9 @@ _EOF_
Create_Desktop_Shared_Items
+ # - file manager desktop icon
+ ln -sf /usr/share/applications/pcmanfm.desktop $HOME/Desktop/pcmanfm.desktop
+
fi
#Desktop MATE
@@ -7218,16 +7155,15 @@ _EOF_
Banner_Configuration
+ Create_Desktop_Shared_Items
+
# - file manager desktop icon
ln -sf /usr/share/applications/caja.desktop $HOME/Desktop/caja.desktop
- Create_Desktop_Shared_Items
-
#Odroid C2, define default pulseaudio sink: https://github.com/Fourdee/DietPi/issues/415
- if (( $G_HW_MODEL == 12 )) &&
- ! grep -qi '^set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo' /etc/pulse/default.pa; then
+ if (( $G_HW_MODEL == 12 )); then
- echo 'set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo' >> /etc/pulse/default.pa
+ G_CONFIG_INJECT 'set-default-sink[[:blank:]]' 'set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo' /etc/pulse/default.pa
fi
@@ -7238,7 +7174,6 @@ _EOF_
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Configuration
-
Create_Desktop_Shared_Items
fi
@@ -7248,7 +7183,6 @@ _EOF_
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Configuration
-
Create_Desktop_Shared_Items
fi
@@ -7322,7 +7256,7 @@ _EOF_
Banner_Configuration
# Custom confs, included by sites-enabled/default within server directive, while nginx/(conf.d|sites-enabled) is included by nginx.conf outside server directive
- mkdir /etc/nginx/sites-dietpi
+ mkdir -p /etc/nginx/sites-dietpi
G_BACKUP_FP /etc/nginx/nginx.conf
dps_index=$software_id Download_Install 'nginx.conf' /etc/nginx/nginx.conf
@@ -7360,16 +7294,8 @@ _EOF_
sed -i '/^server.document-root/c\server.document-root = "/var/www"' /etc/lighttpd/lighttpd.conf
#Configure fastcgi for PHP-FPM
- local fp_php_fpm_sock='/var/run/php/php7.0-fpm.sock'
- if (( $G_DISTRO < 4 )); then
-
- fp_php_fpm_sock='/var/run/php5-fpm.sock'
-
- elif (( $G_DISTRO > 4 )); then
-
- fp_php_fpm_sock='/var/run/php/php7.3-fpm.sock'
-
- fi
+ local fp_php_fpm_sock="/var/run/php/$PHP_APT_PACKAGE_NAME-fpm.sock"
+ (( $G_DISTRO < 4 )) && fp_php_fpm_sock='/var/run/php5-fpm.sock'
cat << _EOF_ > /etc/lighttpd/conf-available/15-fastcgi-php.conf
# -*- depends: fastcgi -*-
@@ -7626,13 +7552,13 @@ This is required, since the ${aSOFTWARE_WHIP_NAME[$software_id]} server node by
# - service
cat << _EOF_ > /etc/systemd/system/openbazaar.service
[Unit]
-Description=OpenBazaar
+Description=OpenBazaar (DietPi)
[Service]
Type=simple
Environment=GOPATH=$G_FP_DIETPI_USERDATA/go
WorkingDirectory=$G_FP_DIETPI_USERDATA/go
-ExecStart=$(which openbazaar-go) start -d $G_FP_DIETPI_USERDATA/openbazaar
+ExecStart=$(command -v openbazaar-go) start -d $G_FP_DIETPI_USERDATA/openbazaar
[Install]
WantedBy=multi-user.target
@@ -7650,7 +7576,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/yacy.service
[Unit]
-Description=DietPi YaCy Service
+Description=YaCy (DietPi)
[Service]
Type=simple
@@ -7686,14 +7612,14 @@ _EOF_
# Create new systemd service
cat << _EOF_ > /lib/systemd/system/fahclient.service
[Unit]
-Description=Folding@Home (DietPi service)
+Description=Folding@Home (DietPi)
[Service]
Type=simple
User=fahclient
Group=dietpi
WorkingDirectory=$G_FP_DIETPI_USERDATA/fahclient
-ExecStart=$(which FAHClient) --allow='0/0' --web-allow='0/0' --daemon=false --user=DietPi --team=234437 --passkey=06c869246e88c00cb05cc4d1758a97f9 --gpu=true --log-rotate=false --log=/var/log/fahclient.log --power=light --data-directory=$G_FP_DIETPI_USERDATA/fahclient
+ExecStart=$(command -v FAHClient) --allow='0/0' --web-allow='0/0' --daemon=false --user=DietPi --team=234437 --passkey=06c869246e88c00cb05cc4d1758a97f9 --gpu=true --log-rotate=false --log=/var/log/fahclient.log --power=light --data-directory=$G_FP_DIETPI_USERDATA/fahclient
[Install]
WantedBy=multi-user.target
@@ -7708,21 +7634,17 @@ _EOF_
Banner_Configuration
- G_DIETPI-NOTIFY 2 'Enabling needed PHP modules.' # https://doc.owncloud.org/server/latest/admin_manual/installation/source_installation.html#php-extensions
+ G_DIETPI-NOTIFY 2 'Enabling needed PHP modules.' # https://doc.owncloud.org/server/administration_manual/installation/manual_installation.html#php-extensions
${PHP_BINARY}enmod curl gd intl json pdo_mysql opcache apcu redis
# Following modules are switchable since Stretch:
- if (( $G_DISTRO > 3 )); then
-
- phpenmod ctype dom fileinfo iconv mbstring posix simplexml xmlwriter xmlreader zip exif
-
- fi
+ (( $G_DISTRO > 3 )) && phpenmod ctype dom fileinfo iconv mbstring posix simplexml xmlwriter xmlreader zip exif
G_DIETPI-NOTIFY 2 'Enabling APCu memory cache for PHP command line usage (CLI) as well, including ownCloud occ command and cron jobs.'
G_CONFIG_INJECT 'apc.enable_cli[[:blank:]=]' 'apc.enable_cli=1' "$FP_PHP_BASE_DIR/mods-available/apcu.ini"
if (( ${aSOFTWARE_INSTALL_STATE[83]} > 0 )); then
- G_DIETPI-NOTIFY 2 'Apache webserver found, enabling ownCloud specific configuration.' # https://doc.owncloud.org/server/latest/admin_manual/installation/source_installation.html#configure-apache-web-server
+ G_DIETPI-NOTIFY 2 'Apache webserver found, enabling ownCloud specific configuration.' # https://doc.owncloud.org/server/administration_manual/installation/manual_installation.html#configure-apache-web-server
a2enmod rewrite headers env dir mime 1> /dev/null
local owncloud_conf='/etc/apache2/sites-available/dietpi-owncloud.conf'
if [[ -f $owncloud_conf ]]; then
@@ -7732,7 +7654,7 @@ _EOF_
fi
dps_index=$software_id Download_Install 'apache.owncloud.conf' $owncloud_conf
- a2ensite owncloud 1> /dev/null
+ a2ensite dietpi-owncloud 1> /dev/null
# Cal/CardDAV redirects to ownCloud DAV endpoint
if [[ ! -f /etc/apache2/conf-available/dietpi-dav_redirect.conf ]]; then
@@ -7746,6 +7668,31 @@ Redirect permanent /.well-known/caldav /owncloud/remote.php/dav' > /etc/apache2/
elif (( ${aSOFTWARE_INSTALL_STATE[84]} > 0 )); then
G_DIETPI-NOTIFY 2 'Lighttpd webserver found, enabling ownCloud specific configuration.'
+
+ # Enable required modules
+ G_CONFIG_INJECT '"mod_access",' ' "mod_access",' /etc/lighttpd/lighttpd.conf '"mod_.+",'
+ G_CONFIG_INJECT '"mod_setenv",' ' "mod_setenv",' /etc/lighttpd/lighttpd.conf '"mod_.+",'
+ if (( $G_DISTRO < 4 )); then
+
+ G_CONFIG_INJECT '"mod_rewrite",' ' "mod_rewrite",' /etc/lighttpd/lighttpd.conf '"mod_.+",'
+
+ else
+
+ lighttpd-enable-mod rewrite
+
+ fi
+
+ # Move ownCloud configuration file in place and activate it
+ owncloud_conf='/etc/lighttpd/conf-available/99-dietpi-owncloud.conf'
+ if [[ -f $owncloud ]]; then
+
+ owncloud_conf+='.dietpi-new'
+ G_WHIP_MSG "Existing ownCloud Lighttpd configuration found, will preserve the old one and save the new one for review and comparison to: $nextcloud_conf"
+
+ fi
+ dps_index=$software_id Download_Install 'lighttpd.owncloud.conf' $owncloud_conf
+ lighttpd-enable-mod dietpi-owncloud
+
# Cal/CardDAV redirects to ownCloud DAV endpoint
if [[ ! -f /etc/lighttpd/conf-enabled/99-dietpi-dav_redirect.conf ]]; then
@@ -7760,7 +7707,7 @@ url.redirect = (
elif (( ${aSOFTWARE_INSTALL_STATE[85]} > 0 )); then
- G_DIETPI-NOTIFY 2 'Nginx webserver found, enabling ownCloud specific configuration.' # https://doc.owncloud.org/server/latest/admin_manual/installation/nginx_configuration.html#owncloud-in-a-subdir-of-nginx
+ G_DIETPI-NOTIFY 2 'Nginx webserver found, enabling ownCloud specific configuration.' # https://doc.owncloud.org/server/administration_manual/installation/nginx_configuration.html
local owncloud_conf='/etc/nginx/sites-dietpi/dietpi-owncloud.conf'
if [[ -f $owncloud_conf ]]; then
@@ -7772,24 +7719,20 @@ url.redirect = (
dps_index=$software_id Download_Install 'nginx.owncloud.conf' $owncloud_conf
# Stretch: Set 'fastcgi_request_buffering off';
- if (( $G_DISTRO > 3 )); then
-
- sed -i 's/#fastcgi_request_buffering off;/fastcgi_request_buffering off;/g' $owncloud_conf
-
- fi
+ (( $G_DISTRO > 3 )) && sed -i 's/#fastcgi_request_buffering off;/fastcgi_request_buffering off;/g' $owncloud_conf
- # Set HTTPS on, if SSL connection is available, even with self-signed/untrusted certificate.
- wget -q --spider --timeout=10 --tries=2 https://localhost &> /dev/null
- if (( $? == 0 || $? == 5)); then
+ # Uncomment HSTS header, if chosen via dietpi-letsencrypt and HTTPS connection test succeeds (incl. self-singed cert => exit code 5)
+ if [[ -f /DietPi/dietpi/.dietpi-letsencrypt && $(sed -n 4p /DietPi/dietpi/.dietpi-letsencrypt) == 1 ]]; then
- sed -i 's/#fastcgi_param HTTPS on;/fastcgi_param HTTPS on;/g' $owncloud_conf
+ wget -q --spider --timeout=10 --tries=2 https://localhost &> /dev/null
+ (( $? == 0 || $? == 5)) && sed -i 's/#add_header Strict-Transport-Security/add_header Strict-Transport-Security/g' $owncloud_conf
fi
# Disable pretty URLs (front controller), if ownCloud version is lower than 10:
if (( $(grep '$OC_VersionString' /var/www/owncloud/version.php | sed "s/^.*= '//" | sed "s/\..*$//") < 10 )); then
- sed -i 's/^[[:blank:]]*fastcgi_param front_controller_active true;/\t#fastcgi_param front_controller_active true;/g' $owncloud_conf
+ sed -i 's/^[[:blank:]]*fastcgi_param front_controller_active true;/\t\t#fastcgi_param front_controller_active true;/g' $owncloud_conf
fi
@@ -7808,10 +7751,10 @@ location = /.well-known/caldav {
fi
- G_DIETPI-NOTIFY 2 'Enable 4-byte support for MariaDB.' # https://doc.owncloud.org/server/latest/admin_manual/configuration/database/linux_database_configuration.html#configure-mysql-for-4-byte-unicode-support
+ G_DIETPI-NOTIFY 2 'Enable 4-byte support for MariaDB.' # https://doc.owncloud.org/server/administration_manual/configuration/database/linux_database_configuration.html#configure-mysql-for-4-byte-unicode-support
local fp_mariadb_conf='/etc/mysql/mariadb.conf.d'
# On Jessie (MariaDB 10.0), /etc/mysql/mariadb.conf.d does not yet exist
- (( G_DISTRO < 4 )) && fp_mariadb_conf='/etc/mysql/conf.d'
+ (( $G_DISTRO < 4 )) && fp_mariadb_conf='/etc/mysql/conf.d'
cat << _EOF_ > $fp_mariadb_conf/99-dietpi-4byte.cnf
[mysqld]
innodb_large_prefix=1
@@ -7822,6 +7765,9 @@ collation-server=utf8mb4_general_ci
_EOF_
G_RUN_CMD systemctl restart $MARIADB_SERVICE
+ # Start redis-server, which is required for ncc command:
+ G_RUN_CMD systemctl start redis-server
+
# Initially add occ command shortcut, will be done by Dietpi-Globals automatically, if occ file exist:
occ(){ sudo -u www-data php /var/www/owncloud/occ "$@"; }
@@ -7907,7 +7853,7 @@ _EOF_
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
+ G_DIETPI-NOTIFY 2 'Enabling Redis for transactional file locking.' # https://doc.owncloud.org/server/administration_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!
@@ -7935,19 +7881,15 @@ _EOF_
Banner_Configuration
- G_DIETPI-NOTIFY 2 'Enabling needed PHP modules.' # https://docs.nextcloud.com/server/14/admin_manual/installation/source_installation.html#prerequisites-label
+ G_DIETPI-NOTIFY 2 'Enabling needed PHP modules.' # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation
${PHP_BINARY}enmod curl gd intl json pdo_mysql opcache apcu redis
# Following modules are switchable since Stretch:
- if (( $G_DISTRO > 3 )); then
-
- phpenmod ctype dom fileinfo iconv mbstring posix simplexml xmlwriter xmlreader zip exif
-
- fi
+ (( $G_DISTRO > 3 )) && phpenmod ctype dom fileinfo iconv mbstring posix simplexml xmlwriter xmlreader zip exif
G_DIETPI-NOTIFY 2 'Enabling APCu memory cache for PHP command line usage (CLI) as well, including Nextcloud ncc command and cron jobs.'
G_CONFIG_INJECT 'apc.enable_cli[[:blank:]=]' 'apc.enable_cli=1' "$FP_PHP_BASE_DIR/mods-available/apcu.ini"
- G_DIETPI-NOTIFY 2 'Enabling and configuring OPcache for Nextcloud.' # https://docs.nextcloud.com/server/14/admin_manual/configuration_server/server_tuning.html#enable-php-opcache
+ G_DIETPI-NOTIFY 2 'Enabling and configuring OPcache for Nextcloud.' # https://docs.nextcloud.com/server/stable/admin_manual/configuration_server/server_tuning.html#enable-php-opcache
G_CONFIG_INJECT 'opcache.enable[[:blank:]=]' 'opcache.enable=1' "$FP_PHP_BASE_DIR/mods-available/opcache.ini"
G_CONFIG_INJECT 'opcache.enable_cli[[:blank:]=]' 'opcache.enable_cli=1' "$FP_PHP_BASE_DIR/mods-available/opcache.ini"
G_CONFIG_INJECT 'opcache.interned_strings_buffer[[:blank:]=]' 'opcache.interned_strings_buffer=8' "$FP_PHP_BASE_DIR/mods-available/opcache.ini"
@@ -7955,9 +7897,9 @@ _EOF_
G_CONFIG_INJECT 'opcache.save_comments[[:blank:]=]' 'opcache.save_comments=1' "$FP_PHP_BASE_DIR/mods-available/opcache.ini"
G_CONFIG_INJECT 'opcache.revalidate_freq[[:blank:]=]' 'opcache.revalidate_freq=1' "$FP_PHP_BASE_DIR/mods-available/opcache.ini"
- if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[83]} > 0 )); then
- G_DIETPI-NOTIFY 2 'Apache webserver found, enabling Nextcloud specific configuration.' # https://docs.nextcloud.com/server/14/admin_manual/installation/source_installation.html#apache-web-server-configuration
+ G_DIETPI-NOTIFY 2 'Apache webserver found, enabling Nextcloud specific configuration.' # https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#apache-web-server-configuration
a2enmod rewrite headers env dir mime 1> /dev/null
local nextcloud_conf='/etc/apache2/sites-available/dietpi-nextcloud.conf'
if [[ -f $nextcloud_conf ]]; then
@@ -7966,8 +7908,8 @@ _EOF_
G_WHIP_MSG "Existing Nextcloud Apache configuration found, will preserve the old one and save the new one for review and comparison to: $nextcloud_conf"
fi
- G_RUN_CMD cp -f /DietPi/dietpi/conf/apache.nextcloud.conf $nextcloud_conf
- a2ensite nextcloud 1> /dev/null
+ dps_index=$software_id Download_Install 'apache.nextcloud.conf' $nextcloud_conf
+ a2ensite dietpi-nextcloud 1> /dev/null
# Cal/CardDAV redirects to Nextcloud DAV endpoint
if [[ ! -f /etc/apache2/conf-available/dietpi-dav_redirect.conf ]]; then
@@ -7978,12 +7920,22 @@ Redirect permanent /.well-known/caldav /nextcloud/remote.php/dav' > /etc/apache2
fi
- elif (( ${aSOFTWARE_INSTALL_STATE[84]} >= 1 )); then
+ elif (( ${aSOFTWARE_INSTALL_STATE[84]} > 0 )); then
G_DIETPI-NOTIFY 2 'Lighttpd webserver found, enabling Nextcloud specific configuration.'
- # Enable mod_setenv
+ # Enable required modules
+ G_CONFIG_INJECT '"mod_access",' ' "mod_access",' /etc/lighttpd/lighttpd.conf '"mod_.+",'
G_CONFIG_INJECT '"mod_setenv",' ' "mod_setenv",' /etc/lighttpd/lighttpd.conf '"mod_.+",'
+ if (( $G_DISTRO < 4 )); then
+
+ G_CONFIG_INJECT '"mod_rewrite",' ' "mod_rewrite",' /etc/lighttpd/lighttpd.conf '"mod_.+",'
+
+ else
+
+ lighttpd-enable-mod rewrite
+
+ fi
# Move Nextcloud configuration file in place and activate it
nextcloud_conf='/etc/lighttpd/conf-available/99-dietpi-nextcloud.conf'
@@ -8010,7 +7962,7 @@ url.redirect = (
elif (( ${aSOFTWARE_INSTALL_STATE[85]} > 0 )); then
- G_DIETPI-NOTIFY 2 'Nginx webserver found, enabling Nextcloud specific configuration.' # https://docs.nextcloud.com/server/14/admin_manual/installation/nginx.html#nextcloud-in-a-subdir-of-nginx
+ G_DIETPI-NOTIFY 2 'Nginx webserver found, enabling Nextcloud specific configuration.' # https://docs.nextcloud.com/server/stable/admin_manual/installation/nginx.html
local nextcloud_conf='/etc/nginx/sites-dietpi/dietpi-nextcloud.conf'
if [[ -f $nextcloud_conf ]]; then
@@ -8021,24 +7973,20 @@ url.redirect = (
dps_index=$software_id Download_Install 'nginx.nextcloud.conf' $nextcloud_conf
# Stretch: Set 'fastcgi_request_buffering off';
- if (( $G_DISTRO > 3 )); then
-
- sed -i 's/#fastcgi_request_buffering off;/fastcgi_request_buffering off;/g' $nextcloud_conf
+ (( $G_DISTRO > 3 )) && sed -i 's/#fastcgi_request_buffering off;/fastcgi_request_buffering off;/g' $nextcloud_conf
- fi
-
- # Set HTTPS on, if SSL connection is available, even with self-signed/untrusted certificate.
- wget -q --spider --timeout=10 --tries=2 https://localhost &> /dev/null
- if (( $? == 0 || $? == 5)); then
+ # Uncomment HSTS header, if chosen via dietpi-letsencrypt and HTTPS connection test succeeds (incl. self-singed cert => exit code 5)
+ if [[ -f /DietPi/dietpi/.dietpi-letsencrypt && $(sed -n 4p /DietPi/dietpi/.dietpi-letsencrypt) == 1 ]]; then
- sed -i 's/#fastcgi_param HTTPS on;/fastcgi_param HTTPS on;/g' $nextcloud_conf
+ wget -q --spider --timeout=10 --tries=2 https://localhost &> /dev/null
+ (( $? == 0 || $? == 5)) && sed -i 's/#add_header Strict-Transport-Security/add_header Strict-Transport-Security/g' $nextcloud_conf
fi
- # Disable pretty URLs (front controller), if Nextcloud version is lower than 13:
+ # Disable pretty URLs (front controller), if Nextcloud version is lower than 13
if (( $(grep '$OC_VersionString' /var/www/nextcloud/version.php | sed "s/^.*= '//" | sed "s/\..*$//") < 13 )); then
- sed -i 's/^[[:blank:]]*fastcgi_param front_controller_active true;/\t#fastcgi_param front_controller_active true;/g' $nextcloud_conf
+ sed -i 's/^[[:blank:]]*fastcgi_param front_controller_active true;/\t\t#fastcgi_param front_controller_active true;/g' $nextcloud_conf
fi
@@ -8057,10 +8005,10 @@ location = /.well-known/caldav {
fi
- G_DIETPI-NOTIFY 2 'Enable 4-byte support for MariaDB' # https://docs.nextcloud.com/server/14/admin_manual/configuration_database/mysql_4byte_support.html
+ G_DIETPI-NOTIFY 2 'Enable 4-byte support for MariaDB' # https://docs.nextcloud.com/server/stable/admin_manual/configuration_database/mysql_4byte_support.html
local fp_mariadb_conf='/etc/mysql/mariadb.conf.d'
# On Jessie (MariaDB 10.0), /etc/mysql/mariadb.conf.d does not yet exist
- (( G_DISTRO < 4 )) && fp_mariadb_conf='/etc/mysql/conf.d'
+ (( $G_DISTRO < 4 )) && fp_mariadb_conf='/etc/mysql/conf.d'
cat << _EOF_ > $fp_mariadb_conf/99-dietpi-4byte.cnf
[mysqld]
innodb_large_prefix=1
@@ -8071,6 +8019,9 @@ collation-server=utf8mb4_general_ci
_EOF_
G_RUN_CMD systemctl restart $MARIADB_SERVICE
+ # Start redis-server, which is required for ncc command:
+ G_RUN_CMD systemctl start redis-server
+
# Initially add occ command shortcut, will be done by Dietpi-Globals automatically, if occ file exist:
ncc(){ sudo -u www-data php /var/www/nextcloud/occ "$@"; }
@@ -8185,7 +8136,7 @@ The install script will now exit. After applying one of the the above, rerun die
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
+ G_DIETPI-NOTIFY 2 'Enabling Redis for transactional file locking.' # https://docs.nextcloud.com/server/stable/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!
@@ -8202,6 +8153,9 @@ The install script will now exit. After applying one of the the above, rerun die
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 -
ncc background:cron
+ # Convert filecache tables to bigint, which is not done anymore automatically by Nextcloud since v15
+ ncc db:convert-filecache-bigint -n
+
# Enable maintenance mode to allow handling by dietpi-services:
grep -q "^[[:blank:]]*'maintenance' => true," $config_php || ncc maintenance:mode --on
@@ -8216,18 +8170,20 @@ The install script will now exit. After applying one of the the above, rerun die
G_DIETPI-NOTIFY 2 'Configuring TURN server:'
# - Enable init.d service
G_CONFIG_INJECT 'TURNSERVER_ENABLED=' 'TURNSERVER_ENABLED=1' /etc/default/coturn
+ # - Disable coturn logging by default, this can be overridden via /etc/turnserver.conf
+ G_CONFIG_INJECT 'DAEMON_ARGS=' "DAEMON_ARGS='-c /etc/turnserver.conf -o -l stdout --no-stdout-log --simple-log'" /etc/default/coturn
# - Ask user for server domain and desired TURN server port
local invalid_text=''
- local domain='my.domain.org'
+ local domain=$(hostname)
while :
do
- G_WHIP_DEFAULT_ITEM="$domain"
+ G_WHIP_DEFAULT_ITEM=$domain
G_WHIP_INPUTBOX "${invalid_text}Please enter your servers external domain to allow Nextcloud Talk access your TURN server:"
if (( $? == 0 )) && [[ $G_WHIP_RETURNED_VALUE ]]; then
- domain="${G_WHIP_RETURNED_VALUE#http*://}"
+ domain=${G_WHIP_RETURNED_VALUE#http*://}
break
else
@@ -8237,7 +8193,7 @@ The install script will now exit. After applying one of the the above, rerun die
fi
done
- local invalid_text=''
+ invalid_text=''
local port=5349
while :
do
@@ -8245,7 +8201,7 @@ The install script will now exit. After applying one of the the above, rerun die
G_WHIP_DEFAULT_ITEM=$port
G_WHIP_INPUTBOX "${invalid_text}Please enter the network port, that should be used for your TURN server:\n
NB: This port needs to be forwarded by your router and/or opened in your firewall settings. Default value is: 5349"
- if (( $? == 0 )) && disable_error=1 G_CHECK_VALIDINT "$G_WHIP_RETURNED_VALUE"; then
+ if (( $? == 0 )) && disable_error=1 G_CHECK_VALIDINT "$G_WHIP_RETURNED_VALUE" 0; then
port=$G_WHIP_RETURNED_VALUE
break
@@ -8260,7 +8216,6 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal
# - Adjust coturn settings
G_CONFIG_INJECT 'fingerprint' 'fingerprint' /etc/turnserver.conf
- 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
GCI_PRESERVE=1 G_CONFIG_INJECT 'total-quota=' 'total-quota=100' /etc/turnserver.conf
@@ -8274,10 +8229,10 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal
-f /etc/letsencrypt/live/$(sed -n 1p /DietPi/dietpi/.dietpi-letsencrypt)/cert.pem ]]; then
G_DIETPI-NOTIFY 2 'LetsEncrypt certificate found, will configure coturn TURN server to accept TLS connections'
- # - Comment matching non-TLS port, to avoid doubled port use:
- G_CONFIG_INJECT "listening-port=$port" "#listening-port=$port" /etc/turnserver.conf
+ # - Disable non-TLS listening port, enable TLS listening port:
+ G_CONFIG_INJECT 'listening-port=' "#listening-port=$port" /etc/turnserver.conf
G_CONFIG_INJECT 'tls-listening-port=' "tls-listening-port=$port" /etc/turnserver.conf
- local fp_cert_dir="/etc/letsencrypt/live/$(sed -n 1p /DietPi/dietpi/.dietpi-letsencrypt)/cert.pem"
+ local fp_cert_dir="/etc/letsencrypt/live/$(sed -n 1p /DietPi/dietpi/.dietpi-letsencrypt)"
G_CONFIG_INJECT 'cert=' "cert=$fp_cert_dir/cert.pem" /etc/turnserver.conf
G_CONFIG_INJECT 'pkey=' "pkey=$fp_cert_dir/privkey.pem" /etc/turnserver.conf
# - Proven working default cipher, but thus should be properly reworked, e.g. to match webserver settings?
@@ -8291,6 +8246,7 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal
# - Install Nextcloud Talk app
G_RUN_CMD systemctl start $MARIADB_SERVICE
+ G_RUN_CMD systemctl start redis-server
G_RUN_CMD ncc maintenance:mode --off
G_RUN_CMD ncc app:install spreed
ncc app:enable spreed
@@ -8301,10 +8257,10 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal
local secret=$(openssl rand -hex 32)
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=}"
+ secret=$(grep -m1 '^[[:blank:]]*static-auth-secret=' /etc/turnserver.conf)
+ secret=${secret#*static-auth-secret=}
ncc config:app:set spreed turn_servers --value="[{\"server\":\"$domain:$port\",\"secret\":\"$secret\",\"protocols\":\"udp,tcp\"}]"
- unset secret
+ unset secret domain port invalid_text
fi
@@ -8315,7 +8271,7 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal
Banner_Configuration
# Remove obsolete init.d service
- rm /etc/init.d/transmission-daemon &> /dev/null
+ [[ -f /etc/init.d/transmission-daemon ]] && rm /etc/init.d/transmission-daemon
# Run service as "dietpi" group: https://github.com/Fourdee/DietPi/issues/350#issuecomment-423763518
mkdir -p /etc/systemd/system/transmission-daemon.service.d
@@ -8361,28 +8317,32 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal
fi
- #MPD
- software_id=128
+ software_id=128 # MPD
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Configuration
# Create MPD user
- #useradd -rM mpd -G dietpi,audio -s /usr/sbin/nologin
+ local usercmd='useradd -rM'
+ getent passwd mpd &> /dev/null && usercmd='usermod'
+ $usercmd mpd -G dietpi,audio -d $G_FP_DIETPI_USERDATA/.mpd_cache -s /usr/sbin/nologin
- # - Runtime folders/files
- # log
+ # Runtime dirs/files
+ # - Log
mkdir -p /var/log/mpd
- > /var/log/mpd/mpd.log
-
- # cache
+ >> /var/log/mpd/mpd.log
+ # - Cache
mkdir -p $G_FP_DIETPI_USERDATA/.mpd_cache
- > $G_FP_DIETPI_USERDATA/.mpd_cache/db_file
- > $G_FP_DIETPI_USERDATA/.mpd_cache/state
- > $G_FP_DIETPI_USERDATA/.mpd_cache/sticker.sql
-
- # Symlink from MPD defaults that applications may still expect/use.
- rm -R /var/lib/mpd &> /dev/null
+ >> $G_FP_DIETPI_USERDATA/.mpd_cache/db_file
+ >> $G_FP_DIETPI_USERDATA/.mpd_cache/state
+ >> $G_FP_DIETPI_USERDATA/.mpd_cache/sticker.sql
+ # - Symlink from MPD defaults that applications may still expect/use.
+ [[ ! -e /var/lib/mpd/music || -L /var/lib/mpd/music ]] || mv -n /var/lib/mpd/music/* $G_FP_DIETPI_USERDATA/Music/ &> /dev/null
+ [[ ! -e /var/lib/mpd/playlists || -L /var/lib/mpd/playlists ]] || mv -n /var/lib/mpd/playlists/* $G_FP_DIETPI_USERDATA/Music/ &> /dev/null
+ [[ ! -e /var/lib/mpd/mpd.db || -L /var/lib/mpd/mpd.db ]] || mv -n /var/lib/mpd/mpd.db $G_FP_DIETPI_USERDATA/.mpd_cache/db_file
+ [[ ! -e /var/lib/mpd/state || -L /var/lib/mpd/state ]] || mv -n /var/lib/mpd/state $G_FP_DIETPI_USERDATA/.mpd_cache/state
+ [[ ! -e /var/lib/mpd/sticker.sql || -L /var/lib/mpd/sticker.sql ]] || mv -n /var/lib/mpd/sticker.sql $G_FP_DIETPI_USERDATA/.mpd_cache/sticker.sql
+ [[ -d /var/lib/mpd ]] && rm -R /var/lib/mpd
mkdir -p /var/lib/mpd
ln -sf $G_FP_DIETPI_USERDATA/Music /var/lib/mpd/music
ln -sf $G_FP_DIETPI_USERDATA/Music /var/lib/mpd/playlists
@@ -8390,38 +8350,68 @@ NB: This port needs to be forwarded by your router and/or opened in your firewal
ln -sf $G_FP_DIETPI_USERDATA/.mpd_cache/state /var/lib/mpd/state
ln -sf $G_FP_DIETPI_USERDATA/.mpd_cache/sticker.sql /var/lib/mpd/sticker.sql
- # - default config
+ # Default config
G_BACKUP_FP /etc/mpd.conf
- cp /DietPi/dietpi/conf/mpd.conf /etc/mpd.conf
+ dps_index=$software_id Download_Install 'mpd.conf' /etc/mpd.conf
+ # - On Stretch (custom build), symlink /etc/mpd.conf to /usr/local/etc/mpd.conf, where /usr/local/bin/mpd by default searches
+ if [[ $(command -v mpd) == '/usr/local/bin/mpd' ]]; then
- # - MPD service/confs
- cat << _EOF_ > /etc/default/mpd
-#Even though we declare the conf location in our service, MPD will fail to start if this file does not exist.
-## The configuration file location for mpd:
-MPDCONF=/etc/mpd.conf
-_EOF_
+ mkdir -p /usr/local/etc
+ ln -sf /etc/mpd.conf /usr/local/etc/mpd.conf
+
+ fi
+ # MPD service/confs
+ [[ -f /etc/default/mpd ]] && rm /etc/default/mpd
+
+ # - Upsteam systemd unit: https://github.com/MusicPlayerDaemon/MPD/blob/master/systemd/system/mpd.service.in
+ # - Debian package systemd unit: https://deb.debian.org/debian/pool/main/m/mpd/
cat << _EOF_ > /lib/systemd/system/mpd.service
[Unit]
-Description=Music Player Daemon
+Description=Music Player Daemon (DietPi)
+Documentation=man:mpd(1) man:mpd.conf(5)
+Documentation=file:///usr/share/doc/mpd/user-manual.html
After=network.target sound.target
[Service]
-#User=root #forks its own process under user set in /etc/mpd.conf (mpd)
-Type=simple
-LimitRTPRIO=infinity
+#User=mpd # Forks its own process under user set in /etc/mpd.conf (mpd)
RuntimeDirectory=/var/run/mpd
-EnvironmentFile=/etc/default/mpd
-ExecStartPre=$(which mkdir) -p /var/run/mpd
-ExecStartPre=$(which chown) -R root:dietpi /var/run/mpd
-ExecStart=$(which mpd) --no-daemon /etc/mpd.conf
+ExecStartPre=$(command -v mkdir) -p /var/run/mpd
+ExecStartPre=$(command -v chown) -R mpd:dietpi /var/run/mpd
+ExecStart=$(command -v mpd) --no-daemon /etc/mpd.conf
+
+# allow MPD to use real-time priority 50
+LimitRTPRIO=50
+LimitRTTIME=infinity
+
+# disallow writing to /usr, /bin, /sbin, ...
+ProtectSystem=yes
+
+# more paranoid security settings
+NoNewPrivileges=yes
+ProtectKernelTunables=yes
+ProtectControlGroups=yes
+ProtectKernelModules=yes
+# AF_NETLINK is required by libsmbclient, or it will exit() .. *sigh*
+RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK
+RestrictNamespaces=yes
[Install]
WantedBy=multi-user.target
-
+Also=mpd.socket
_EOF_
- #JustBoom specials
+ # - Jessie: Remove unsupported systemd unit settings
+ if (( $G_DISTRO < 4 )); then
+
+ sed -i '/ProtectKernelTunables/d' /lib/systemd/system/mpd.service
+ sed -i '/ProtectControlGroups/d' /lib/systemd/system/mpd.service
+ sed -i '/ProtectKernelModules/d' /lib/systemd/system/mpd.service
+ sed -i '/RestrictNamespaces/d' /lib/systemd/system/mpd.service
+
+ fi
+
+ # JustBoom specials
if grep -qi '^[[:blank:]]*CONFIG_SOUNDCARD=justboom' /DietPi/dietpi.txt; then
# - Name displayed in YMPD sound button
@@ -8441,7 +8431,7 @@ _EOF_
fi
- #Grab our test music for the user.
+ # Grab our test music for the user.
Download_Test_Media
fi
@@ -8509,17 +8499,19 @@ _EOF_
Banner_Configuration
- useradd -rM ympd -G dietpi -s /usr/sbin/nologin
+ usercmd='useradd -rM'
+ getent passwd ympd &> /dev/null && usercmd='usermod'
+ $usercmd ympd -G dietpi -s /usr/sbin/nologin
#YMPD service
cat << _EOF_ > /etc/systemd/system/ympd.service
[Unit]
-Description=YMPD
+Description=YMPD (DietPi)
After=mpd.service
[Service]
Type=simple
-User=root # Changes to ympd during run
+#User=ympd # Changes to ympd during run
Group=dietpi
ExecStart=/usr/bin/ympd --user ympd --webport 1337
@@ -8535,18 +8527,20 @@ _EOF_
Banner_Configuration
- useradd -rM mympd -G dietpi,audio -s /usr/sbin/nologin
+ usercmd='useradd -rM'
+ getent passwd mympd &> /dev/null && usercmd='usermod'
+ $usercmd mympd -G dietpi,audio -s /usr/sbin/nologin
cat << _EOF_ > /lib/systemd/system/mympd.service
[Unit]
-Description=myMPD
+Description=myMPD (DietPi)
After=mpd.service
[Service]
Type=simple
-User=root # Changes at runlevel
+#User=mympd # Changes at runlevel
Group=dietpi
-ExecStart=$(which mympd) /etc/mympd/mympd.conf
+ExecStart=$(command -v mympd) /etc/mympd/mympd.conf
[Install]
WantedBy=multi-user.target
@@ -8584,8 +8578,8 @@ _EOF_
# - Move logfiles to /var/log/ (dietpi-ramlog)
# Remove any previous folders to clear for symlink
- rm -R $G_FP_DIETPI_USERDATA/roon/RoonBridge/Logs &> /dev/null
- rm -R $G_FP_DIETPI_USERDATA/roon/RAATServer/Logs &> /dev/null
+ [[ -d $G_FP_DIETPI_USERDATA/roon/RoonBridge/Logs ]] && rm -R $G_FP_DIETPI_USERDATA/roon/RoonBridge/Logs
+ [[ -d $G_FP_DIETPI_USERDATA/roon/RAATServer/Logs ]] && rm -R $G_FP_DIETPI_USERDATA/roon/RAATServer/Logs
mkdir -p $G_FP_DIETPI_USERDATA/roon/RoonBridge
mkdir -p $G_FP_DIETPI_USERDATA/roon/RAATServer
@@ -8609,7 +8603,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/node-red.service
[Unit]
-Description=Node-Red
+Description=Node-Red (DietPi)
[Service]
Type=simple
@@ -8644,13 +8638,13 @@ _EOF_
mkdir -p $HOME/.config/cava
G_BACKUP_FP $HOME/.config/cava/config
- cp /DietPi/dietpi/conf/cava.conf $HOME/.config/cava/config
+ cp /var/lib/dietpi/dietpi-software/conf/cava.conf $HOME/.config/cava/config
# - lower MPD buffer size to reduce latency of spectrum:
sed -i '/audio_buffer_size /c\audio_buffer_size "384"' /etc/mpd.conf
# - fifo stream for mpd
- if (( ! $(grep -ci -m1 '/tmp/mpd.fifo' /etc/mpd.conf) )); then
+ if ! grep -q '/tmp/mpd.fifo' /etc/mpd.conf; then
cat << _EOF_ >> /etc/mpd.conf
@@ -8676,61 +8670,44 @@ _EOF_
Banner_Configuration
- useradd -rM mopidy -G dietpi,audio -s /usr/sbin/nologin
- sed -i "/User=/c\User=mopidy" /lib/systemd/system/mopidy.service
+ # Assure user home, data and cache dir as well on custom configs
+ G_CONFIG_INJECT 'data_dir[[:blank:]]*=' 'data_dir = /mnt/dietpi_userdata/mopidy/data' /etc/mopidy/mopidy.conf '\[core\]'
+ G_CONFIG_INJECT 'cache_dir[[:blank:]]*=' 'cache_dir = /mnt/dietpi_userdata/mopidy/cache' /etc/mopidy/mopidy.conf '\[core\]'
- # - conf
- mkdir -p $G_FP_DIETPI_USERDATA/mopidy/cache
- mkdir -p $G_FP_DIETPI_USERDATA/mopidy/data
+ # - Move existing home+data to dietpi_userdata, if not yet existent
+ if [[ -d /var/lib/mopidy && ! -d $G_FP_DIETPI_USERDATA/mopidy ]]; then
- mkdir -p ~/.config/mopidy
+ mv /var/lib/mopidy $G_FP_DIETPI_USERDATA/mopidy
+ mkdir -p $G_FP_DIETPI_USERDATA/mopidy/data
+ # - Non-hidden files/folders are data
+ mv $G_FP_DIETPI_USERDATA/mopidy/* $G_FP_DIETPI_USERDATA/mopidy/data
- G_BACKUP_FP ~/.config/mopidy/mopidy.conf
- cat << _EOF_ > ~/.config/mopidy/mopidy.conf
-[core]
-cache_dir = $G_FP_DIETPI_USERDATA/mopidy/cache
-config_dir = /etc/mopidy
-data_dir = $G_FP_DIETPI_USERDATA/mopidy/data
-[logging]
-config_file = /etc/mopidy/logging.conf
-debug_file = /var/log/mopidy.log
+ else
-[local]
-library = images
-media_dir = /mnt
-enabled = true
-scan_timeout = 1000
-scan_flush_threshold = 100
-scan_follow_symlinks = false
-excluded_file_extensions =
- .directory
- .html
- .jpeg
- .jpg
- .log
- .nfo
- .png
- .txt
-
-[file]
-enabled = true
-media_dirs = /mnt
+ mkdir -p $G_FP_DIETPI_USERDATA/mopidy/data
+ [[ -d /var/lib/mopidy ]] && rm -R /var/lib/mopidy
+
+ fi
-[m3u]
-playlists_dir = /mnt
+ # - Move existing cache to dietpi_userdata, if not yet existent
+ if [[ -d /var/cache/mopidy && ! -d $G_FP_DIETPI_USERDATA/mopidy/cache ]]; then
-[http]
-enabled = true
-hostname = ::
-port = 6680
-static_dir =
-zeroconf = Mopidy HTTP server on $hostname
+ mv /var/cache/mopidy $G_FP_DIETPI_USERDATA/mopidy/cache
-_EOF_
+ else
+
+ mkdir -p $G_FP_DIETPI_USERDATA/mopidy/cache
+ [[ -d /var/cache/mopidy ]] && rm -R /var/cache/mopidy
+
+ fi
+
+ # - Adjust user group and home dir
+ usermod -a -G dietpi -d $G_FP_DIETPI_USERDATA/mopidy mopidy
- # NB: mopidy uses both config locations, so lets make sure we match them
- cp ~/.config/mopidy/mopidy.conf /etc/mopidy/mopidy.conf
+ # - Adjust systemd unit to match new group and do not pre-create obsolete cache dir
+ mkdir -p /etc/systemd/system/mopidy.service.d
+ echo -e '[Service]\nGroup=dietpi\nExecStartPre=' > /etc/systemd/system/mopidy.service.d/dietpi.conf
Download_Test_Media
@@ -8746,7 +8723,7 @@ _EOF_
userdel -r kodi &> /dev/null
#Run Kodi as root
- sed -i '/USER=/c\USER=root' /etc/default/kodi &> /dev/null
+ [[ -f /etc/default/kodi ]] && G_CONFIG_INJECT 'USER=' 'USER=root' /etc/default/kodi
#Copy udev rules, probably not needed for root, but we'll do it anyway
dps_index=$software_id Download_Install '99-dietpi-kodi.rules' /etc/udev/rules.d/99-dietpi-kodi.rules
@@ -8754,7 +8731,7 @@ _EOF_
#Create .desktop SymLinks
mkdir -p $HOME/Desktop
- rm /usr/share/applications/kodi.desktop &> /dev/null
+ [[ -f /usr/share/applications/kodi.desktop ]] && rm /usr/share/applications/kodi.desktop
G_RUN_CMD wget https://raw.githubusercontent.com/Fourdee/DietPi/$G_GITBRANCH/.conf/desktop/apps/kodi.desktop -O /usr/share/applications/kodi.desktop
ln -sf /usr/share/applications/kodi.desktop $HOME/Desktop/kodi.desktop
@@ -8769,13 +8746,13 @@ _EOF_
userdel -rf minidlna &> /dev/null
useradd -rM minidlna -G dietpi -s /usr/sbin/nologin
- rm /etc/init.d/minidlna &> /dev/null
- rm /etc/systemd/system/minidlna.service &> /dev/null
- rm /lib/systemd/system/minidlna.service &> /dev/null
+ [[ -f /etc/init.d/minidlna ]] && rm /etc/init.d/minidlna
+ [[ -f /etc/systemd/system/minidlna.service ]] && rm /etc/systemd/system/minidlna.service
+ [[ -f /lib/systemd/system/minidlna.service ]] && rm /lib/systemd/system/minidlna.service
cat << _EOF_ > /etc/systemd/system/minidlna.service
[Unit]
-Description=MiniDLNA
+Description=MiniDLNA (DietPi)
After=network.target
[Service]
@@ -8783,7 +8760,7 @@ Type=simple
User=minidlna
Group=dietpi
RuntimeDirectory=minidlna
-ExecStart=$(which minidlnad) -SR -f /etc/minidlna.conf
+ExecStart=$(command -v minidlnad) -SR -f /etc/minidlna.conf
[Install]
WantedBy=multi-user.target
@@ -8808,11 +8785,15 @@ _EOF_
Banner_Configuration
+ #Failsafe: Directory required for "noip2 -C" to create the config file
+ mkdir -p /usr/local/etc
+
#noip2 service file
cat << _EOF_ > /etc/systemd/system/noip2.service
[Unit]
-Description=noip2
+Description=noip2 (DietPi)
After=network.target network-online.target rsyslog.service
+ConditionPathExists=/usr/local/etc/no-ip2.conf
[Service]
Type=forking
@@ -8891,17 +8872,16 @@ _EOF_
local exec_start="$G_FP_DIETPI_USERDATA/amiberry/$amiberry_filename -f $G_FP_DIETPI_USERDATA/amiberry/conf/autostart.uae"
if (( $G_HW_MODEL == 52 )); then
- exec_start="$(which xinit) $G_FP_DIETPI_USERDATA/amiberry/$amiberry_filename -f $G_FP_DIETPI_USERDATA/amiberry/conf/autostart.uae"
+ exec_start="$(command -v xinit) $G_FP_DIETPI_USERDATA/amiberry/$amiberry_filename -f $G_FP_DIETPI_USERDATA/amiberry/conf/autostart.uae"
fi
cat << _EOF_ > /etc/systemd/system/amiberry.service
[Unit]
-Description=AmiBerry Amiga Emulator
+Description=AmiBerry Amiga Emulator (DietPi)
[Service]
Type=simple
-User=root
#StandardOutput=tty
#StandardInput=tty
#TTYPath=/dev/tty1
@@ -8988,13 +8968,13 @@ _EOF_
chmod +x /var/lib/dietpi/dietpi-software/installed/raspimjpeg.sh
cat << _EOF_ > /etc/systemd/system/raspimjpeg.service
[Unit]
-Description=DietPi Raspimjpeg Service
+Description=Raspimjpeg (DietPi)
[Service]
Type=simple
RemainAfterExit=yes
-ExecStart=$(which bash) -c '/var/lib/dietpi/dietpi-software/installed/raspimjpeg.sh start'
-ExecStop=$(which bash) -c '/var/lib/dietpi/dietpi-software/installed/raspimjpeg.sh stop'
+ExecStart=$(command -v bash) -c '/var/lib/dietpi/dietpi-software/installed/raspimjpeg.sh start'
+ExecStop=$(command -v bash) -c '/var/lib/dietpi/dietpi-software/installed/raspimjpeg.sh stop'
[Install]
WantedBy=multi-user.target
@@ -9033,14 +9013,15 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/deluged.service
[Unit]
-Description=DietPi Deluged Service
+Description=Deluged (DietPi)
[Service]
Type=simple
User=deluge
Group=dietpi
+UMask=002
Environment=USER=deluge HOME=$G_FP_DIETPI_USERDATA/deluge
-ExecStart=$(which deluged) -d -l /var/log/deluged.log -L warning
+ExecStart=$(command -v deluged) -d -l /var/log/deluged.log -L warning
[Install]
WantedBy=multi-user.target
@@ -9048,14 +9029,15 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/deluge-web.service
[Unit]
-Description=DietPi Deluge-web Service
+Description=Deluge-web (DietPi)
[Service]
-Type=simple #forking causes systemd-tty-ask-password-agent hang
+# forking causes systemd-tty-ask-password-agent hang
+Type=simple
User=deluge
Group=dietpi
Environment=USER=deluge HOME=$G_FP_DIETPI_USERDATA/deluge
-ExecStart=$(which deluge-web) -l /var/log/deluge-web.log -L warning
+ExecStart=$(command -v deluge-web) -l /var/log/deluge-web.log -L warning
[Install]
WantedBy=multi-user.target
@@ -9100,12 +9082,12 @@ _EOF_
rm /etc/init.d/webmin &> /dev/null
cat << _EOF_ > /etc/systemd/system/webmin.service
[Unit]
-Description=DietPi Webmin Service
+Description=Webmin (DietPi)
[Service]
Type=forking
-ExecStart=$(which bash) -c '/etc/webmin/start'
-ExecStop=$(which bash) -c '/etc/webmin/stop'
+ExecStart=$(command -v bash) -c '/etc/webmin/start'
+ExecStop=$(command -v bash) -c '/etc/webmin/stop'
[Install]
WantedBy=multi-user.target
@@ -9160,48 +9142,45 @@ Do you want to enable the Pi-hole blocking page?'; then
fi
- #AirSonic
- software_id=33
+ software_id=33 # Airsonic
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Configuration
- useradd -rM airsonic -G dietpi,audio -s /usr/sbin/nologin
+ local usercmd='useradd -rM'
+ getent passwd airsonic &> /dev/null && usercmd='usermod'
+ $usercmd airsonic -G dietpi,audio -d $G_FP_DIETPI_USERDATA/airsonic -s /usr/sbin/nologin
#Optimize memory limit
local airsonic_memory_max=$(( $RAM_TOTAL / 5 ))
- if (( $airsonic_memory_max < 200 )); then
-
- airsonic_memory_max='200'
-
- fi
+ (( $airsonic_memory_max < 200 )) && airsonic_memory_max=200
airsonic_memory_max+='m'
cat << _EOF_ > /etc/systemd/system/airsonic.service
[Unit]
-Description=Airsonic Media Server
+Description=Airsonic Media Server (DietPi)
After=remote-fs.target network.target
[Service]
Type=simple
User=airsonic
+Group=dietpi
WorkingDirectory=$G_FP_DIETPI_USERDATA/airsonic
-ExecStart=$(which java) -Xmx$airsonic_memory_max -Dairsonic.home=$G_FP_DIETPI_USERDATA/airsonic -Dserver.context-path=/airsonic -Dserver.port=8080 -jar $G_FP_DIETPI_USERDATA/airsonic/airsonic.war
+ExecStart=$(command -v java) -Xmx$airsonic_memory_max -Dairsonic.home=$G_FP_DIETPI_USERDATA/airsonic -Dserver.context-path=/airsonic -Dserver.port=8080 -jar $G_FP_DIETPI_USERDATA/airsonic/airsonic.war
[Install]
WantedBy=multi-user.target
_EOF_
- #Symlink ffmpeg to subsonic transcoder
- ln -fs $(which ffmpeg) $G_FP_DIETPI_USERDATA/airsonic/transcode
+ #Symlink FFmpeg to Airsonic transcoder
+ ln -sf $(command -v ffmpeg) $G_FP_DIETPI_USERDATA/airsonic/transcode
#Grab our test media for user
Download_Test_Media
fi
- #SUBSONIC 6
- software_id=34
+ software_id=34 # Subsonic
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Configuration
@@ -9216,15 +9195,15 @@ _EOF_
cat << _EOF_ > /etc/default/subsonic
SUBSONIC_USER=root
-SUBSONIC_ARGS="--quiet --pidfile=/run/subsonic.pid --max-memory=$subsonic_memory_max --default-music-folder=$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC --default-podcast-folder=$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC --default-playlist-folder=$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC"
+SUBSONIC_ARGS='--quiet --pidfile=/run/subsonic.pid --max-memory=$subsonic_memory_max --default-music-folder=$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC --default-podcast-folder=$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC --default-playlist-folder=$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC'
_EOF_
+ #Symlink FFmpeg to Subsonic transcoder
+ ln -fs $(command -v ffmpeg) /var/subsonic/transcode
+
#Grab our test media for user
Download_Test_Media
- #Symlink ffmpeg to subsonic transcoder
- ln -fs $(which ffmpeg) /var/subsonic/transcode
-
fi
#WEBIOPI
@@ -9250,17 +9229,17 @@ _EOF_
#Service
cat << _EOF_ > /etc/systemd/system/dietpi-cloudshell.service
[Unit]
-Description=dietpi-cloudshell on main screen
+Description=dietpi-cloudshell on main screen (DietPi)
[Service]
Type=simple
StandardOutput=tty
TTYPath=/dev/tty1
-ExecStartPre=$(which setterm) --term linux --blank 0 --powersave off --cursor off
+ExecStartPre=$(command -v setterm) --term linux --blank 0 --powersave off --cursor off
ExecStart=/bin/bash -c '/DietPi/dietpi/dietpi-cloudshell 1'
-ExecStop=$(which setterm) --reset
-ExecStop=$(which echo) 'DietPi-Cloudshell terminated, have a nice day!'
+ExecStop=$(command -v setterm) --reset
+ExecStop=$(command -v echo) 'DietPi-Cloudshell terminated, have a nice day!'
[Install]
WantedBy=multi-user.target
@@ -9375,11 +9354,11 @@ _EOF_
#Service
cat << _EOF_ > /etc/systemd/system/squeezeboxserver.service
[Unit]
-Description=Squeezebox Server (LMS)
+Description=Squeezebox Server/LMS (DietPi)
[Service]
Type=simple
-ExecStart=$(which squeezeboxserver) --prefsdir /var/lib/squeezeboxserver/prefs --logfile /var/log/squeezeboxserver/error.log --logdir /var/log/squeezeboxserver/ --cachedir /var/lib/squeezeboxserver/cache --user root
+ExecStart=$(command -v squeezeboxserver) --prefsdir /var/lib/squeezeboxserver/prefs --logfile /var/log/squeezeboxserver/error.log --logdir /var/log/squeezeboxserver/ --cachedir /var/lib/squeezeboxserver/cache --user root
[Install]
WantedBy=multi-user.target
@@ -9501,13 +9480,12 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/vncserver.service
[Unit]
-Description=Manage VNC Server
+Description=Manage VNC Server (DietPi)
Before=xrdp.service xrdp-sesman.service
After=dietpi-boot.service dietpi-ramdisk.service dietpi-ramlog.service
[Service]
Type=simple
-User=root
RemainAfterExit=yes
PAMName=login
ExecStart=/bin/bash /usr/local/bin/vncserver start
@@ -9675,9 +9653,6 @@ _EOF_
Banner_Configuration
- # Generate log
- echo 0 > /var/log/auth.log
-
G_BACKUP_FP /etc/fail2ban/fail2ban.conf /etc/fail2ban/jail.conf
cat << _EOF_ > /etc/fail2ban/fail2ban.conf
[Definition]
@@ -9733,7 +9708,7 @@ _EOF_
fi
- #grafana
+ #Grafana
software_id=77
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
@@ -9754,6 +9729,7 @@ _EOF_
# - Set password, wrap into trippled double quotes in case of ; or # being contained, according to docs: http://docs.grafana.org/installation/configuration/#password
GCI_PRESERVE=1 G_CONFIG_INJECT 'admin_password[[:blank:]]*=' "admin_password = \"\"\"$GLOBAL_PW\"\"\"" /etc/grafana/grafana.ini
+ G_CONFIG_INJECT 'http_port = ' 'http_port = 3001' /etc/grafana/grafana.ini
fi
@@ -9770,14 +9746,14 @@ _EOF_
chmod +x $G_FP_DIETPI_USERDATA/ubooquity/Ubooquity.jar
cat << _EOF_ > /etc/systemd/system/ubooquity.service
[Unit]
-Description=Ubooquity - DietPi
+Description=Ubooquity (DietPi)
After=dietpi-boot.service network.target
[Service]
Type=simple
User=ubooquity
WorkingDirectory=$G_FP_DIETPI_USERDATA/ubooquity
-ExecStart=$(which java) -jar $G_FP_DIETPI_USERDATA/ubooquity/Ubooquity.jar --headless --remoteadmin --adminport 2038 --libraryport 2039
+ExecStart=$(command -v java) -jar $G_FP_DIETPI_USERDATA/ubooquity/Ubooquity.jar --headless --remoteadmin --adminport 2038 --libraryport 2039
[Install]
WantedBy=multi-user.target
@@ -9845,47 +9821,44 @@ _EOF_
Banner_Configuration
- local key_size=1024
+ local key_size=2048
#Start Cert/Key generation.
- cp -R /usr/share/easy-rsa/ /etc/openvpn
+ cp -a /usr/share/easy-rsa/ /etc/openvpn
mkdir -p /etc/openvpn/easy-rsa/keys
cat << _EOF_ >> /etc/openvpn/easy-rsa/vars
export KEY_SIZE=$key_size
-export KEY_COUNTRY="UK"
-export KEY_PROVINCE="DietPi"
-export KEY_CITY="DietPi"
-export KEY_ORG="DietPi"
-export KEY_EMAIL="noreply@DietPi.com"
-export KEY_OU="DietPi"
-export KEY_NAME="DietPi_OpenVPN_Server"
+export KEY_COUNTRY='UK'
+export KEY_PROVINCE='DietPi'
+export KEY_CITY='DietPi'
+export KEY_ORG='DietPi'
+export KEY_EMAIL='noreply@DietPi.com'
+export KEY_OU='DietPi'
+export KEY_NAME='DietPi_OpenVPN_Server'
_EOF_
#Create Server Cert Auth
G_DIETPI-NOTIFY 2 'Generating unique OpenVPN certificates and keys. Please wait...\n'
- openssl dhparam -out /etc/openvpn/dh"$key_size".pem "$key_size"
+ openssl dhparam -out /etc/openvpn/dh${key_size}.pem $key_size
#Build Server certs/keys
chmod -R +x /etc/openvpn/easy-rsa
cd /etc/openvpn/easy-rsa
# - https://github.com/Fourdee/DietPi/issues/1450#issuecomment-362608574
- if (( $G_DISTRO >= 4 )); then
-
- cp openssl-1.0.0.cnf openssl.cnf
+ (( $G_DISTRO >= 4 )) && cp -a openssl-1.0.0.cnf openssl.cnf
- fi
. ./vars
./clean-all
./build-ca --batch DietPi_OpenVPN_Server
./build-key-server --batch DietPi_OpenVPN_Server
#Copy Server cert/keys
- cp /etc/openvpn/easy-rsa/keys/{DietPi_OpenVPN_Server.crt,DietPi_OpenVPN_Server.key,ca.crt} /etc/openvpn/
+ cp -a /etc/openvpn/easy-rsa/keys/{DietPi_OpenVPN_Server.crt,DietPi_OpenVPN_Server.key,ca.crt} /etc/openvpn/
#Build client cert/keys
./build-key --batch DietPi_OpenVPN_Client
- cd ..
+ cd /tmp/$G_PROGRAM_NAME
#End Cert/Key generation.
#Server config
@@ -9970,6 +9943,174 @@ _EOF_
fi
+ #WireGuard
+ software_id=172
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
+
+ # Try to enable module, if it fails, a reboot is required
+ local module_active=0
+ modprobe wireguard 2> /dev/null && module_active=1
+
+ # Server/Client choice
+ local choice_required=''
+ while :
+ do
+
+ G_WHIP_MENU_ARRAY=(
+
+ 'Server' ': Use this machine as VPN server and allow clients to connect to it.'
+ 'Client' ': Use this machine as VPN client, e.g. to connect to a VPN service provider.'
+
+ )
+
+ G_WHIP_MENU "${choice_required}Please choose, if this machine should be set up as VPN server or client:" && break
+ choice_required='[ERROR] A choice is required to finish the WireGuard install.\n\n'
+
+ done
+
+ # Server choice
+ if [[ $G_WHIP_RETURNED_VALUE == 'Server' ]]; then
+
+ # - Public IP/domain and desired WireGuard server port
+ local invalid_text=''
+ local domain=$(hostname)
+ while :
+ do
+
+ G_WHIP_DEFAULT_ITEM="$domain"
+ G_WHIP_INPUTBOX "${invalid_text}Please enter your servers public IP/domain for WireGuard client access:"
+ if (( $? == 0 )) && [[ $G_WHIP_RETURNED_VALUE ]]; then
+
+ domain="${G_WHIP_RETURNED_VALUE#http*://}"
+ break
+
+ else
+
+ invalid_text='[ERROR] No valid entry found. Please retry...\n\n'
+
+ fi
+
+ done
+ invalid_text=''
+ local port=51820
+ while :
+ do
+
+ G_WHIP_DEFAULT_ITEM=$port
+ G_WHIP_INPUTBOX "${invalid_text}Please enter the network port, that should be used to access your WireGuard server:\n
+NB: This port needs to be forwarded by your router and/or opened in your firewall settings. Default value is: 51820"
+ if (( $? == 0 )) && disable_error=1 G_CHECK_VALIDINT "$G_WHIP_RETURNED_VALUE" 0; then
+
+ port=$G_WHIP_RETURNED_VALUE
+ break
+
+ else
+
+ invalid_text='[ERROR] No valid entry found, value needs to be a sequence of integers. Please retry...\n\n'
+
+ fi
+
+ done
+
+ # - Create everything inside WireGuard config dir
+ cd /etc/wireguard
+
+ # - For securiy reasons set umask to 077
+ umask 077
+
+ # - Create server and client keys
+ [[ -f server_private.key ]] || wg genkey > server_private.key
+ [[ -f server_public.key ]] || wg pubkey < server_private.key > server_public.key
+ [[ -f client_private.key ]] || wg genkey > client_private.key
+ [[ -f client_public.key ]] || wg pubkey < client_private.key > client_public.key
+
+ # - Server config
+ [[ -f wg0.conf ]] || cat << _EOF_ > wg0.conf
+[Interface]
+Address = 10.8.0.1/24
+PrivateKey = $( wg0-client.conf
+[Interface]
+# The address must be unique for each client, use "10.8.0.3/24" for the second client and so on.
+Address = 10.8.0.2/24
+PrivateKey = $( /etc/sysctl.d/dietpi-wireguard.conf
+
+ # - Start WireGuard interface via systemd unit
+ (( $module_active )) && systemctl start wg-quick@wg0
+ # persistent
+ systemctl enable wg-quick@wg0
+
+ # - Set umask back to default 022
+ umask 022
+
+ # - Navigate back to DietPi-Software working dir
+ cd /tmp/$G_PROGRAM_NAME
+
+ # Client choice
+ elif [[ $G_WHIP_RETURNED_VALUE == 'Client' ]]; then
+
+ G_WHIP_MSG '[ INFO ] WireGuard client setup has been chosen\n
+Please follow the instructions of your VPN provider to configure WireGuard.\n
+If no WireGuard (auto)start is included, but you require it, please do the following:
+1. Check for the created config file/interface name:
+ ls -Al /etc/wireguard/
+ It has a ".conf" file ending, lets assume "wg0-client.conf".
+2. To start the VPN interface, run:
+ systemctl start wg-quick@wg0-client
+3. To autostart the VPN interface on boot, run:
+ systemctl enable wg-quick@wg0-client
+4. To disable autostart again, run:
+ systemctl disable wg-quick@wg0-client'
+
+ fi
+
+ (( $module_active )) || { [[ $DISABLE_REBOOT == 1 ]] && G_WHIP_MSG '[ INFO ] WireGuard install finished\n\nNB: WireGuard has been successfully installed, but a reboot is required, before it can be started.'; }
+
+ unset module_active choice_required domain port invalid_text server_ip
+
+ fi
+
#WIFIHOTSPOT
software_id=60
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
@@ -10071,7 +10212,7 @@ _EOF_
if (( $G_HW_MODEL == 3 && ! $WIFIHOTSPOT_RTL8188C_DEVICE )); then
# - Add Wireless N support
- echo -e "ieee80211n=1" >> /etc/hostapd/hostapd.conf
+ G_CONFIG_INJECT 'ieee80211n=' 'ieee80211n=1' /etc/hostapd/hostapd.conf
fi
@@ -10110,7 +10251,7 @@ _EOF_
# - Generate Logfile
mkdir -p /var/log/tor
- echo 0 > /var/log/tor/notices.log
+ > /var/log/tor/notices.log
chown -R debian-tor:nogroup /var/log/tor/notices.log
# - User: Test tor is functional.
@@ -10354,19 +10495,33 @@ _EOF_
Banner_Configuration
- # - service
+ # - Service
dps_index=$software_id Download_Install 'netdata.service' /etc/systemd/system/netdata.service
+ # Workaround for Jessie
+ if (( $G_DISTRO < 4 )); then
- # - Create netdata user/group
- getent passwd netdata &> /dev/null || useradd -r netdata -s /usr/sbin/nologin -d /var/lib/netdata
+ sed -i '\#ExecStartPre=/bin/chown -R netdata:netdata /var/run/netdata#d' /etc/systemd/system/netdata.service
+ sed -Ei '\#ProtectKernel(Modules|Tunables)=no#d' /etc/systemd/system/netdata.service
- for i in /var/cache/netdata /usr/share/netdata/web /etc/netdata /var/log/netdata /var/lib/netdata
- do
+ fi
- chown -R netdata:netdata $i
- chmod -R 0775 $i
+ # - User
+ local usercmd='useradd -r'
+ getent passwd netdata &> /dev/null && usercmd='usermod'
+ $usercmd netdata -s /usr/sbin/nologin -d /var/lib/netdata
- done
+ # - Permissions: https://docs.netdata.cloud/docs/netdata-security/#netdata-directories
+ # R/O
+ chown -R root:netdata /etc/netdata /usr/lib/netdata /usr/libexec/netdata /usr/share/netdata
+ chmod -R 0750 /etc/netdata /usr/lib/netdata /usr/libexec/netdata /usr/share/netdata
+ # apps.plugin requires root privileges to read disk I/O
+ chmod 4750 /usr/libexec/netdata/plugins.d/apps.plugin
+ # R/W
+ chown -R netdata:netdata /var/cache/netdata /var/lib/netdata /var/log/netdata
+ chmod -R 0770 /var/cache/netdata /var/lib/netdata /var/log/netdata
+
+ # Required: https://github.com/Fourdee/DietPi/issues/2336#issuecomment-450196178
+ chown -R netdata:netdata /usr/share/netdata/web
fi
@@ -10465,15 +10620,10 @@ location = /.well-known/caldav {
# For all ARM devices:
# - en_US.UTF-8 must be installed and the default locale on system. This is for SBC installs using dev2day repo: https://github.com/Fourdee/DietPi/issues/116#issuecomment-222195911
- if (( $G_USER_INPUTS && $G_HW_ARCH < 10 )) &&
- ! locale | grep -q 'en_US.UTF-8'; then
-
- sed -i '/en_US.UTF-8 UTF-8/c\en_US.UTF-8 UTF-8' /etc/locale.gen
- locale-gen
+ if (( $G_HW_ARCH < 10 )) && ! locale | grep -q 'en_US.UTF-8'; then
- G_WHIP_MSG 'Plex Media Server requires en_US.UTF-8 locale to be installed and set to default, else, Plex will not start.\n\nDietPi-Config will now be launched, on the next screen:\n - Select "locale" option\n\nOn the screen after:\n - Select en_US.UTF-8 and press enter.\n\nOnce completed, exit dietpi-config to resume setup'
-
- /DietPi/dietpi/dietpi-config 7 1
+ G_WHIP_MSG 'Plex Media Server requires en_US.UTF-8 locale to be installed and set to default, else, Plex will not start.\n\nThe installer will now change your locale to: en_US.UTF-8'
+ /DietPi/dietpi/func/dietpi-set_software locale 'en_US.UTF-8'
fi
@@ -10493,7 +10643,7 @@ location = /.well-known/caldav {
cat << _EOF_ > /etc/systemd/system/cuberite.service
[Unit]
-Description=Cuberite Server
+Description=Cuberite Server (DietPi)
[Service]
Type=forking
@@ -10586,7 +10736,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/gogs.service
[Unit]
-Description=DietPi Gogs service
+Description=Gogs (DietPi)
DefaultDependencies=no
After=mysqld.service mysql.service mariadb.service
@@ -10633,7 +10783,7 @@ Bittorrent\MaxUploads=$(Optimize_BitTorrent 3)
Bittorrent\MaxUploadsPerTorrent=$(Optimize_BitTorrent 3)
WebUI\Port=1340
WebUI\Enabled=true
-General\Locale=en_GB
+General\Locale=en
Downloads\SavePath=$G_FP_DIETPI_USERDATA/downloads
Downloads\TempPathEnabled=false
Downloads\TempPath=$G_FP_DIETPI_USERDATA/downloads
@@ -10695,16 +10845,12 @@ program=
_EOF_
#Jessie WebUI\Password_ha1 breaks login with m5dsum generated pw, revert to default 'adminadmin': https://github.com/Fourdee/DietPi/issues/1499#issuecomment-364769146
- if (( $G_DISTRO == 3 )); then
-
- sed -i '/Password_ha1=/d' $HOME/.config/qBittorrent/qBittorrent.conf
-
- fi
+ (( $G_DISTRO == 3 )) && sed -i '/Password_ha1=/d' $HOME/.config/qBittorrent/qBittorrent.conf
# - service
cat << _EOF_ > /etc/systemd/system/qbittorrent.service
[Unit]
-Description=qBittorrent Daemon Service
+Description=qBittorrent (DietPi)
After=network.target
[Service]
@@ -10827,11 +10973,10 @@ _EOF_
# - Service using screen | '/usr/bin/rtorrent &> /var/log/rtorrent.log &' doesnt work, hangs program after 5 seconds
cat << _EOF_ > /etc/systemd/system/rtorrent.service
[Unit]
-Description=rTorrent
+Description=rTorrent (DietPi)
After=network.target
[Service]
-User=root
Type=forking
KillMode=none
ExecStart=/usr/bin/screen -d -m -fa -S rtorrent /usr/bin/rtorrent
@@ -11035,11 +11180,11 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/aria2.service
[Unit]
-Description=DietPi Aria2
+Description=Aria2 (DietPi)
[Service]
Type=simple
-ExecStart=$(which aria2c) --conf-path=/var/lib/dietpi/dietpi-software/installed/aria2.conf
+ExecStart=$(command -v aria2c) --conf-path=/var/lib/dietpi/dietpi-software/installed/aria2.conf
[Install]
WantedBy=multi-user.target
@@ -11084,7 +11229,7 @@ _EOF_
#services
cat << _EOF_ > /etc/systemd/system/syncthing.service
[Unit]
-Description=Syncthing
+Description=Syncthing (DietPi)
After=network.target
[Service]
@@ -11117,36 +11262,18 @@ _EOF_
fi
- #SICKRAGE
+ #Medusa
software_id=116
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then
Banner_Configuration
- useradd -rM sickrage -G dietpi -s /usr/sbin/nologin
-
- cat << _EOF_ > /etc/systemd/system/sickrage.service
-[Unit]
-Description=SickRage
-
-[Service]
-User=sickrage
-Group=dietpi
-Type=forking
-GuessMainPID=no
-WorkingDirectory=$G_FP_DIETPI_USERDATA/sickrage
-TimeoutSec=infinity
-TimeoutStopSec=20
-Restart=always
-ExecStart=$(which python) $G_FP_DIETPI_USERDATA/sickrage/SiCKRAGE.py -d --nolaunch --datadir=$G_FP_DIETPI_USERDATA/sickrage
-
-[Install]
-WantedBy=multi-user.target
-_EOF_
+ useradd -rM medusa -G dietpi -d $G_FP_DIETPI_USERDATA/medusa -s /usr/sbin/nologin
- chown -R sickrage:dietpi $G_FP_DIETPI_USERDATA/sickrage # also applied in /DietPi/dietpi/func/dietpi-set_software setpermissions
- > /var/log/sickrage.log
- chown sickrage:dietpi /var/log/sickrage.log # also applied in /DietPi/dietpi/func/dietpi-set_software setpermissions
+ cp $G_FP_DIETPI_USERDATA/medusa/runscripts/init.systemd /etc/systemd/system/medusa.service
+ G_CONFIG_INJECT 'Group=' 'Group=dietpi' /etc/systemd/system/medusa.service '\[Service\]'
+ G_CONFIG_INJECT 'ExecStart=' "ExecStart=$(command -v python) $G_FP_DIETPI_USERDATA/medusa/start.py -q --daemon --nolaunch --datadir=$G_FP_DIETPI_USERDATA/medusa" /etc/systemd/system/medusa.service
+ chmod 644 /etc/systemd/system/medusa.service
fi
@@ -11161,7 +11288,7 @@ _EOF_
#service
cat << _EOF_ > /etc/systemd/system/tonido.service
[Unit]
-Description=Tonido - DietPi
+Description=Tonido (DietPi)
[Service]
Type=simple
@@ -11277,11 +11404,11 @@ URL=\$(grep -m1 '^[[:blank:]]*SOFTWARE_CHROMIUM_AUTOSTART_URL=' /DietPi/dietpi.t
CHROMIUM_OPTS+=" --homepage \$URL"
#Find absolute filepath location of Chromium binary.
-FP_CHROMIUM=\$(which chromium)
+FP_CHROMIUM=\$(command -v chromium)
if [[ ! \$FP_CHROMIUM ]]; then
# - Assume RPi
- FP_CHROMIUM="\$(which chromium-browser)"
+ FP_CHROMIUM="\$(command -v chromium-browser)"
fi
@@ -11361,17 +11488,17 @@ public = no
#localDumpFile = $G_FP_DIETPI_USERDATA/darkice_recording.ogg
_EOF_
- #SystemD service for Darkice
+ #Systemd service for Darkice
rm /etc/init.d/darkice
cat << _EOF_ > /etc/systemd/system/darkice.service
[Unit]
-Description=DarkIce - DietPi
+Description=DarkIce (DietPi)
After=icecast2.service
Requires=icecast2.service
[Service]
Type=simple
-ExecStart=$(which darkice)
+ExecStart=$(command -v darkice)
[Install]
WantedBy=multi-user.target
@@ -11388,12 +11515,12 @@ _EOF_
rm /etc/init.d/mosquitto
cat << _EOF_ > /etc/systemd/system/mosquitto.service
[Unit]
-Description=Mosquitto
+Description=Mosquitto (DietPi)
After=network.target
[Service]
Type=simple
-ExecStart=$(which mosquitto) -c /etc/mosquitto/mosquitto.conf
+ExecStart=$(command -v mosquitto) -c /etc/mosquitto/mosquitto.conf
[Install]
WantedBy=multi-user.target
@@ -11407,22 +11534,29 @@ _EOF_
Banner_Configuration
- local config_file_url_address='https://raw.githubusercontent.com/blynkkk/blynk-server/master/server/core/src/main/resources/server.properties'
- G_RUN_CMD wget "$config_file_url_address" -O $G_FP_DIETPI_USERDATA/blynk/server.properties
- G_CONFIG_INJECT 'data.folder=' "data.folder=$G_FP_DIETPI_USERDATA/blynk/data" $G_FP_DIETPI_USERDATA/blynk/server.properties
+ # - Preserve existing config
+ if [[ ! -f $G_FP_DIETPI_USERDATA/blynk/server.properties ]]; then
- # - service
- cat << _EOF_ > /etc/systemd/system/blynkserver.service
+ local config_file_url_address='https://raw.githubusercontent.com/blynkkk/blynk-server/master/server/core/src/main/resources/server.properties'
+ G_RUN_CMD wget "$config_file_url_address" -O $G_FP_DIETPI_USERDATA/blynk/server.properties
+ G_CONFIG_INJECT 'data.folder=' "data.folder=$G_FP_DIETPI_USERDATA/blynk/data" $G_FP_DIETPI_USERDATA/blynk/server.properties
+ fi
+
+ # - User
+ useradd -rM blynk -G dietpi -s /usr/sbin/nologin
+
+ # - Service
+ cat << _EOF_ > /etc/systemd/system/blynkserver.service
[Unit]
-Description=Blynk Server
+Description=Blynk Server (DietPi)
After=network.target
[Service]
Type=simple
User=blynk
Group=dietpi
-ExecStart=$(which java) -jar $G_FP_DIETPI_USERDATA/blynk/blynkserver.jar -serverConfig $G_FP_DIETPI_USERDATA/blynk/server.properties
+ExecStart=$(command -v java) -jar $G_FP_DIETPI_USERDATA/blynk/blynkserver.jar -serverConfig $G_FP_DIETPI_USERDATA/blynk/server.properties
[Install]
WantedBy=multi-user.target
@@ -11477,7 +11611,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/virtualhere.service
[Unit]
-Description=VirtualHere DietPi service
+Description=VirtualHere (DietPi)
After=local-fs.target
[Service]
@@ -11503,13 +11637,13 @@ _EOF_
useradd -rM sabnzbd -G dietpi -s /usr/sbin/nologin
cat << _EOF_ > /etc/systemd/system/sabnzbd.service
[Unit]
-Description=sabnzbd DietPi
+Description=sabnzbd (DietPi)
[Service]
User=sabnzbd
Group=dietpi
Type=simple
-ExecStart=$(which python) /etc/sabnzbd/SABnzbd.py -f /etc/sabnzbd/sabnzbd.ini
+ExecStart=$(command -v python) /etc/sabnzbd/SABnzbd.py -f /etc/sabnzbd/sabnzbd.ini
[Install]
WantedBy=multi-user.target
@@ -11566,7 +11700,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/spotify-connect-web.service
[Unit]
-Description=spotify-connect-web
+Description=spotify-connect-web (DietPi)
After=sound.target
[Service]
@@ -11621,7 +11755,7 @@ _EOF_
#G_CONFIG_INJECT 'ADMIN_EMAIL=' 'ADMIN_EMAIL=dietpi@dietpi.com' .env
#G_CONFIG_INJECT 'ADMIN_NAME=' 'ADMIN_NAME=admin' .env
#G_CONFIG_INJECT 'ADMIN_PASSWORD=' "ADMIN_PASSWORD=$GLOBAL_PW" .env
- G_CONFIG_INJECT 'FFMPEG_PATH=' "FFMPEG_PATH=$(which ffmpeg)" .env
+ G_CONFIG_INJECT 'FFMPEG_PATH=' "FFMPEG_PATH=$(command -v ffmpeg)" .env
php artisan koel:init
#php artisan db:seed --force
@@ -11630,14 +11764,14 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/koel.service
[Unit]
-Description=Koel
+Description=Koel (DietPi)
[Service]
Type=simple
User=koel
Group=dietpi
WorkingDirectory=$G_FP_DIETPI_USERDATA/koel
-ExecStart=$(which php) $G_FP_DIETPI_USERDATA/koel/artisan serve --host 0.0.0.0
+ExecStart=$(command -v php) $G_FP_DIETPI_USERDATA/koel/artisan serve --host 0.0.0.0
[Install]
WantedBy=multi-user.target
@@ -11657,7 +11791,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/sonarr.service
[Unit]
-Description=Sonarr (NzbDrone) Daemon
+Description=Sonarr (NzbDrone) Daemon (DietPi)
After=network.target
[Service]
@@ -11692,7 +11826,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/radarr.service
[Unit]
-Description=Radarr Daemon
+Description=Radarr Daemon (DietPi)
After=network.target
[Service]
@@ -11727,7 +11861,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/lidarr.service
[Unit]
-Description=lidarr (NzbDrone) Daemon
+Description=lidarr (NzbDrone) Daemon (DietPi)
After=network.target
[Service]
@@ -11762,7 +11896,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/plexpy.service
[Unit]
-Description=Tautulli - Stats for Plex Media Server usage
+Description=Tautulli - Stats for Plex Media Server usage (DietPi)
[Service]
Type=forking
@@ -11787,7 +11921,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/jackett.service
[Unit]
-Description=Jackett Daemon
+Description=Jackett Daemon (DietPi)
After=network.target
[Service]
@@ -11843,7 +11977,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/nzbget.service
[Unit]
-Description=NZBget
+Description=NZBget (DietPi)
[Service]
Type=forking
@@ -11866,7 +12000,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/htpc-manager.service
[Unit]
-Description=HTPC Manager
+Description=HTPC Manager (DietPi)
After=network.target
[Service]
@@ -11887,12 +12021,11 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/octoprint.service
[Unit]
-Description=OctoPrint
+Description=OctoPrint (DietPi)
[Service]
Type=simple
-User=root
-ExecStart=$(which octoprint) serve --iknowwhatimdoing
+ExecStart=$(command -v octoprint) serve --iknowwhatimdoing
[Install]
WantedBy=multi-user.target
@@ -11908,12 +12041,11 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/roonserver.service
[Unit]
-Description=Roon Server
+Description=Roon Server (DietPi)
After=network.target
[Service]
Type=simple
-User=root
Environment=ROON_DATAROOT=$G_FP_DIETPI_USERDATA/roonserver
ExecStart=$G_FP_DIETPI_USERDATA/roonserver/start.sh
@@ -11945,7 +12077,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/home-assistant.service
[Unit]
-Description=Home Assistant
+Description=Home Assistant (DietPi)
After=network.target
[Service]
@@ -12055,7 +12187,7 @@ _EOF_
# create systemd file
cat << _EOF_ > /etc/systemd/system/nukkit.service
[Unit]
-Description=nukkit
+Description=nukkit (DietPi)
[Service]
WorkingDirectory=/usr/local/bin/nukkit
@@ -12077,7 +12209,7 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/gitea.service
[Unit]
-Description=Gitea (Git with a cup of tea)
+Description=Gitea (DietPi)
[Service]
Type=simple
@@ -12140,7 +12272,7 @@ _EOF_
# - Disable onboard ETH if adapter found
cat << _EOF_ > /etc/systemd/system/sparky_eth_controller.service
[Unit]
-Description=Sparky auto detect and set onboard ETH/USB ETH
+Description=Sparky auto detect and set onboard ETH/USB ETH (DietPi)
After=network.target networking.service
[Service]
@@ -12196,14 +12328,14 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/gmrender.service
[Unit]
-Description=gmrender
+Description=GMrender (DietPi)
After=network.target
[Service]
Type=simple
User=gmrender
Group=dietpi
-ExecStart=$(which gmediarender) -u "$(sed -n 5p /DietPi/dietpi/.hw_model)" -f "$(cat /etc/hostname)" --gstout-audiodevice=sysdefault --gstout-initial-volume-db=-1 --logfile=/var/log/gmrender.log
+ExecStart=$(command -v gmediarender) -u "$(sed -n 5p /DietPi/dietpi/.hw_model)" -f "$(cat /etc/hostname)" --gstout-audiodevice=sysdefault --gstout-initial-volume-db=-1 --logfile=/var/log/gmrender.log
[Install]
WantedBy=multi-user.target
@@ -12262,12 +12394,11 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/pi-spc.service
[Unit]
-Description=AudioPhonics Pi-SPC
+Description=AudioPhonics Pi-SPC (DietPi)
[Service]
Type=simple
StandardOutput=tty
-User=root
ExecStart=/bin/bash -c '/var/lib/dietpi/dietpi-software/installed/pi-spc/sds.sh'
@@ -12386,7 +12517,7 @@ _EOF_
Banner_Configuration
fi
-
+
#------------------------------------------------------------------
}
@@ -12397,24 +12528,30 @@ _EOF_
local gpu_memory=0
#Define Memory Split Modes with installed software
- #Mode 4 RPI ONLY (Descent HIGH GPU RAM / 192MB)
- if (( ${aSOFTWARE_INSTALL_STATE[112]} == 2 )); then
+ local hw_memory_size=$(cat /DietPi/dietpi/.hw_model | grep -m1 'HW_MEMORY_SIZE=' | sed 's/^[^=]*=//')
+
+ # - Kodi
+ if (( ${aSOFTWARE_INSTALL_STATE[31]} == 2 )); then
+
+ gpu_enabled=1
+ gpu_memory=320
+ (( $hw_memory_size <= 512 )) && gpu_memory=256
+
+ # - Mode 4 (Descent)
+ elif (( ${aSOFTWARE_INSTALL_STATE[112]} == 2 )); then
gpu_enabled=1
gpu_memory=192
- #Define Memory Split Modes with installed software
- #Mode 3 (KODI / DIETPICAM / UAE4ARM / Chromium / MED GPU RAM / 128MB)
- elif (( ${aSOFTWARE_INSTALL_STATE[31]} == 2 ||
- ${aSOFTWARE_INSTALL_STATE[59]} == 2 ||
+ # - Mode 3 (DIETPICAM / UAE4ARM / Chromium)
+ elif (( ${aSOFTWARE_INSTALL_STATE[59]} == 2 ||
${aSOFTWARE_INSTALL_STATE[108]} == 2 ||
${aSOFTWARE_INSTALL_STATE[113]} == 2 )); then
gpu_enabled=1
gpu_memory=128
- #Mode 2 (Desktop / LOW GPU RAM)
- #All DESKTOP_* and OPENTYRIAN
+ # - Mode 2 (Desktops / OpenTyrian)
elif (( ${aSOFTWARE_INSTALL_STATE[23]} == 2 ||
${aSOFTWARE_INSTALL_STATE[24]} == 2 ||
${aSOFTWARE_INSTALL_STATE[25]} == 2 ||
@@ -12424,7 +12561,7 @@ _EOF_
gpu_enabled=1
gpu_memory=64
- #Mode 1 - DIETPICLOUDSHELL (forces display output)
+ # - Mode 1 - DIETPICLOUDSHELL (forces display output)
elif (( ${aSOFTWARE_INSTALL_STATE[62]} == 2 )); then
gpu_enabled=1
@@ -12438,35 +12575,15 @@ _EOF_
if (( $G_HW_MODEL < 10 )); then
# - Never override a higher existing value
- local current_gpu_mem=$(grep -m1 '^[[:blank:]]*gpu_mem' /DietPi/config.txt | sed 's/^[^=]*=//g')
+ local current_gpu_mem=$(grep -m1 '^[[:blank:]]*gpu_mem_1024' /DietPi/config.txt | sed 's/^[^=]*=//g')
(( $current_gpu_mem <= $gpu_memory )) && /DietPi/dietpi/func/dietpi-set_hardware gpumemsplit $gpu_memory
fi
fi
- if (( $gpu_enabled )); then
-
- #RPi
- if (( $G_HW_MODEL < 10 )); then
-
- sed -i '/CONFIG_HDMI_OUTPUT=/c\CONFIG_HDMI_OUTPUT=1' /DietPi/dietpi.txt
-
- #odroid C1
- elif (( $G_HW_MODEL == 10 )); then
-
- sed -i '/setenv hdmioutput /c\setenv hdmioutput "1"' /DietPi/boot.ini
- sed -i '/setenv vpu /c\setenv vpu "1"' /DietPi/boot.ini
- sed -i '/setenv m_bpp /c\setenv m_bpp "32"' /DietPi/boot.ini
-
- #Odroid C2
- elif (( $G_HW_MODEL == 12 )); then
-
- sed -i '/setenv nographics /c\setenv nographics "0"' /DietPi/boot.ini
-
- fi
-
- fi
+ #Disable headless/enable GPU's
+ (( $gpu_enabled )) && /DietPi/dietpi/func/dietpi-set_hardware headless 0
}
@@ -12490,10 +12607,10 @@ _EOF_
#NB: systemctl daemon-reload is executed at the end of this function
- local software_id=0
+ local software_id=-1
software_id=23
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
apt-mark unhold pcmanfm #RPi
@@ -12503,7 +12620,7 @@ _EOF_
fi
software_id=24
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP mate-desktop-environment-extras upower policykit-1 firefox-esr
@@ -12511,7 +12628,7 @@ _EOF_
fi
software_id=26
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP x-window-system-core wmaker gnustep gnustep-devel gnustep-games upower policykit-1 firefox-esr
@@ -12519,7 +12636,7 @@ _EOF_
fi
software_id=25
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP xfce4 gnome-icon-theme tango-icon-theme firefox-esr
@@ -12527,7 +12644,7 @@ _EOF_
fi
software_id=22
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP quiterss
@@ -12535,7 +12652,7 @@ _EOF_
fi
software_id=30
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP nomachine
@@ -12543,7 +12660,7 @@ _EOF_
fi
software_id=29
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP xrdp
@@ -12551,7 +12668,7 @@ _EOF_
fi
software_id=44
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP transmission-daemon
@@ -12562,7 +12679,7 @@ _EOF_
#ownCloud
software_id=47
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
# Remove background cron job
@@ -12607,7 +12724,7 @@ _EOF_
#Nextcloud Talk + TURN server "coturn"
software_id=168
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP coturn
@@ -12620,7 +12737,7 @@ _EOF_
#Nextcloud
software_id=114
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
crontab -u www-data -l | grep -v '/var/www/nextcloud/cron.php' | crontab -u www-data -
@@ -12665,7 +12782,7 @@ _EOF_
fi
software_id=83
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP apache2
@@ -12673,7 +12790,7 @@ _EOF_
fi
software_id=85
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP nginx $(dpkg --get-selections nginx-* | awk '{print $1}')
@@ -12681,7 +12798,7 @@ _EOF_
fi
software_id=84
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP lighttpd
@@ -12694,7 +12811,7 @@ _EOF_
fi
software_id=87
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP sqlite3
@@ -12702,7 +12819,7 @@ _EOF_
fi
software_id=91
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP "$PHP_BINARY"-redis redis-server redis-tools
@@ -12710,7 +12827,7 @@ _EOF_
fi
software_id=89
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm $FP_PHP_BASE_DIR/fpm/pool.d/www.conf 2> /dev/null
@@ -12725,7 +12842,7 @@ _EOF_
fi
software_id=90
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
systemctl start $MARIADB_SERVICE
@@ -12736,7 +12853,7 @@ _EOF_
fi
software_id=54
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
systemctl start $MARIADB_SERVICE
@@ -12747,7 +12864,7 @@ _EOF_
fi
software_id=115
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP webmin
@@ -12756,7 +12873,7 @@ _EOF_
fi
software_id=32
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
userdel -rf ympd
@@ -12766,31 +12883,34 @@ _EOF_
fi
software_id=148
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
userdel -rf mympd
rm -R /etc/mympd
rm -R /usr/share/mympd
- rm $(which mympd)
+ rm $(command -v mympd)
rm /lib/systemd/system/mympd.service
fi
software_id=128
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
#apt-mark auto libavformat57 libupnp6 libao-common libao4 libasound2 libasound2-data libasyncns0 libaudiofile1 libavahi-client3 libavahi-common-data libavahi-common3 libavcodec56 libavformat56 libavresample2 libavutil54 libbinio1ldbl libcaca0 libcdio-cdda1 libcdio-paranoia1 libcdio13 libcups2 libcurl3-gnutls libdirectfb-1.2-9 libdnet libfaad2 libflac8 libfluidsynth1 libgme0 libgomp1 libgsm1 libice6 libid3tag0 libiso9660-8 libjack-jackd2-0 libjson-c2 libldb1 libmad0 libmikmod3 libmms0 libmodplug1 libmp3lame0 libmpcdec6 libmpg123-0 libnfs4 libntdb1 libogg0 libopenal-data libopenal1 libopenjpeg5 libopus0 liborc-0.4-0 libpulse0 libresid-builder0c2a libroar2 libsamplerate0 libschroedinger-1.0-0 libsdl1.2debian libshout3 libsidplay2 libsidutils0 libslp1 libsm6 libsmbclient libsndfile1 libsoxr0 libspeex1 libspeexdsp1 libsqlite3-0 libtalloc2 libtdb1 libtevent0 libtheora0 libupnp6 libva1 libvorbis0a libvorbisenc2 libvorbisfile3 libvpx1 libwavpack1 libwbclient0 libwildmidi-config libwildmidi1 libx11-6 libx11-data libx11-xcb1 libx264-142 libxau6 libxcb1 libxdmcp6 libxext6 libxi6 libxtst6 libxvidcore4 libyajl2 libzzip-0-13 mime-support python python-talloc python2.7 samba-libs x11-common file &> /dev/null
apt-mark unhold mpd 1> /dev/null
G_AGP mpd libmpdclient2
- userdel -rf mpd
- rm /lib/systemd/system/mpd.service
- rm -R $G_FP_DIETPI_USERDATA/.mpd_cache
+ getent passwd mpd &> /dev/null && userdel -rf mpd
+ [[ -f /lib/systemd/system/mpd.service ]] && rm /lib/systemd/system/mpd.service
+ [[ -d $G_FP_DIETPI_USERDATA/.mpd_cache ]] && rm -R $G_FP_DIETPI_USERDATA/.mpd_cache
+ [[ -f /usr/local/etc/mpd.conf ]] && rm /usr/local/etc/mpd.conf && rmdir --ignore-fail-on-non-empty /usr/local/etc
+ [[ -f /etc/mpd.conf ]] && rm /etc/mpd.conf
+ [[ -f /etc/default/mpd ]] && rm /etc/default/mpd # pre-v6.20
fi
software_id=122
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
npm r -g node-red
@@ -12804,7 +12924,7 @@ _EOF_
fi
software_id=123
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP mosquitto
@@ -12814,7 +12934,7 @@ _EOF_
fi
software_id=124
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
#apt-mark auto gcc-6-base libstdc++6 &> /dev/null
@@ -12823,7 +12943,7 @@ _EOF_
fi
software_id=125
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP tomcat8
@@ -12831,7 +12951,7 @@ _EOF_
fi
software_id=126
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
apt-mark auto libssl1.0.0
@@ -12839,7 +12959,7 @@ _EOF_
fi
software_id=129
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R /var/www/ompd
@@ -12850,7 +12970,7 @@ _EOF_
fi
software_id=130
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP python-pip python3-pip
@@ -12858,19 +12978,19 @@ _EOF_
fi
software_id=131
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
- rm /etc/systemd/system/blynkserver.service
- rm -R $G_FP_DIETPI_USERDATA/blynk
- rm -R /etc/blynkserver #pre v6.19
+ [[ -f /etc/systemd/system/blynkserver.service ]] && rm /etc/systemd/system/blynkserver.service
+ [[ -d $G_FP_DIETPI_USERDATA/blynk ]] && rm -R $G_FP_DIETPI_USERDATA/blynk
+ [[ -d /etc/blynkserver ]] && rm -R /etc/blynkserver #pre v6.19
- userdel -f blynk
+ userdel -rf blynk
fi
software_id=132
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm /etc/systemd/system/aria2.service
@@ -12883,7 +13003,7 @@ _EOF_
fi
software_id=133
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm /etc/systemd/system/yacy.service
@@ -12892,7 +13012,7 @@ _EOF_
fi
software_id=2
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP fahclient
@@ -12904,7 +13024,7 @@ _EOF_
fi
software_id=134
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
#apt-mark auto libjpeg8 libpng12-0 libfontconfig1 libssl1.0.0 &> /dev/null
@@ -12918,7 +13038,7 @@ _EOF_
fi
software_id=135
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP darkice icecast2
@@ -12927,7 +13047,7 @@ _EOF_
fi
software_id=136
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
#apt-mark auto v4l-utils python python-dev libssl-dev libcurl4-openssl-dev libjpeg-dev zlib1g-dev libx264-142 libavcodec56 libavformat56 libmysqlclient18 libswscale3 libpq5 &> /dev/null
@@ -12939,7 +13059,7 @@ _EOF_
fi
software_id=137
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP cloudprint-service
@@ -12953,7 +13073,7 @@ _EOF_
fi
software_id=138
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R /etc/vhusbd
@@ -12962,7 +13082,7 @@ _EOF_
fi
software_id=139
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
userdel -rf sabnzbd
@@ -12972,7 +13092,7 @@ _EOF_
fi
software_id=140
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP libsdl2 libsdl2-image libsdl2-mixer libsdl2-net libsdl2-ttf libsmpeg2
@@ -12980,7 +13100,7 @@ _EOF_
fi
software_id=141
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R $G_FP_DIETPI_USERDATA/spotify-connect-web
@@ -12989,7 +13109,7 @@ _EOF_
fi
software_id=142
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R /etc/couchpotato
@@ -13000,7 +13120,7 @@ _EOF_
fi
software_id=143
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
@@ -13018,7 +13138,7 @@ _EOF_
fi
software_id=144
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
@@ -13038,7 +13158,7 @@ _EOF_
fi
software_id=145
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
@@ -13053,7 +13173,7 @@ _EOF_
fi
software_id=106
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
@@ -13068,7 +13188,7 @@ _EOF_
fi
software_id=146
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R /opt/plexpy
@@ -13080,7 +13200,7 @@ _EOF_
fi
software_id=147
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
userdel -rf jackett
@@ -13090,7 +13210,7 @@ _EOF_
fi
software_id=149
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R $G_FP_DIETPI_USERDATA/nzbget
@@ -13101,7 +13221,7 @@ _EOF_
fi
software_id=155
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R $G_FP_DIETPI_USERDATA/htpc-manager
@@ -13110,7 +13230,7 @@ _EOF_
fi
software_id=150
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
apt-mark auto mono-complete mono-devel mono-runtime libmono-cil-dev 2>/dev/null
@@ -13120,7 +13240,7 @@ _EOF_
fi
software_id=151
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP nvidia-driver nvidia-xconfig libgl1-nvidia-glx:i386
@@ -13128,7 +13248,7 @@ _EOF_
fi
software_id=152
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP avahi-daemon
@@ -13136,11 +13256,11 @@ _EOF_
fi
software_id=153
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R $G_FP_DIETPI_USERDATA/octoprint
- rm $(which octoprint)
+ rm $(command -v octoprint)
rm -R $HOME/.octoprint
rm /etc/systemd/system/octoprint.service
@@ -13148,7 +13268,7 @@ _EOF_
software_id=121
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm /etc/systemd/system/roonbridge.service
@@ -13158,7 +13278,7 @@ _EOF_
fi
software_id=154
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
[[ -d $G_FP_DIETPI_USERDATA/roonserver ]] && rm -R $G_FP_DIETPI_USERDATA/roonserver
@@ -13167,7 +13287,7 @@ _EOF_
fi
software_id=156
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP steam
@@ -13177,7 +13297,7 @@ _EOF_
fi
software_id=119
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP cava
@@ -13187,33 +13307,33 @@ _EOF_
fi
software_id=118
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP mopidy
- rm /etc/apt/sources.list.d/mopidy.list
- rm -R $G_FP_DIETPI_USERDATA/mopidy
+ [[ -f /etc/apt/sources.list.d/mopidy.list ]] && rm /etc/apt/sources.list.d/mopidy.list
- userdel -rf mopidy
+ command -v pip &> /dev/null && pip uninstall -y Mopidy-MusicBox-Webclient Mopidy-Local-Images
- pip uninstall -y Mopidy-MusicBox-Webclient Mopidy-Local-Images
+ getent passwd mopidy &> /dev/null && userdel -rf mopidy
+ [[ -d $G_FP_DIETPI_USERDATA/mopidy ]] && rm -R $G_FP_DIETPI_USERDATA/mopidy
fi
software_id=31
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP kodi kodi-odroid
[[ -f /usr/share/applications/kodi.desktop ]] && rm /usr/share/applications/kodi.desktop
[[ -f /root/Desktop/kodi.desktop ]] && rm /root/Desktop/kodi.desktop
- rm /home/*/Desktop/kodi.desktop &> /dev/null
+ rm -f /home/*/Desktop/kodi.desktop
[[ -f /etc/udev/rules.d/99-dietpi-kodi.rules ]] && rm /etc/udev/rules.d/99-dietpi-kodi.rules
fi
software_id=39
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP minidlna
@@ -13226,7 +13346,7 @@ _EOF_
fi
software_id=51
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP ibsdl1.2debian libsdl-net1.2
@@ -13237,7 +13357,7 @@ _EOF_
fi
software_id=59
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP gpac
@@ -13251,7 +13371,7 @@ _EOF_
fi
software_id=45
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP deluged deluge-web deluge-webui deluge-console
@@ -13264,7 +13384,7 @@ _EOF_
fi
software_id=94
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP proftpd-basic
@@ -13272,15 +13392,17 @@ _EOF_
fi
software_id=96
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP samba samba-common-bin
+ [[ -f /etc/tmpfiles.d/dietpi-samba_cache.conf ]] && rm /etc/tmpfiles.d/dietpi-samba_cache.conf
+ [[ -d /var/run/samba-cache ]] && rm -R /var/run/samba-cache
fi
software_id=95
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP vsftpd
@@ -13288,7 +13410,7 @@ _EOF_
fi
software_id=109
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP nfs-kernel-server
@@ -13296,24 +13418,25 @@ _EOF_
fi
software_id=67
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
- rm /usr/local/bin/noip2
- rm /etc/systemd/system/noip2.service
+ [[ -f /usr/local/bin/noip2 ]] && rm /usr/local/bin/noip2
+ [[ -f /usr/local/etc/no-ip2.conf ]] && rm /usr/local/etc/no-ip2.conf
+ [[ -f /etc/systemd/system/noip2.service ]] && rm /etc/systemd/system/noip2.service
fi
software_id=63
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
- rm -R /var/www/linuxdash
+ [[ -d /var/www/linuxdash ]] && rm -R /var/www/linuxdash
fi
software_id=93
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
pihole uninstall
@@ -13341,28 +13464,27 @@ _EOF_
fi
- software_id=33
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ software_id=33 # Airsonic
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
- rm -R $G_FP_DIETPI_USERDATA/airsonic
- rm /etc/systemd/system/airsonic.service
-
- userdel -rf airsonic
+ getent passwd airsonic &> /dev/null && userdel -rf airsonic
+ [[ -d $G_FP_DIETPI_USERDATA/airsonic ]] && rm -R $G_FP_DIETPI_USERDATA/airsonic
+ [[ -f /etc/systemd/system/airsonic.service ]] && rm /etc/systemd/system/airsonic.service
fi
- software_id=34
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ software_id=34 # Subsonic
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP subsonic
- rm -R /var/subsonic
+ [[ -d /var/subsonic ]] && rm -R /var/subsonic
fi
software_id=71
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
update-rc.d webiopi remove
@@ -13374,7 +13496,7 @@ _EOF_
fi
software_id=68
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
# <= v150 (weaved)
@@ -13388,7 +13510,7 @@ _EOF_
fi
software_id=62
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
#Kill
@@ -13404,7 +13526,7 @@ _EOF_
fi
software_id=98
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
update-rc.d haproxy remove
@@ -13418,7 +13540,7 @@ _EOF_
fi
software_id=35
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
#apt-mark auto libxml-parser-perl zlib1g-dev libjpeg-dev libpng-dev libjpeg62-turbo-dev &> /dev/null
@@ -13430,7 +13552,7 @@ _EOF_
fi
software_id=55
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
systemctl start $MARIADB_SERVICE
@@ -13442,7 +13564,7 @@ _EOF_
fi
software_id=38
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
@@ -13462,9 +13584,9 @@ _EOF_
fi
software_id=27
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )) ||
- (( aSOFTWARE_INSTALL_STATE[28] == -1 )) ||
- (( aSOFTWARE_INSTALL_STATE[120] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )) ||
+ (( ${aSOFTWARE_INSTALL_STATE[28]} == -1 )) ||
+ (( ${aSOFTWARE_INSTALL_STATE[120]} == -1 )); then
Banner_Uninstalling
G_AGP tightvncserver $(dpkg --get-selections tigervnc-* | awk '{print $1}') vnc4server x11vnc realvnc-vnc-server
@@ -13481,7 +13603,7 @@ _EOF_
fi
software_id=73
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP fail2ban
@@ -13489,7 +13611,7 @@ _EOF_
fi
software_id=64
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R /var/www/phpsysinfo
@@ -13497,7 +13619,7 @@ _EOF_
fi
software_id=56
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm /var/www/gallery/index.php
@@ -13506,7 +13628,7 @@ _EOF_
fi
software_id=40
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R /var/www/ampache
@@ -13519,7 +13641,7 @@ _EOF_
fi
software_id=117
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm /etc/apt/sources.list.d/swupdate.openvpn.net.list
@@ -13529,38 +13651,59 @@ _EOF_
fi
software_id=97
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP openvpn
- rm -R /etc/openvpn &> /dev/null
+ [[ -d /etc/openvpn ]] && rm -R /etc/openvpn
+
+ fi
+
+ software_id=172 # WireGuard
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
+
+ Banner_Uninstalling
+ G_AGP wireguard*
+ [[ -d /etc/wireguard ]] && rm -R /etc/wireguard
+ [[ -f /etc/apt/sources.d/dietpi-wireguard.list ]] && rm /etc/apt/sources.d/dietpi-wireguard.list
+ [[ -f /etc/apt/preferences.d/dietpi-wireguard ]] && rm /etc/apt/preferences.d/dietpi-wireguard
+ [[ -f /etc/sysctl.d/dietpi-wireguard.conf ]] && rm /etc/sysctl.d/dietpi-wireguard.conf
+
+ fi
+
+ software_id=171
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
+
+ Banner_Uninstalling
+ rm -R /etc/openvpn/ovpn_tcp/*nordvpn* /etc/openvpn/ovpn_udp/*nordvpn*
+ rm -R /var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn /lib/systemd/system/dietpi-nordvpn.service &> /dev/null
fi
software_id=92
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
if (( $G_DISTRO >= 4 )); then
G_AGP python-certbot-apache python-certbot-nginx certbot
- [ -f /etc/systemd/system/certbot.service ] && rm /etc/systemd/system/certbot.service
- [ -d /etc/systemd/system/certbot.service.d ] && rm -R /etc/systemd/system/certbot.service.d
+ [[ -f /etc/systemd/system/certbot.service ]] && rm /etc/systemd/system/certbot.service
+ [[ -d /etc/systemd/system/certbot.service.d ]] && rm -R /etc/systemd/system/certbot.service.d
else
# Pre-reqs: https://github.com/certbot/certbot/blob/master/certbot-auto#L390-L399
#apt-mark auto python python-dev virtualenv python-virtualenv gcc libaugeas0 augeas-lenses libssl-dev openssl libffi-dev ca-certificates
- [ -d /etc/certbot_scripts ] && rm -R /etc/certbot_scripts
- [ -f /etc/cron.weekly/dietpi-letsencrypt ] && rm /etc/cron.weekly/dietpi-letsencrypt
- [ -f /home/minio-user/.minio/dietpi-cert-renewl.sh ] && rm /home/minio-user/.minio/dietpi-cert-renewl.sh
+ [[ -d /etc/certbot_scripts ]] && rm -R /etc/certbot_scripts
+ [[ -f /etc/cron.weekly/dietpi-letsencrypt ]] && rm /etc/cron.weekly/dietpi-letsencrypt
+ [[ -f /home/minio-user/.minio/dietpi-cert-renewl.sh ]] && rm /home/minio-user/.minio/dietpi-cert-renewl.sh
fi
fi
software_id=69
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP python-rpi.gpio python3-rpi.gpio
@@ -13568,7 +13711,7 @@ _EOF_
fi
software_id=72
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP i2c-tools
@@ -13578,7 +13721,7 @@ _EOF_
fi
software_id=70
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R /root/wiringPi* &> /dev/null
@@ -13586,7 +13729,7 @@ _EOF_
fi
software_id=61
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP tor
@@ -13597,7 +13740,7 @@ _EOF_
fi
software_id=60
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
#apt-mark auto libssl1.0.0 &> /dev/null
@@ -13640,7 +13783,7 @@ _EOF_
fi
software_id=37
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
#apt-mark auto libssl1.0.0 openssl libsoxr0 libavahi-client3 libtool libconfig9 libpopt0 libdaemon0 &> /dev/null
@@ -13653,16 +13796,16 @@ _EOF_
fi
software_id=48
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R /var/www/pydio
# Remove webserver configs
- [[ $(which a2dissite) ]] && a2dissite dietpi-pydio
+ command -v a2dissite &> /dev/null && a2dissite dietpi-pydio
[[ -f /etc/apache2/conf-available/dietpi-pydio.conf ]] && rm /etc/apache2/conf-available/dietpi-pydio.conf
[[ -f /etc/nginx/sites-dietpi/dietpi-pydio.conf ]] && rm /etc/nginx/sites-dietpi/dietpi-pydio.conf
- [[ $(which lighttpd-disable-mod) ]] && lighttpd-disable-mod dietpi-pydio
+ command -v lighttpd-disable-mod &> /dev/null && lighttpd-disable-mod dietpi-pydio
[[ -f /etc/lighttpd/conf-available/99-dietpi-pydio.conf ]] && rm /etc/lighttpd/conf-available/99-dietpi-pydio.conf
# Drop database
@@ -13673,7 +13816,7 @@ _EOF_
fi
software_id=36
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP squeezelite
@@ -13684,7 +13827,7 @@ _EOF_
fi
software_id=99
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R /etc/emonhub
@@ -13694,7 +13837,7 @@ _EOF_
fi
software_id=66
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP rpimonitor
@@ -13702,7 +13845,7 @@ _EOF_
fi
software_id=57
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R /var/www/baikal
@@ -13724,7 +13867,7 @@ _EOF_
fi
software_id=65
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
#apt-mark auto zlib1g-dev &> /dev/null
@@ -13751,7 +13894,7 @@ _EOF_
fi
software_id=43
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP mumble-server
@@ -13759,7 +13902,7 @@ _EOF_
fi
software_id=41
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP emby-server embymagick
@@ -13775,7 +13918,7 @@ _EOF_
fi
software_id=58
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
@@ -13786,18 +13929,18 @@ _EOF_
fi
software_id=42
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP $(dpkg --get-selections plexmediaserver* | awk '{print $1}')
- rm -R /var/lib/plexmediaserver
- rm /etc/apt/sources.list.d/plex.list 2> /dev/null && G_AGUP
+ [[ -d /var/lib/plexmediaserver ]] && rm -R /var/lib/plexmediaserver
+ [[ -f etc/apt/sources.list.d/plex.list ]] && rm /etc/apt/sources.list.d/plex.list && G_AGUP
[[ -d /etc/systemd/system/plexmediaserver.service.d ]] && rm -R /etc/systemd/system/plexmediaserver.service.d # post v6.17
fi
software_id=52
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R /etc/cuberite &> /dev/null #v6.11<
@@ -13809,7 +13952,7 @@ _EOF_
fi
software_id=53
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R $G_FP_DIETPI_USERDATA/mineos
@@ -13825,7 +13968,7 @@ _EOF_
fi
software_id=49
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
@@ -13842,20 +13985,20 @@ _EOF_
fi
software_id=46
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP qbittorrent-nox
userdel -rf qbittorrent
- rm /etc/systemd/system/qbittorrent.service
- rm -R /home/qbittorrent
+ [[ -f /etc/systemd/system/qbittorrent.service ]] && rm /etc/systemd/system/qbittorrent.service
+ [[ -d /home/qbittorrent ]] && rm -R /home/qbittorrent
fi
software_id=50
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
@@ -13870,21 +14013,18 @@ _EOF_
fi
software_id=116
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
-
- rm /etc/systemd/system/sickrage.service
-
- rm -R /etc/sickrage &> /dev/null # v6.11<
- rm -R $G_FP_DIETPI_USERDATA/sickrage
-
- userdel -rf sickrage
+ rm /etc/systemd/system/medusa.service
+ rm -R $G_FP_DIETPI_USERDATA/medusa
+ userdel -rf medusa
+ #apt-mark auto python libssl-dev
fi
software_id=107
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP rtorrent
@@ -13903,13 +14043,13 @@ _EOF_
rm /etc/nginx/sites-dietpi/dietpi-rutorrent.conf
# apache2
- which a2dissite &> /dev/null && a2dissite dietpi-rutorrent
+ command -v a2dissite &> /dev/null && a2dissite dietpi-rutorrent
rm /etc/apache2/sites-available/dietpi-rutorrent.conf
fi
software_id=108
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R $G_FP_DIETPI_USERDATA/amiberry
@@ -13921,7 +14061,7 @@ _EOF_
fi
software_id=112
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm $G_FP_DIETPI_USERDATA/dxx-rebirth/*
@@ -13937,7 +14077,7 @@ _EOF_
fi
software_id=113
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
#apt-mark auto libgnome-keyring0 libnspr4 libnss3 libnss3-1d libspeechd2 libxslt1.1 libxss1 xdg-utils libgnome-keyring-common libltdl7 &> /dev/null
@@ -13952,23 +14092,25 @@ _EOF_
fi
software_id=157
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
- # Remove installationof HA.
- rm -R /srv/homeassistant
+ #apt-mark auto cmake daemon gcc nmap net-tools swig uuid-dev libc-ares-dev libgnutls28-dev libgnutlsxx28 libglib2.0-dev libudev-dev libusb-1.0-0 libssl-dev libffi-dev libbz2-dev zlib1g-dev libreadline-dev libsqlite3-dev libncurses5-dev libncursesw5-dev
+
+ # Remove installation of HA.
+ [[ -d /srv/homeassistant ]] && rm -R /srv/homeassistant
# Remove the user and all files. This removed pyenv for this user as well.
- userdel -rf homeassistant
- groupdel homeassistant
+ getent passwd homeassistant &> /dev/null && userdel -rf homeassistant
+ getent group homeassistant &> /dev/null && groupdel homeassistant
# Remove the service.
- rm /etc/systemd/system/home-assistant.service
+ [[ -f /etc/systemd/system/home-assistant.service ]] && rm /etc/systemd/system/home-assistant.service
fi
software_id=165
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
# Delete systemd files
@@ -13986,7 +14128,7 @@ _EOF_
fi
software_id=166
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm /etc/systemd/system/pi-spc.service
@@ -13998,7 +14140,7 @@ _EOF_
fi
software_id=167
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP raspotify
@@ -14008,7 +14150,7 @@ _EOF_
fi
software_id=169
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
rm -R $G_FP_DIETPI_USERDATA/voice-recognizer-raspi
@@ -14019,7 +14161,7 @@ _EOF_
fi
software_id=100
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP pijuice-base
@@ -14028,7 +14170,7 @@ _EOF_
fi
software_id=158
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
# Remove service
@@ -14051,7 +14193,7 @@ _EOF_
fi
software_id=161
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
/etc/init.d/bdd stop
@@ -14069,12 +14211,12 @@ _EOF_
fi
software_id=162
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
# Remove docker, all its unused dependencies and custom repository
- G_AGP docker-ce docker-ce-cli docker docker-engine
+ G_AGP docker-ce docker-ce-cli docker-engine
[[ -f /etc/apt/sources.list.d/docker.list ]] && rm /etc/apt/sources.list.d/docker.list
# Remove service adjustments
@@ -14090,7 +14232,7 @@ _EOF_
fi
software_id=164
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
# Remove Service file
@@ -14102,7 +14244,7 @@ _EOF_
fi
software_id=163
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
#apt-mark auto libupnp6 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-alsa &> /dev/null
@@ -14114,8 +14256,8 @@ _EOF_
fi
software_id=159
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )) ||
- (( aSOFTWARE_INSTALL_STATE[160] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )) ||
+ (( ${aSOFTWARE_INSTALL_STATE[160]} == -1 )); then
Banner_Uninstalling
rm -R /var/www/allo
@@ -14128,7 +14270,7 @@ _EOF_
fi
software_id=88
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_WHIP_MSG "Creating MariaDB database backup before uninstallation:\n\nIn case of accident, we create a database backup for you. You can remove it manually, if you are sure, that you don't need it any more.\n\n$G_FP_DIETPI_USERDATA/mariadb-database-backup.sql"
@@ -14150,7 +14292,7 @@ _EOF_
fi
software_id=74
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
@@ -14164,21 +14306,21 @@ _EOF_
fi
- software_id=77
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ software_id=77 # Grafana
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP grafana
- rm /etc/apt/sources.list.d/grafana*.list &> /dev/null && G_AGUP
+ [[ -f /etc/apt/sources.list.d/grafana.list ]] && rm /etc/apt/sources.list.d/grafana.list
- rm -R /var/lib/grafana
- rm -R $G_FP_DIETPI_USERDATA/grafana
+ [[ -e /var/lib/grafana ]] && rm -R /var/lib/grafana
+ [[ -d $G_FP_DIETPI_USERDATA/grafana ]] && rm -R $G_FP_DIETPI_USERDATA/grafana
fi
software_id=80
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
@@ -14190,7 +14332,7 @@ _EOF_
fi
software_id=86
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
@@ -14209,7 +14351,7 @@ _EOF_
#LINUX SOFTWARE
software_id=15
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP tcpdump
@@ -14217,7 +14359,7 @@ _EOF_
fi
software_id=14
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP nload
@@ -14225,7 +14367,7 @@ _EOF_
fi
software_id=13
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP mtr-tiny
@@ -14233,7 +14375,7 @@ _EOF_
fi
software_id=11
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP iptraf
@@ -14241,7 +14383,7 @@ _EOF_
fi
software_id=10
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP iftop
@@ -14249,7 +14391,7 @@ _EOF_
fi
software_id=19
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP jed
@@ -14257,7 +14399,7 @@ _EOF_
fi
software_id=3
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP mc
@@ -14265,7 +14407,7 @@ _EOF_
fi
software_id=18
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP emacs
@@ -14273,8 +14415,8 @@ _EOF_
fi
software_id=20
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )) ||
- (( aSOFTWARE_INSTALL_STATE[21] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )) ||
+ (( ${aSOFTWARE_INSTALL_STATE[21]} == -1 )); then
Banner_Uninstalling
G_AGP vim vim-tiny
@@ -14282,7 +14424,7 @@ _EOF_
fi
software_id=127
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP neovim
@@ -14290,7 +14432,7 @@ _EOF_
fi
software_id=0
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
# This also removes OpenSSH server. So lets check OpenSSH server isn't installed before hand.
@@ -14303,7 +14445,7 @@ _EOF_
fi
software_id=1
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
umount -f /mnt/samba
@@ -14316,7 +14458,7 @@ _EOF_
fi
software_id=111
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP urbackup-server
@@ -14333,7 +14475,7 @@ _EOF_
fi
software_id=110
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
umount -f /mnt/nfs_client
@@ -14355,7 +14497,7 @@ _EOF_
fi
software_id=16
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP build-essential
@@ -14363,7 +14505,7 @@ _EOF_
fi
software_id=17
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP git
@@ -14371,7 +14513,7 @@ _EOF_
fi
software_id=5
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP alsa-utils
@@ -14379,7 +14521,7 @@ _EOF_
fi
software_id=6
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
#apt-mark auto xserver-xorg-video-armsoc libdrm-rockchip1 libmali-rk-utgard-450-r7p0 aml-libs-odroid mali450-odroid xf86-video-mali-odroid libump* xf86-video-fbturbo* firmware-samsung xf86-video-armsoc-odroid malit628-odroid &> /dev/null
@@ -14389,7 +14531,7 @@ _EOF_
fi
software_id=7
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP ffmpeg
@@ -14398,36 +14540,39 @@ _EOF_
fi
software_id=8
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
- apt-mark auto $(dpkg --get-selections default-jre* default-jdk* openjdk-8-jre* openjdk-8-jdk* | awk '{print $1}') ca-certificates-java
- rm /etc/apt/preferences.d/99-dietpi-openjdk-8-jdk &> /dev/null
+ apt-mark auto $(dpkg --get-selections default-jre* default-jdk* openjdk-* | awk '{print $1}') ca-certificates-java
+ [[ -f /etc/apt/preferences.d/99-dietpi-openjdk-8-jdk ]] && rm /etc/apt/preferences.d/99-dietpi-openjdk-8-jdk
fi
software_id=104
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
- G_AGP $(dpkg --get-selections dropbear* | awk '{print $1}') #stretch | dropbear-initramfs dropbear-run
+ G_AGP $(dpkg --get-selections dropbear* | awk '{print $1}') # Stretch: dropbear-initramfs dropbear-run
+
+ # Required on Jessie only, since ECDSA key is not created on install automatically, thus not removed on uninstall
+ [[ -d /etc/dropbear ]] && rm -R /etc/dropbear
fi
software_id=105
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP $(dpkg --get-selections openssh-* | awk '{print $1}')
- # This also clears Openssh-client
+ # This also clears OpenSSH client
aSOFTWARE_INSTALL_STATE[0]=0
fi
software_id=103
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
@@ -14450,8 +14595,9 @@ ExecStart=/bin/bash -c '/var/lib/dietpi/dietpi-ramlog/disable.sh &> /var/tmp/die
[Install]
WantedBy=local-fs.target
_EOF_
+
systemctl daemon-reload
- systemctl enable dietpi-ramlog_disable.service
+ systemctl enable dietpi-ramlog_disable
cat << _EOF_ > /var/lib/dietpi/dietpi-ramlog/disable.sh
#!/bin/bash
@@ -14471,7 +14617,7 @@ _EOF_
fi
software_id=101
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP logrotate
@@ -14479,7 +14625,7 @@ _EOF_
fi
software_id=102
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP rsyslog
@@ -14487,7 +14633,7 @@ _EOF_
fi
software_id=9
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
npm r -g n yarn npm
@@ -14519,14 +14665,22 @@ _EOF_
fi
software_id=4
- if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+ if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then
Banner_Uninstalling
G_AGP vifm
fi
- G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Finalize uninstall'
+ software_id=170
+ if (( aSOFTWARE_INSTALL_STATE[$software_id] == -1 )); then
+
+ Banner_Uninstalling
+ G_AGP unrar
+
+ fi
+
+ G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Finalise uninstall'
#Uninstall finished, set all uninstalled software to state 0 (not installed)
for i in ${!aSOFTWARE_INSTALL_STATE[@]}
@@ -14617,7 +14771,7 @@ _EOF_
# - Automation Set NTPD mode
# Due to possible packages required, must be done here after APT cache updated
- if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
+ if (( $G_DIETPI_INSTALL_STAGE == 1 )); then
/DietPi/dietpi/func/dietpi-set_software ntpd-mode $(grep -m1 '^[[:blank:]]*CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
@@ -14660,8 +14814,9 @@ _EOF_
/DietPi/dietpi/func/dietpi-set_software setpermissions &> /dev/null
# Apply autostart index
- local autostart_current="$( /DietPi/dietpi/.install_stage
- # Set Install Stage to Finished
- echo 1 > /DietPi/dietpi/.install_stage
+ fi
}
@@ -14820,39 +14975,6 @@ _EOF_
}
- FirstRun_DietPi_Update(){
-
- #Disable powersaving on main screen
- setterm -blank 0 -powersave off 2> /dev/null
-
- #-1 = 1st run | 0 = Reboot, updates applied | 1 = Idle, No updates
- #Update .update_stage file to completed
- echo 1 > /DietPi/dietpi/.update_stage
-
- #Check for updates and apply if needed (1=force apply updates).
- /DietPi/dietpi/dietpi-update 1
-
- #Check update stage file again (dietpi-update will set to 0 if an update was applied and requires a reboot)
- if (( $( /DietPi/dietpi/.update_stage
-
- #Prompt user for reboot
- if (( $G_USER_INPUTS )); then
-
- G_WHIP_MSG 'DietPi has been updated to the latest version.\n\nThe system will now reboot. Once completed, simply login to resume DietPi Setup. \n\nPress Enter to Continue.'
-
- fi
-
- #Reboot required NOW
- reboot
- exit
-
- fi
-
- }
-
#/////////////////////////////////////////////////////////////////////////////////////
# Globals
#/////////////////////////////////////////////////////////////////////////////////////
@@ -15000,85 +15122,33 @@ _EOF_
fi
- string+="=${aSOFTWARE_INSTALL_STATE[$i]} | ${aSOFTWARE_WHIP_NAME[$i]}: \e[0m\e[90m${aSOFTWARE_WHIP_DESC[$i]}\e[0m |"
-
- if (( ${aSOFTWARE_REQUIRES_ALSA[$i]:=0} == 1 )); then
-
- string+=' +ALSA'
-
- fi
-
- if (( ${aSOFTWARE_REQUIRES_XSERVERXORG[$i]:=0} == 1 )); then
-
- string+=' +XSERVER'
-
- fi
-
- if (( ${aSOFTWARE_REQUIRES_DESKTOP[$i]:=0} == 1 )); then
+ string+="=${aSOFTWARE_INSTALL_STATE[$i]} | ${aSOFTWARE_WHIP_NAME[$i]}:\e[0m \e[90m${aSOFTWARE_WHIP_DESC[$i]}\e[0m |"
- string+=' +DESKTOP'
+ (( ${aSOFTWARE_REQUIRES_ALSA[$i]:=0} == 1 )) && string+=' +ALSA'
- fi
-
- if (( ${aSOFTWARE_REQUIRES_RSYSLOG[$i]:=0} == 1 )); then
-
- string+=' +RSYSLOG'
-
- fi
-
- if (( ${aSOFTWARE_REQUIRES_FFMPEG[$i]:=0} == 1 )); then
-
- string+=' +FFMPEG'
-
- fi
-
- if (( ${aSOFTWARE_REQUIRES_JAVA_JRE_JDK[$i]:=0} == 1 )); then
-
- string+=' +ORACLEJAVA'
-
- fi
+ (( ${aSOFTWARE_REQUIRES_XSERVERXORG[$i]:=0} == 1 )) && string+=' +XSERVER'
- if (( ${aSOFTWARE_REQUIRES_NODEJS[$i]:=0} == 1 )); then
+ (( ${aSOFTWARE_REQUIRES_DESKTOP[$i]:=0} == 1 )) && string+=' +DESKTOP'
- string+=' +NODEJS'
+ (( ${aSOFTWARE_REQUIRES_RSYSLOG[$i]:=0} == 1 )) && string+=' +RSYSLOG'
- fi
-
- if (( ${aSOFTWARE_REQUIRES_BUILDESSENTIAL[$i]:=0} == 1 )); then
+ (( ${aSOFTWARE_REQUIRES_FFMPEG[$i]:=0} == 1 )) && string+=' +FFMPEG'
- string+=' +BUILDESSENTIAL'
+ (( ${aSOFTWARE_REQUIRES_JAVA_JRE_JDK[$i]:=0} == 1 )) && string+=' +ORACLEJAVA'
- fi
+ (( ${aSOFTWARE_REQUIRES_NODEJS[$i]:=0} == 1 )) && string+=' +NODEJS'
- if (( ${aSOFTWARE_REQUIRES_GIT[$i]:=0} == 1 )); then
+ (( ${aSOFTWARE_REQUIRES_BUILDESSENTIAL[$i]:=0} == 1 )) && string+=' +BUILDESSENTIAL'
- string+=' +GIT'
+ (( ${aSOFTWARE_REQUIRES_GIT[$i]:=0} == 1 )) && string+=' +GIT'
- fi
+ (( ${aSOFTWARE_REQUIRES_WEBSERVER[$i]:=0} == 1 )) && string+=' +WEBSERVER'
- if (( ${aSOFTWARE_REQUIRES_WEBSERVER[$i]:=0} == 1 )); then
-
- string+=' +WEBSERVER'
-
- fi
+ (( ${aSOFTWARE_REQUIRES_PHP[$i]:=0} == 1 )) && string+=' +PHP'
- if (( ${aSOFTWARE_REQUIRES_PHP[$i]:=0} == 1 )); then
+ (( ${aSOFTWARE_REQUIRES_MYSQL[$i]:=0} == 1 )) && string+=' +MARIADB'
- string+=' +PHP'
-
- fi
-
- if (( ${aSOFTWARE_REQUIRES_MYSQL[$i]:=0} == 1 )); then
-
- string+=' +MARIADB'
-
- fi
-
- if (( ${aSOFTWARE_REQUIRES_SQLITE[$i]:=0} == 1 )); then
-
- string+=' +SQLITE'
-
- fi
+ (( ${aSOFTWARE_REQUIRES_SQLITE[$i]:=0} == 1 )) && string+=' +SQLITE'
# - Available for G_HW_ARCH?
if (( ! ${aSOFTWARE_AVAIL_G_HW_ARCH[$i,$G_HW_ARCH]:=1} )); then
@@ -15098,11 +15168,7 @@ _EOF_
fi
# - Online docs
- if [[ ${aSOFTWARE_ONLINEDOC_URL[$i]} ]]; then
-
- string+=" | \e[90m$FP_ONLINEDOC_URL${aSOFTWARE_ONLINEDOC_URL[$i]}\e[0m"
-
- fi
+ [[ ${aSOFTWARE_ONLINEDOC_URL[$i]} ]] && string+=" | \e[90m$FP_ONLINEDOC_URL${aSOFTWARE_ONLINEDOC_URL[$i]}\e[0m"
#Convert string to lowercase
echo -e "${string,,}"
@@ -15134,8 +15200,7 @@ _EOF_
local search_string='' #show all
display_software_menu=0 #prevent display of CHECKLIST if no results found
- G_WHIP_INPUTBOX 'Please enter a software title/index to search (eg: desktop/cloud/media/torrent)'
- if (( $? == 0 )); then
+ if G_WHIP_INPUTBOX 'Please enter a software title/index to search (eg: desktop/cloud/media/torrent)'; then
G_WHIP_CHECKLIST_ARRAY=()
local item_found=0
@@ -15160,6 +15225,8 @@ _EOF_
fi
+ echo $i
+
G_WHIP_CHECKLIST_ARRAY+=($i "${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}" "$selected")
display_software_menu=1
@@ -15167,11 +15234,7 @@ _EOF_
done
- if (( ! $display_software_menu )); then
-
- G_WHIP_MSG "Search was unable to find any items for '$search_string'"
-
- fi
+ (( ! $display_software_menu )) && G_WHIP_MSG "Search was unable to find any items for '$search_string'"
fi
@@ -15194,11 +15257,7 @@ _EOF_
G_WHIP_CHECKLIST_ARRAY=()
local max_categories=${#aSOFTWARE_CATEGORIES_DIETPI[@]}
- if (( $input_mode == 1 )); then
-
- max_categories=${#aSOFTWARE_CATEGORIES_LINUX[@]}
-
- fi
+ (( $input_mode == 1 )) && max_categories=${#aSOFTWARE_CATEGORIES_LINUX[@]}
for ((i=0; i<$max_categories; i++))
do
@@ -15304,9 +15363,8 @@ Once $G_PROGRAM_NAME has finished installation, simply run 'dietpi-drive_manager
#Gogs: Requires OpenSSH for ssh-keygen binary: https://github.com/Fourdee/DietPi/issues/442
if (( ${aSOFTWARE_INSTALL_STATE[49]} == 1 && $INDEX_SSHSERVER_TARGET != -2 )); then
- G_WHIP_YESNO "Gogs requires OpenSSH server to function.\n\nIf you continue, OpenSSH will be selected for install on your system. OpenSSH will also replace Dropbear (if currently installed).\n
-Would you like to continue with the Gogs installation?"
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Gogs requires OpenSSH server to function.\n\nIf you continue, OpenSSH will be selected for install on your system. OpenSSH will also replace Dropbear (if currently installed).\n
+Would you like to continue with the Gogs installation?"; then
# - Use SSH target index to ensure Dropbear gets removed if installed.
INDEX_SSHSERVER_TARGET=-2
@@ -15470,9 +15528,8 @@ Once DietPi has completed your software installations, and rebooted, please foll
# NoIp
if (( ${aSOFTWARE_INSTALL_STATE[67]} == 1 )); then
- G_WHIP_YESNO 'NoIp can be setup and configured by using DietPi-Config. Would you like to complete this now? \n\n- Once finished, exit DietPi-Config to resume setup.\n
- - More information:\nhttps://dietpi.com/phpbb/viewtopic.php?f=8&t=5&start=10#p58'
- if (( $? == 0 )); then
+ if G_WHIP_YESNO 'NoIp can be setup and configured by using DietPi-Config. Would you like to complete this now? \n\n- Once finished, exit DietPi-Config to resume setup.\n
+ - More information:\nhttps://dietpi.com/phpbb/viewtopic.php?f=8&t=5&start=10#p58'; then
#Write installed states to temp
Write_InstallFileList temp
@@ -15653,11 +15710,10 @@ This will allow you to choose which program loads automatically, after the syste
G_WHIP_DEFAULT_ITEM="$index_sshserver_text"
G_WHIP_BUTTON_CANCEL_TEXT='Back'
- G_WHIP_MENU 'Please select desired SSH server:\n
+ if G_WHIP_MENU 'Please select desired SSH server:\n
- None: Selecting this option will uninstall all SSH servers. This reduces system resources and improves performance. Useful for users who do NOT require networked/remote terminal access.\n
- Dropbear (Recommended): Lightweight SSH server, installed by default on DietPi systems.\n
-- OpenSSH: A feature rich SSH server with SFTP/SCP support, at the cost of increased resource usage.'
- if (( $? == 0 )); then
+- OpenSSH: A feature rich SSH server with SFTP/SCP support, at the cost of increased resource usage.'; then
# - Assign target index
if [[ $G_WHIP_RETURNED_VALUE == 'None' ]]; then
@@ -15844,11 +15900,7 @@ More information on user data in DietPi:\n- https://dietpi.com/phpbb/viewtopic.p
local return_value="$( -1 )); do
diff --git a/dietpi/dietpi-survey b/dietpi/dietpi-survey
index 17ba9254c8..c08250f101 100644
--- a/dietpi/dietpi-survey
+++ b/dietpi/dietpi-survey
@@ -75,6 +75,12 @@ _EOF_
local gitbranch="$G_GITOWNER/$G_GITBRANCH"
[[ $G_GITOWNER != 'Fourdee' ]] && gitbranch='custom'
+ # Prevent empty strings, occurred in rare cases
+ local network_interface='NONE'
+ [[ -f /DietPi/dietpi/.network ]] && network_interface="$(sed -n 3p /DietPi/dietpi/.network)"
+ local autostart_index=0
+ [[ -f /DietPi/dietpi/.dietpi-autostart_index ]] && autostart_index=$( $UPLOAD_FILENAME
#!/bin/bash
# -------------------------
@@ -87,9 +93,9 @@ _EOF_
((aCPU_ARCH[$G_HW_ARCH_DESCRIPTION]++))
((aCPU_COUNT[$G_HW_CPU_CORES]++))
((aDISTRO_VERSION[$G_DISTRO_NAME]++))
-((aAUTOSTART_OPTION[\${aAUTOSTART_NAME[$( $FP_FILTER_INCLUDE_EXCLUDE
-#Global - Folders
-- $FP_TARGET
-- /boot/dietpi/
-- /DietPi/
-- /dev/
-- /proc/
-- /sys/
-- /tmp/
-- /run/
-
-#Global - Files
- $FP_LOG
-- $FP_DIETPISYNC_SETTINGS
-- $SYNC_STATS_FILENAME
-- /var/swap
+- $FP_FILTER_INCLUDE_EXCLUDE
- .swap*
- *.tmp
# - MS Windows specific
- Thumbs.db
- desktop.ini
- SyncToy* # MS SyncToy
-- System Volume Information # - causes error code 23 (permission denied)
-
+- System Volume Information # causes error code 23 (permission denied)
_EOF_
- #Add users additional list
- if [[ -f $FP_USER_FILTER_INCLUDE_EXCLUDE ]]; then
+ #Exclude specific files/dirs by path
+ local aexclude=(
- cat $FP_USER_FILTER_INCLUDE_EXCLUDE >> $FP_FILTER_INCLUDE_EXCLUDE
+ "$FP_TARGET"
+ $FP_SETTINGS
+ $FP_USER_FILTER_INCLUDE_EXCLUDE
+ /boot/dietpi/
+ /var/swap
- fi
+ )
+
+ for i in "${aexclude[@]}"
+ do
+
+ # - Exclude only, if inside source location, via path, relative to source location
+ [[ $i == ${FP_SOURCE}/* ]] && echo "- $(realpath --relative-to="$FP_SOURCE" "$i")" >> $FP_FILTER_INCLUDE_EXCLUDE
+
+ done
+
+ unset aexclude
+
+ #Add users additional list
+ [[ -f $FP_USER_FILTER_INCLUDE_EXCLUDE ]] && cat $FP_USER_FILTER_INCLUDE_EXCLUDE >> $FP_FILTER_INCLUDE_EXCLUDE
}
Banner_Start(){
local mode='Sync'
- #Dry Run?
- if (( $SYNC_DRY_RUN )); then
-
- mode='Dry Run'
-
- fi
+ (( ${SYNC_DRY_RUN:=0} )) && mode='Dry Run'
G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" "$mode"
@@ -113,25 +104,33 @@ _EOF_
Banner_Start
- # Userdata location verify
- G_CHECK_USERDATA
+ #Stop rsync service: https://github.com/Fourdee/DietPi/issues/1869
+ if systemctl is-active rsync &> /dev/null; then
- #Generate Target dir.
- mkdir -p "$FP_TARGET"
+ SERVICE_CONTROL=1
+ G_RUN_CMD systemctl stop rsync
- systemctl stop rsync &> /dev/null # : https://github.com/Fourdee/DietPi/issues/1869
- killall -w rsync &> /dev/null
+ fi
+ killall -qw rsync
+
+ #Pre-create target dir to check R/W access
+ # - Remove previous mkdir log
+ [[ -f /var/log/dietpi-sync.log ]] && rm /var/log/dietpi-sync.log
+ mkdir -p "$FP_TARGET" &> $FP_LOG
- #Error: Folder not found
+ #Error: Dir not found
if [[ ! -d $FP_TARGET ]]; then
- G_WHIP_MSG "Error:\n\nSync failed, unable to create Target directory $FP_TARGET"
+ G_WHIP_MSG "[FAILED] Unable to pre-create target directory: $FP_TARGET\n\n\"mkdir\" reported the following error:\n$(<$FP_LOG)"
+ echo "$(date +"%d-%m-%Y_%T") [FAILED] Unable to pre-create target directory: $FP_TARGET" >> $FP_LOG
+ mv $FP_LOG /var/log/dietpi-sync.log
#Error: Rsync is already running
- elif (( $(ps aux | grep -ci -m1 "[r]sync") )); then
+ elif pgrep '[r]sync' &> /dev/null; then
- G_WHIP_MSG 'Sync Failed:\n\nA sync job could not be started as rsync is already running.'
- echo -e "Sync failed: $(date +"%d-%m-%Y_%H%M"). Rsync is already running." >> "$FP_TARGET/$SYNC_STATS_FILENAME"
+ G_WHIP_MSG '[FAILED] Rsync is already running and failed to stop gracefully'
+ # Add info to target log location directly, preserve previous rsync log
+ echo "$(date +"%d-%m-%Y_%T") [FAILED] Rsync is already running and failed to stop gracefully" >> "$FP_TARGET/$FP_LOG"
#Start sync
else
@@ -140,204 +139,155 @@ _EOF_
Create_Filter_Include_Exclude
#Rsync options
- local rync_options+="-aHP4 --info=name0 --info=progress2 --human-readable --delete-excluded --exclude-from=$FP_FILTER_INCLUDE_EXCLUDE --log-file=$FP_LOG "
-
- # - Compression?
- if (( $SYNC_COMPRESSION )); then
-
- rync_options+='z'
-
- fi
-
- # - Dry Run?
- if (( $SYNC_DRY_RUN )); then
-
- rync_options+='n'
-
- fi
-
+ local rsync_options="-aHP4h --info=name0 --info=progress2 --delete-excluded --exclude-from=$FP_FILTER_INCLUDE_EXCLUDE --log-file=$FP_LOG"
# - Delete mode?
- if (( $SYNC_DELETE_MODE )); then
+ (( $SYNC_DELETE_MODE )) && rsync_options+=' --delete'
- rync_options+=' --delete'
-
- fi
+ #Dry Run and verify enough space, in case if real sync
+ rsync --dry-run --stats $rsync_options "$FP_SOURCE"/ "$FP_TARGET"/ > .dietpi-sync_result
+ EXIT_CODE=$?
+ if ! (( $SYNC_DRY_RUN || $EXIT_CODE )); then
- #Verify enough space
- # NB: working in KiB until end MiB conversion, as, don't like using long long int, and, KiB should offer a good end result.
- local old_backup_size=$(du -ks "$FP_TARGET" | awk '{print $1}')
+ # - NB: working in KiB until end MiB conversion, as, don't like using long long int, and, KiB should offer a good end result.
+ local old_backup_size=$(du -ks "$FP_TARGET" | mawk '{print $1}')
+ local new_backup_size=$(( $(grep -m1 'Total file size' .dietpi-sync_result | sed 's/[^0-9]*//g') / 1024 ))
+ local total_file_count=$(( $(mawk '/Number of files/ {print $6;exit}' .dietpi-sync_result | sed 's/[^0-9]*//g') ))
+ local total_folder_count=$(( $(mawk '/Number of files/ {print $8;exit}' .dietpi-sync_result | sed 's/[^0-9]*//g') ))
+ local target_fs_blocksize=$(stat -fc %s "$FP_TARGET")
+ new_backup_size=$(( $new_backup_size + ( $total_file_count + $total_folder_count ) * $target_fs_blocksize / 1024 ))
+ local end_result=$(( ( $new_backup_size - $old_backup_size ) / 1024 + 1 ))
- rsync --dry-run --stats $rync_options "$FP_SOURCE"/ "$FP_TARGET"/ > /tmp/dietpi-sync_result
- local new_backup_size=$(( $(grep -m1 'Total file size' /tmp/dietpi-sync_result | sed 's/[^0-9]*//g') / 1024 ))
- local total_file_count=$(( $(grep -m1 'Number of files' /tmp/dietpi-sync_result | awk '{print $6}' | sed 's/[^0-9]*//g') ))
- local total_folder_count=$(( $(grep -m1 'Number of files' /tmp/dietpi-sync_result | awk '{print $8}' | sed 's/[^0-9]*//g') ))
- local target_fs_blocksize=$(stat -fc %s "$FP_TARGET")
- new_backup_size=$(( $new_backup_size + ( $total_file_count + $total_folder_count ) * $target_fs_blocksize / 1024 ))
- local end_result=$(( ( $new_backup_size - $old_backup_size ) / 1024 + 1 ))
- rm /tmp/dietpi-sync_result
+ if ! G_CHECK_FREESPACE "$FP_TARGET" $end_result; then
- if ! G_CHECK_FREESPACE "$FP_TARGET" $end_result; then
+ G_WHIP_BUTTON_OK_TEXT='Ignore'
+ G_WHIP_BUTTON_CANCEL_TEXT='Exit'
+ if ! G_WHIP_YESNO 'The system sync target location appears to have insufficient free space to successfully finish the backup.
+However, this check is a rough estimation in reasonable time, thus it could be marginally incorrect.\n
+Would you like to override this warning and continue with the backup?'; then
- G_WHIP_BUTTON_OK_TEXT='Ignore'
- G_WHIP_BUTTON_CANCEL_TEXT='Exit'
- G_WHIP_YESNO 'The system sync target location appears to have insufficient free space to successfully finish the backup.\nHowever, this check is a rough estimation in reasonable time, thus it could be marginally incorrect.\n\nWould you like to override this warning and continue with the backup?'
- if (( $? )); then
+ echo "$(date +"%d-%m-%Y_%T") [FAILED] Insufficient free space" >> $FP_LOG
+ mv $FP_LOG "$FP_TARGET"/
+ return 1
- echo -e "Sync canceled: due to insufficient free space: $(date +"%d-%m-%Y_%H%M")" >> "$FP_TARGET/$SYNC_STATS_FILENAME"
- break
+ fi
fi
- fi
+ #Real sync
+ G_DIETPI-NOTIFY 2 "Sync | $FP_SOURCE > $FP_TARGET: in progress, please wait..."
+ # - Clear log file from space check
+ > $FP_LOG
+ rsync $rsync_options "$FP_SOURCE"/ "$FP_TARGET"/
+ EXIT_CODE=$?
- G_DIETPI-NOTIFY 2 "Sync | $FP_SOURCE > $FP_TARGET: in progress, please wait..."
+ fi
- #Sync
- rsync $rync_options "$FP_SOURCE"/ "$FP_TARGET"/
- EXIT_CODE=$?
G_DIETPI-NOTIFY -1 $EXIT_CODE "$G_PROGRAM_NAME"
- if (( $EXIT_CODE == 0 )); then
- echo -e "Sync completed: $(date +"%d-%m-%Y_%H%M")" >> "$FP_TARGET/$SYNC_STATS_FILENAME"
+ if (( ! $EXIT_CODE )); then
+
if (( ! $SYNC_DRY_RUN )); then
- G_WHIP_MSG "Sync completed:\n - $FP_SOURCE > $FP_TARGET"
+ echo "$(date +"%d-%m-%Y_%T") [ OK ] Sync completed" >> $FP_LOG
+ G_WHIP_MSG "[ OK ] Sync completed:\n - $FP_SOURCE > $FP_TARGET"
else
- G_WHIP_MSG "Dry Run Sync completed (NO modifications):\n - $FP_SOURCE > $FP_TARGET"
+ echo "$(date +"%d-%m-%Y_%T") [ OK ] Dry run completed" >> $FP_LOG
+ G_WHIP_MSG "[ OK ] Dry Run Sync completed (NO modifications):\n - $FP_SOURCE > $FP_TARGET"
fi
else
- echo -e "Sync failed: please see the log file for more information ($FP_LOG): $(date +"%d-%m-%Y_%H%M")" >> "$FP_TARGET/$SYNC_STATS_FILENAME"
- G_WHIP_MSG "Sync failed:\n - $FP_SOURCE > $FP_TARGET\n\nYou will given an option to view the logfile on the next screen. Please check it for information and/or errors."
+ echo "$(date +"%d-%m-%Y_%T") [FAILED] Please see the log file for more information: $FP_TARGET/$FP_LOG" >> $FP_LOG
+ G_WHIP_MSG "[FAILED] $FP_SOURCE > $FP_TARGET\n\nYou will given an option to view the logfile on the next screen. Please check it for information and/or errors."
fi
log=1 G_WHIP_VIEWFILE $FP_LOG
-
- #return to main menu
- TARGETMENUID=0
+ mv $FP_LOG "$FP_TARGET"/
fi
- systemctl start rsync &> /dev/null # : https://github.com/Fourdee/DietPi/issues/1869
-
}
Check_Available_DietPi_Mounts(){
- local temp_file_mounts='.dietpi-sync_dietpi_mounts'
- df -h > "$temp_file_mounts"
-
- #Samba Client
- SAMBA_MOUNT_AVAILABLE=0
- SAMBA_MOUNT_TEXT="Not mounted ($FP_SAMBA_MOUNT). Select to setup."
- if (( $(grep -ci -m1 "/mnt/samba" $temp_file_mounts) )); then
+ local samba_mount_out=$(df -h | grep "$fp_samba_mount")
+ if [[ $samba_mount_out ]]; then
- SAMBA_MOUNT_AVAILABLE=1
- SAMBA_MOUNT_TEXT="Size: $(df -h | grep /mnt/samba | awk '{print $2}')B | Available: $(df -h | grep /mnt/samba | awk '{print $4}')B"
+ samba_mount_available=1
+ samba_mount_text=$(mawk '{print "Size: "$2"B | Available: "$4"B"}' <<< $samba_mount_out)
fi
- rm $temp_file_mounts
-
}
#/////////////////////////////////////////////////////////////////////////////////////
# Settings File
#/////////////////////////////////////////////////////////////////////////////////////
- #Settings File
- FP_DIETPISYNC_SETTINGS='/DietPi/dietpi/.dietpi-sync_settings'
-
Write_Settings_File(){
- cat << _EOF_ > $FP_DIETPISYNC_SETTINGS
+ cat << _EOF_ > $FP_SETTINGS
FP_SOURCE=$FP_SOURCE
FP_TARGET=$FP_TARGET
SYNC_DELETE_MODE=$SYNC_DELETE_MODE
-SYNC_COMPRESSION=$SYNC_COMPRESSION
SYNC_CRONDAILY=$SYNC_CRONDAILY
_EOF_
}
- Read_Settings_File(){
-
- if [[ -f $FP_DIETPISYNC_SETTINGS ]]; then
-
- . $FP_DIETPISYNC_SETTINGS
-
- fi
-
- }
+ Read_Settings_File(){ [[ -f $FP_SETTINGS ]] && . $FP_SETTINGS; }
#/////////////////////////////////////////////////////////////////////////////////////
# MENUS
#/////////////////////////////////////////////////////////////////////////////////////
TARGETMENUID=0
- SAMBA_MOUNT_AVAILABLE=0
- SAMBA_MOUNT_TEXT='Not available'
-
- SYNC_DRY_RUN=0
-
- SYNC_MODE_TEXT='Disabled'
- SYNC_COMPRESSION_TEXT='Disabled'
- SYNC_CRONDAILY_TEXT='Disabled'
+ SYNC_MODE_TEXT=''
+ SYNC_CRONDAILY_TEXT=''
#TARGETMENUID=0
Menu_Main(){
SYNC_MODE_TEXT='[Off]'
- if (( $SYNC_DELETE_MODE )); then
-
- SYNC_MODE_TEXT='[On]'
+ (( $SYNC_DELETE_MODE )) && SYNC_MODE_TEXT='[On]'
- fi
-
- SYNC_COMPRESSION_TEXT='[Off]'
- if (( $SYNC_COMPRESSION )); then
-
- SYNC_COMPRESSION_TEXT='[On]'
+ SYNC_CRONDAILY_TEXT='[Off]'
+ (( $SYNC_CRONDAILY )) && SYNC_CRONDAILY_TEXT='[On]'
- fi
+ if [[ -f $FP_TARGET/$FP_LOG ]]; then
- SYNC_CRONDAILY_TEXT='[Off]'
- if (( $SYNC_CRONDAILY )); then
+ local sync_last_status=$(tail -1 "$FP_TARGET/$FP_LOG")
- SYNC_CRONDAILY_TEXT='[On]'
+ elif [[ -f /var/log/dietpi-sync.log ]]; then
- fi
+ local sync_last_status=$(tail -1 /var/log/dietpi-sync.log)
- local sync_last_completed='No previous sync found in target directory.'
- if [[ -f $FP_TARGET/$SYNC_STATS_FILENAME ]]; then
+ else
- sync_last_completed=$(grep '^Sync completed' "$FP_TARGET/$SYNC_STATS_FILENAME" | tail -1 | awk '{print $3}')
+ local sync_last_status='No previous sync found in target directory.'
fi
G_WHIP_MENU_ARRAY=(
'' '●─ Info '
- 'Help' "What does $G_PROGRAM_NAME do?"
+ 'Help' ": What does $G_PROGRAM_NAME do?"
'' '●─ Options '
'Source Location' ': Change the Source directory.'
'Target Location' ': Change the Target directory.'
"Delete Mode" ": $SYNC_MODE_TEXT"
- "Compression" ": $SYNC_COMPRESSION_TEXT"
"Sync: Daily" ": $SYNC_CRONDAILY_TEXT"
'' '●─ Run '
- 'Sync: Dry Run' 'Run a test Sync without modifying any data.'
- 'Sync: Now' 'Sync the Source location to the Target location.'
+ 'Sync: Dry Run' ': Run a test Sync without modifying any data.'
+ 'Sync: Now' ': Sync the Source location to the Target location.'
)
G_WHIP_BUTTON_CANCEL_TEXT='Exit'
- G_WHIP_MENU "Source location:\n $FP_SOURCE\n\nTarget location:\n $FP_TARGET\n\nMost recent successful sync date:\n $sync_last_completed"
- if (( $? == 0 )); then
+ if G_WHIP_MENU "Source location:\n $FP_SOURCE\n\nTarget location:\n $FP_TARGET\n\nLast sync status:\n $sync_last_status"; then
case "$G_WHIP_RETURNED_VALUE" in
@@ -355,47 +305,42 @@ _EOF_
'Help')
- G_WHIP_MSG "DietPi-Sync is a program that allows you to duplicate a directory from one location (Source) to another (Target).\n\nFor example: If we want to duplicate (sync) the data on our external USB HDD to another location, we simply select the USB HDD as the source, then, select a target location. The target location can be anything from a networked samba fileserver, or even a FTP server.\n\nIf you would like to test a sync without modifiying any data, simply select Dry Run.\n\nMore information:\n - https://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=256#p256"
+ G_WHIP_MSG 'DietPi-Sync is a program that allows you to duplicate a directory from one location (Source) to another (Target).\n
+For example: If we want to duplicate (sync) the data on our external USB HDD to another location, we simply select the USB HDD as the source, then, select a target location.
+The target location can be anything from a networked samba fileserver, or even a FTP server.\n
+If you would like to test a sync without modifiying any data, simply select Dry Run.\n\nMore information:\n - https://dietpi.com/phpbb/viewtopic.php?p=256#p256'
;;
- "Delete Mode")
+ 'Delete Mode')
- TARGETMENUID=3
+ Menu_Set_Sync_Delete_Mode
;;
- 'Compression')
+ 'Sync: Daily')
- TARGETMENUID=4
+ Menu_Set_CronDaily
;;
- "Sync: Daily")
+ 'Sync: Dry Run')
- TARGETMENUID=5
+ if G_WHIP_YESNO "Start dry run sync?\n\nSource location:\n$FP_SOURCE/*\n\nTarget location:\n$FP_TARGET/*\n
+This is a Dry Run for testing. No data will be modified.\n\nDo you wish to continue?"; then
- ;;
-
- "Sync: Dry Run")
-
- G_WHIP_YESNO "Start dry run sync?\n\nSource location:\n$FP_SOURCE/*\n\nTarget location:\n$FP_TARGET/*\n\nThis is a Dry Run for testing. No data will be modified.\n\nDo you wish to continue?"
- if (( $? == 0 )); then
-
- SYNC_DRY_RUN=1
- Run_Sync
+ SYNC_DRY_RUN=1 Run_Sync
fi
;;
- "Sync: Now")
+ 'Sync: Now')
- G_WHIP_YESNO "Start sync?\n\nSource location:\n$FP_SOURCE/*\n\nTarget location:\n$FP_TARGET/*\n\nA copy of all the files and folders inside your Source location, will be created at the Target location.\n\nDo you wish to continue?"
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Start sync?\n\nSource location:\n$FP_SOURCE/*\n\nTarget location:\n$FP_TARGET/*\n
+A copy of all the files and folders inside your Source location, will be created at the Target location.\n\nDo you wish to continue?"; then
- SYNC_DRY_RUN=0
- Run_Sync
+ SYNC_DRY_RUN=0 Run_Sync
fi
@@ -414,45 +359,40 @@ _EOF_
Menu_Exit(){
G_WHIP_SIZE_X_MAX=50
- G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"
- if (( $? == 0 )); then
-
- TARGETMENUID=-1
-
- fi
+ G_WHIP_YESNO "Exit $G_PROGRAM_NAME?" && TARGETMENUID=-1
}
- #TARGETMENUID=1 && TARGETMENUID=2
+ #TARGETMENUID=1 (Target) && TARGETMENUID=2 (Source)
Menu_Set_Directories(){
- #TARGETMENUID
- #2=Source | 1=Target
-
local current_directory="$FP_TARGET"
local current_mode_text='Target'
- local whip_description_text="Please select the $current_mode_text location.\nA copy of all the files and folders in the Source location will be created here.\n\nCurrent Target location:\n$FP_TARGET"
+ local whip_description_text="Please select the $current_mode_text location.\nA copy of all the files and folders in the Source location will be created here.\n\nCurrent $current_mode_text location:\n$current_directory"
if (( $TARGETMENUID == 2 )); then
current_directory="$FP_SOURCE"
current_mode_text='Source'
- whip_description_text="Please select the $current_mode_text location.\nA copy of all the files and folder in this Source location, will be created at the Target location.\n\nCurrent Source location:\n$FP_SOURCE"
+ whip_description_text="Please select the $current_mode_text location.\nA copy of all the files and folder in this Source location, will be created at the Target location.\n\nCurrent $current_mode_text location:\n$current_directory"
fi
+ # Check for samba mount
+ local fp_samba_mount='/mnt/samba'
+ local samba_mount_available=0
+ local samba_mount_text="Not mounted ($fp_samba_mount). Select to setup."
Check_Available_DietPi_Mounts
G_WHIP_MENU_ARRAY=(
- 'Manual' "Manually type your $current_mode_text directory."
- 'List' 'Select from a list of available mounts/drives'
- "Samba Client" "$SAMBA_MOUNT_TEXT"
+ 'Manual' ": Manually type your $current_mode_text directory."
+ 'List' ': Select from a list of available mounts/drives'
+ 'Samba Client' ": [$samba_mount_text]"
)
G_WHIP_BUTTON_CANCEL_TEXT='Back'
- G_WHIP_MENU "$whip_description_text"
- if (( $? == 0 )); then
+ if G_WHIP_MENU "$whip_description_text"; then
case "$G_WHIP_RETURNED_VALUE" in
@@ -461,11 +401,7 @@ _EOF_
/DietPi/dietpi/dietpi-drive_manager 1
local return_value=$( Exact copy'
)
G_WHIP_DEFAULT_ITEM="$SYNC_MODE_TEXT"
- G_WHIP_MENU "Please select the Sync delete mode.\n\nDisabled: (safe)\nIf files and folders exist in the Target location, that are not in the Source, they will be left alone.\n\nEnabled: (WARNING, if in doubt, DO NOT enable)\nAn exact copy of the Source location will be created at the Target location. If files are in the Target location that dont exist in the Source, they will be DELETED."
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select the Sync delete mode.\n
+[Off]: (safe)\nIf files and folders exist in the Target location, that are not in the Source, they will be left alone.\n
+[On]: (WARNING, if in doubt, DO NOT enable)\nAn exact copy of the Source location will be created at the Target location.
+If files are in the Target location that do not exist in the Source, they will be DELETED.'; then
SYNC_DELETE_MODE=0
- if [[ $G_WHIP_RETURNED_VALUE == 'Enabled' ]]; then
-
- SYNC_DELETE_MODE=1
-
- fi
-
- fi
-
- #Return to main menu
- TARGETMENUID=0
-
- }
-
- #TARGETMENUID=4
- Menu_Set_Compression(){
-
- G_WHIP_MENU_ARRAY=(
-
- 'Disabled' 'Transfer data in its original state.'
- 'Enabled' 'Compress the data during transfer.'
-
- )
-
- G_WHIP_DEFAULT_ITEM="$SYNC_COMPRESSION_TEXT"
- G_WHIP_MENU "Please select the compression mode.\n\nDisabled:\nNo compression will be used during data transfer.\n\nEnabled:\nData will be compressed when its being transfered. Useful for slow connections, however, its CPU intensive."
- if (( $? == 0 )); then
-
- SYNC_COMPRESSION=0
- if [[ $G_WHIP_RETURNED_VALUE == 'Enabled' ]]; then
-
- SYNC_COMPRESSION=1
-
- fi
+ [[ $G_WHIP_RETURNED_VALUE == '[On]' ]] && SYNC_DELETE_MODE=1
fi
- #Return to main menu
- TARGETMENUID=0
-
}
- #TARGETMENUID=5
Menu_Set_CronDaily(){
G_WHIP_MENU_ARRAY=(
- 'Disabled' 'Manual sync.'
- 'Enabled' 'Automatically sync once a day.'
+ '[Off]' ': Manual sync'
+ '[On]' ': Automatically sync once a day'
)
G_WHIP_DEFAULT_ITEM="$SYNC_CRONDAILY_TEXT"
- G_WHIP_MENU "Disabled:\nThe user must manually sync using dietpi-sync.\n\nEnabled:\nA cron job will be created that automatically runs dietpi-sync, once a day.\n\n(NOTICE):\nBefore enabling this feature, please run a test sync (Dry Run) to verify what will happen."
- if (( $? == 0 )); then
+ if G_WHIP_MENU '[Off]:\nThe user must manually sync using dietpi-sync.\n
+[On]:\nA cron job will be created that automatically runs dietpi-sync, once a day.\n
+(NOTICE):\nBefore enabling this feature, please run a test sync (Dry Run) to verify what will happen.'; then
SYNC_CRONDAILY=0
- if [[ $G_WHIP_RETURNED_VALUE == 'Enabled' ]]; then
-
- SYNC_CRONDAILY=1
-
- fi
+ [[ $G_WHIP_RETURNED_VALUE == '[On]' ]] && SYNC_CRONDAILY=1
fi
- #Return to main menu
- TARGETMENUID=0
-
}
Input_User_Directory(){
@@ -616,40 +506,52 @@ _EOF_
#TARGETMENUID
#2=Source | 1=Target
- #Target
- if (( $TARGETMENUID == 1 )); then
+ local mode='target'
+ (( $TARGETMENUID == 2 )) && mode='source'
+ local fp_mode="FP_${mode^^}"
+ G_WHIP_DEFAULT_ITEM=${!fp_mode}
+ local text="Please enter a new file path for the $mode directory.\neg: /mnt/$mode"
- G_WHIP_DEFAULT_ITEM="$FP_TARGET"
- G_WHIP_INPUTBOX 'Please enter a new filepath for the Target directory. \neg: /mnt/target'
- if (( $? == 0 )); then
+ while :
+ do
- FP_TARGET="$G_WHIP_RETURNED_VALUE"
+ if G_WHIP_INPUTBOX "$text"; then
- fi
+ # Sanity checks
+ # - Full path required
+ if [[ $G_WHIP_RETURNED_VALUE != /* ]]; then
+
+ text="ERROR: Please enter the $mode location as full path with leading slash: /\n\n - eg: /mnt/$mode"
+
+ # - Do not allow to sync from or to root
+ elif [[ $G_WHIP_RETURNED_VALUE == / ]]; then
+
+ text="ERROR: You entered the root directory as $mode location: /\n\n - Please use \"dietpi-backup\" instead for system backups and recoveries."
+
+ else
- #Source
- elif (( $TARGETMENUID == 2 )); then
+ declare -g $fp_mode="${G_WHIP_RETURNED_VALUE%/}"
+ TARGETMENUID=0
+ return
- G_WHIP_DEFAULT_ITEM="$FP_SOURCE"
- G_WHIP_INPUTBOX 'Please enter a new filepath for the Source directory. \neg: /mnt/source'
- if (( $? == 0 )); then
+ fi
- FP_SOURCE="$G_WHIP_RETURNED_VALUE"
+ else
+
+ return
fi
- fi
+ G_WHIP_DEFAULT_ITEM="$G_WHIP_RETURNED_VALUE"
+
+ done
}
Prompt_Setup_Samba_Mount(){
- G_WHIP_YESNO "$SAMBA_MOUNT_TEXT\n\nWould you like to run DietPi-Drive_Manager and setup your Samba Client Mount now?"
- if (( $? == 0 )); then
-
- /DietPi/dietpi/dietpi-drive_manager
-
- fi
+ G_WHIP_YESNO "$samba_mount_text\n\nWould you like to run DietPi-Drive_Manager and setup your Samba Client Mount now?"
+ (( $? )) || /DietPi/dietpi/dietpi-drive_manager
}
@@ -665,19 +567,20 @@ _EOF_
cat << _EOF_ > $FP_USER_FILTER_INCLUDE_EXCLUDE
#$G_PROGRAM_NAME | Custom include/exclude filters
#
-#To INCLUDE (+) a file/folder:
-#+ /location/to/my/file
-#+ /location/to/my/directory/
+#To EXCLUDE (-) all files by name:
+#- file
+#To EXCLUDE (-) a single file by path, relative to source directory:
+#- /relative/path/to/file
+#To EXCLUDE (-) a specific directory by path, relative to source directory:
+#- /relative/path/to/directory/
#
-#To EXCLUDE (-) a file/folder:
-#- /location/to/my/file
-#- /location/to/my/directory/
+#To INCLUDE (+) something from within an otherwise excluded directory:
+#+ /relative/path/to/directory/include_this
_EOF_
fi
- #Read settings file
Read_Settings_File
#-----------------------------------------------------------------------------
@@ -702,30 +605,14 @@ _EOF_
Menu_Set_Directories
- elif (( $TARGETMENUID == 3 )); then
-
- Menu_Set_Sync_Delete_Mode
-
- elif (( $TARGETMENUID == 4 )); then
-
- Menu_Set_Compression
-
- elif (( $TARGETMENUID == 5 )); then
-
- Menu_Set_CronDaily
-
fi
done
- #Save settings
Write_Settings_File
fi
- #-----------------------------------------------------------------------------------
- #Cleaup left over tmp files
- rm $FP_FILTER_INCLUDE_EXCLUDE &> /dev/null
#-----------------------------------------------------------------------------------
exit $EXIT_CODE
#-----------------------------------------------------------------------------------
diff --git a/dietpi/dietpi-update b/dietpi/dietpi-update
index 713bd8f278..5efd24ccb9 100644
--- a/dietpi/dietpi-update
+++ b/dietpi/dietpi-update
@@ -30,7 +30,7 @@
#Import DietPi-Globals ---------------------------------------------------------------
INPUT=0
- disable_error=1 G_CHECK_VALIDINT $1 && INPUT=$1
+ disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1
#/////////////////////////////////////////////////////////////////////////////////////
#UPDATE Vars
@@ -46,10 +46,10 @@
UPDATE_REQUIRESNEWIMAGE=0
RUN_UPDATE=0
- GITOWNER_TARGET="$(grep -m1 '^[[:blank:]]*DEV_GITOWNER=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
- GITOWNER_TARGET="${GITOWNER_TARGET:-Fourdee}"
- GITBRANCH_TARGET="$(grep -m1 '^[[:blank:]]*DEV_GITBRANCH=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
- GITBRANCH_TARGET="${GITBRANCH_TARGET:-master}"
+ GITOWNER_TARGET=$(grep -m1 '^[[:blank:]]*DEV_GITOWNER=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
+ GITOWNER_TARGET=${GITOWNER_TARGET:-Fourdee}
+ GITBRANCH_TARGET=$(grep -m1 '^[[:blank:]]*DEV_GITBRANCH=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
+ GITBRANCH_TARGET=${GITBRANCH_TARGET:-master}
COREVERSION_SERVER=0
SUBVERSION_SERVER=0
@@ -117,9 +117,9 @@
RCVERSION_SERVER=$(sed -n 3p server_version)
#Check if server_version contains valid intergers.
- if disable_error=1 G_CHECK_VALIDINT $COREVERSION_SERVER &&
- disable_error=1 G_CHECK_VALIDINT $SUBVERSION_SERVER &&
- disable_error=1 G_CHECK_VALIDINT $RCVERSION_SERVER; then
+ if disable_error=1 G_CHECK_VALIDINT "$COREVERSION_SERVER" &&
+ disable_error=1 G_CHECK_VALIDINT "$SUBVERSION_SERVER" &&
+ disable_error=1 G_CHECK_VALIDINT "$RCVERSION_SERVER"; then
SERVER_ONLINE=1
G_DIETPI-NOTIFY 0 "Using update server: ${URL_MIRROR_SERVERVERSION[$i]}"
@@ -225,12 +225,22 @@
while :
do
+ local auto_updates_enabled=0
+ local auto_updates_text='[Disabled]'
+ if grep -qi '^[[:blank:]]*CONFIG_AUTO_DIETPI_UPDATES=1' /DietPi/dietpi.txt; then
+
+ auto_updates_enabled=1
+ auto_updates_text='[Enabled]'
+
+ fi
+
G_WHIP_BUTTON_CANCEL_TEXT='Exit'
G_WHIP_MENU_ARRAY=(
'' '●─ Update DietPi '
'Update' ": Apply $COREVERSION_SERVER.$SUBVERSION_SERVER.$RCVERSION_SERVER update."
'' '●─ Additional Options '
+ 'Automatic Updates' ": $auto_updates_text"
'Changelog' ': View the changelog and patch notes.'
'Backup' ': Create a system backup, before updating.'
@@ -262,6 +272,21 @@ Do you wish to continue and update DietPi to v$COREVERSION_SERVER.$SUBVERSION_SE
fi
+ elif [[ ${G_WHIP_RETURNED_VALUE,,} == 'automatic updates' ]]; then
+
+ ((auto_updates_enabled++))
+ if (( $auto_updates_enabled >= 2 )); then
+
+ auto_updates_enabled=0
+
+ else
+
+ G_WHIP_MSG 'Automatic DietPi updates have been enabled.\n\nUpdates will be checked and applied (if update is available) daily via cron job.\n\nWe highly recommend you create a system backup with "DietPi-Backup" if using this feature, as automated updates will not prompt user if a failure occurs.\n\nWhen DietPi applies updates, all system services will be temporarily stopped. Do NOT power off the unit during updates as this could render the system in a unrecoverable state.'
+
+ fi
+
+ G_CONFIG_INJECT 'CONFIG_AUTO_DIETPI_UPDATES=' "CONFIG_AUTO_DIETPI_UPDATES=$auto_updates_enabled" /DietPi/dietpi.txt
+
elif [[ ${G_WHIP_RETURNED_VALUE,,} == 'changelog' ]]; then
Get_View_Changelog
@@ -314,14 +339,14 @@ Do you wish to continue and update DietPi to v$COREVERSION_SERVER.$SUBVERSION_SE
rm DietPi-"$GITBRANCH_TARGET"/dietpi/pre-patch_file
#Remove folders of "non-critical scripts" before updating them. (eg: so we dont need to patch for /conf/* file removals)
- # rm -R /DietPi/dietpi/conf #:https://github.com/Fourdee/DietPi/issues/905#issuecomment-298241622
+ # :https://github.com/Fourdee/DietPi/issues/905#issuecomment-298241622
# rm -R /DietPi/dietpi/func
# rm -R /DietPi/dietpi/misc
l_message='Copy DietPi core files to RAMdisk' G_RUN_CMD cp -Rf DietPi-"$GITBRANCH_TARGET"/dietpi /DietPi/
- l_message='Copy rootfs files in place' G_RUN_CMD cp -Rf DietPi-"$GITBRANCH_TARGET"/rootfs/. /
+ l_message='Copy DietPi rootfs files in place' G_RUN_CMD cp -Rf DietPi-"$GITBRANCH_TARGET"/rootfs/. /
- l_message='Set execute permissions for DietPi scripts' G_RUN_CMD chmod -R +x /DietPi /var/lib/dietpi/services /etc/cron.*/dietpi /etc/profile.d/dietpi-*.sh /etc/bashrc.d/dietpi-*.sh
+ l_message='Set execute permissions for DietPi scripts' G_RUN_CMD chmod -R +x /DietPi/dietpi /var/lib/dietpi/services /etc/cron.*/dietpi
systemctl daemon-reload
#Verify/update dietpi.txt entries:
@@ -357,8 +382,8 @@ Do you wish to continue and update DietPi to v$COREVERSION_SERVER.$SUBVERSION_SE
#Update local version ID
# - Update current Git owner/branch info
- G_GITOWNER="$GITOWNER_TARGET"
- G_GITBRANCH="$GITBRANCH_TARGET"
+ G_GITOWNER=$GITOWNER_TARGET
+ G_GITBRANCH=$GITBRANCH_TARGET
# - Save current version and Git owner/branch info
G_VERSIONDB_SAVE
@@ -462,6 +487,9 @@ Please download the latest DietPi image:\n - https://dietpi.com/#download \n\n -
#Stop Services
/DietPi/dietpi/dietpi-services stop
+ #Disable powersaving on main screen
+ setterm -blank 0 -powersave off 2> /dev/null
+
#Run update and patcher
[[ -f $FP_LOG ]] && rm $FP_LOG
@@ -473,28 +501,41 @@ Please download the latest DietPi image:\n - https://dietpi.com/#download \n\n -
unset G_WHIP_SIZE_X_OVERRIDE G_WHIP_SIZE_Y_OVERRIDE
mv $FP_TMP_LOG $FP_LOG
- #.update file stage (only used on 1st run of dietpi-software to check/apply updates, 0 tells dietpi-software to reboot)
- echo 0 > /DietPi/dietpi/.update_stage
-
#Remove update_available file
+ # - Remove update_available file
[[ -f /DietPi/dietpi/.update_available ]] && rm /DietPi/dietpi/.update_available
-
- #Update DietPi-Survey
+ # - Update DietPi-Survey
/DietPi/dietpi/dietpi-survey 1
- #Sync to disk now: https://dietpi.com/phpbb/viewtopic.php?f=9&t=2591
+ # - Sync to disk now: https://dietpi.com/phpbb/viewtopic.php?f=9&t=2591
sync
- #Done
G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Completed'
G_DIETPI-NOTIFY 2 "$INFO_CURRENT_VERSION"
G_DIETPI-NOTIFY 2 "$INFO_SERVER_VERSION"
- # - Reboot prompt, if system is already installed (else, dietpi-software handles this for 1st run)
- if (( $G_DIETPI_INSTALL_STAGE == 1 )); then
+ # - 1st run setup
+ if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
+
+ export G_DIETPI_INSTALL_STAGE=1
+ echo $G_DIETPI_INSTALL_STAGE > /DietPi/dietpi/.install_stage
+
+ G_WHIP_MSG 'DietPi has been updated to the latest version.\n\nThe system will now reboot. Once completed, simply login to resume DietPi Setup. \n\nPress Enter to Continue.'
+ reboot
+
+ # - Reboot prompt, if system is already installed
+ elif (( $G_DIETPI_INSTALL_STAGE == 2 )); then
G_WHIP_YESNO "Update applied:\n\n - $INFO_CURRENT_VERSION\n\nA system reboot is required to finalize the update. Would you like to reboot the system now?"
- (( $? == 0 )) && reboot
+ if (( $? == 0 )); then
+
+ reboot
+
+ else
+
+ /DietPi/dietpi/dietpi-services restart
+
+ fi
fi
diff --git a/dietpi/func/dietpi-benchmark b/dietpi/func/dietpi-benchmark
index 71eeefc07a..020e0766e3 100644
--- a/dietpi/func/dietpi-benchmark
+++ b/dietpi/func/dietpi-benchmark
@@ -109,14 +109,9 @@ _EOF_
/DietPi/dietpi/dietpi-survey 1
- else
+ elif G_WHIP_YESNO 'To upload and compare your results against other users, you must be opted in to the DietPi-Survey.\n\nWould you like to run DietPi-Survey now, allowing you to opt in?'; then
- G_WHIP_YESNO 'To upload and compare your results against other users, you must be opted in to the DietPi-Survey.\n\nWould you like to run DietPi-Survey now, allowing you to opt in?'
- if (( $? == 0 )); then
-
- /DietPi/dietpi/dietpi-survey
-
- fi
+ /DietPi/dietpi/dietpi-survey
fi
@@ -188,7 +183,7 @@ _EOF_
{ time -p $FP_TEMP/bench; } 2> $FP_TEMP/bench_result
BENCH_CPU_TEMP_END=$(G_OBTAIN_CPU_TEMP)
- BENCH_CPU=$( grep -m1 'real' $FP_TEMP/bench_result | awk '{print $2}' )
+ BENCH_CPU=$(mawk '/real/ {print $2;exit}' $FP_TEMP/bench_result)
if (( $SHOW_RESULTS )); then
@@ -207,17 +202,9 @@ NB: A lower 'Total time' is faster"
local benchmark_file_name='benchmark.file'
local min_benchmark_size=10
local max_benchmark_size=$(( $(G_CHECK_FREESPACE $FP_BENCHFILE) - 100 ))
- if (( $max_benchmark_size > 1000 )); then
-
- max_benchmark_size=1000
-
- fi
+ (( $max_benchmark_size > 1000 )) && max_benchmark_size=1000
- if [[ $FP_BENCHFILE != *'/' ]]; then
-
- FP_BENCHFILE+='/'
-
- fi
+ [[ $FP_BENCHFILE != *'/' ]] && FP_BENCHFILE+='/'
FP_BENCHFILE+=$benchmark_file_name
printf '\ec' # clear current terminal screen
@@ -226,8 +213,7 @@ NB: A lower 'Total time' is faster"
if (( $BENCH_FILESIZE == 0 )); then
G_WHIP_DEFAULT_ITEM=$min_benchmark_size
- G_WHIP_INPUTBOX "Please enter a filesize test value (MB). A value of 100 is recommended.\n- Minimum value: $min_benchmark_size\n- Maximum possible value: $max_benchmark_size"
- if (( $? == 0 )); then
+ if G_WHIP_INPUTBOX "Please enter a filesize test value (MB). A value of 100 is recommended.\n- Minimum value: $min_benchmark_size\n- Maximum possible value: $max_benchmark_size"; then
BENCH_FILESIZE=$G_WHIP_RETURNED_VALUE
@@ -246,15 +232,15 @@ NB: A lower 'Total time' is faster"
local bench_write_result=$(dd bs=4K count=$(( $BENCH_FILESIZE * 1024 / 4 )) if=/dev/zero of=$FP_BENCHFILE conv=fdatasync 2>&1 | grep 'copied')
# Convert results manually from bytes and time to MB/s
- local temp_bytes_result=$(echo "$bench_write_result" | awk '{print $1}')
+ local temp_bytes_result=$(mawk '{print $1}' <<< "$bench_write_result")
local temp_time_result=''
if (( $G_DISTRO == 3 )); then
- temp_time_result=$(echo "$bench_write_result" | awk '{print $6}')
+ temp_time_result=$(mawk '{print $6}' <<< "$bench_write_result")
else
- temp_time_result=$(echo "$bench_write_result" | awk '{print $8}')
+ temp_time_result=$(mawk '{print $8}' <<< "$bench_write_result")
fi
bench_write_result=$(bc -l <<< "scale=0; ( $temp_bytes_result / $temp_time_result ) / 1000 / 1000")
@@ -268,14 +254,14 @@ NB: A lower 'Total time' is faster"
local bench_read_result=$(dd bs=4K count=$(( $BENCH_FILESIZE * 1024 / 4 )) if=$FP_BENCHFILE of=/dev/null conv=fdatasync 2>&1 | grep 'copied')
# Convert results manually from bytes and time to MB/s
- temp_bytes_result=$(echo "$bench_read_result" | awk '{print $1}')
+ temp_bytes_result=$(mawk '{print $1}' <<< "$bench_read_result")
if (( $G_DISTRO == 3 )); then
- temp_time_result=$(echo "$bench_read_result" | awk '{print $6}')
+ temp_time_result=$(mawk '{print $6}' <<< "$bench_read_result")
else
- temp_time_result=$(echo "$bench_read_result" | awk '{print $8}')
+ temp_time_result=$(mawk '{print $8}' <<< "$bench_read_result")
fi
bench_read_result=$(bc -l <<< "scale=0; ( $temp_bytes_result / $temp_time_result ) / 1000 / 1000")
@@ -310,7 +296,7 @@ NB: A lower 'Total time' is faster"
fi
- rm $FP_BENCHFILE &> /dev/null
+ [[ -f $FP_BENCHFILE ]] && rm $FP_BENCHFILE
fi
@@ -335,11 +321,7 @@ NB: A lower 'Total time' is faster"
if (( $G_HW_CPU_CORES <= 2 )); then
G_WHIP_YESNO "We have detected a low CPU core count ($G_HW_CPU_CORES). The tests may take upto 5 minutes to complete (eg: RaspberryPi Zero).\n\nDo you wish to continue?"
- if (( $? == 1 )); then
-
- exit 0
-
- fi
+ (( $? == 1 )) && exit 0
fi
@@ -388,8 +370,7 @@ Compare these results online with other users, using the link below:
Benchmark_Lan_Client(){
G_AG_CHECK_INSTALL_PREREQ iperf
- G_WHIP_INPUTBOX 'Please enter the IP address of the system running the network benchmark server:\n - eg: 192.168.0.100'
- if (( $? == 0 )); then
+ if G_WHIP_INPUTBOX 'Please enter the IP address of the system running the network benchmark server:\n - eg: 192.168.0.100'; then
IPERF_SERVER_IP="$G_WHIP_RETURNED_VALUE"
diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals
index 4b929b8125..2ba4e1b136 100644
--- a/dietpi/func/dietpi-globals
+++ b/dietpi/func/dietpi-globals
@@ -55,9 +55,9 @@
fi
- #DietPi First-Run Stage | -2 = PREP_SYSTEM/Unknown | -1 = first boot | 0 = run dietpi-software at login | 1 = completed | 2 = Pre-installed image, converts to 1 during 1st boot
+ #DietPi First-Run Stage | -2 = PREP_SYSTEM/Unknown | -1 = first boot | 0 = 1st run dietpi-update | 1 = 1st run dietpi-software | 2 = completed | 10 = Pre-installed image, converts to 2 during 1st boot
G_DIETPI_INSTALL_STAGE=-2
- if [[ -r '/DietPi/dietpi/.install_stage' ]]; then
+ if [[ -f '/DietPi/dietpi/.install_stage' ]]; then
G_DIETPI_INSTALL_STAGE=$( /tmp/G_CHECK_URL
+ wget --spider $optional_cmd_inputs --timeout=$timeout --tries=1 "$string" &> $G_ERROR_HANDLER_ONERROR_FPLOGFILE
G_ERROR_HANDLER_EXITCODE=$?
# Valid
if (( ! $G_ERROR_HANDLER_EXITCODE )); then
@@ -1445,16 +1415,12 @@ $print_logfile_info
else
sleep 2
- error_connection_failed=1
G_DIETPI-NOTIFY -2 "Failed connection attempt ($i/$retry_max), retrying..."
fi
done
- #--no-check-certificate
- #https://github.com/Fourdee/DietPi/issues/352#issuecomment-221013166
-
G_ERROR_HANDLER
if (( ! $G_ERROR_HANDLER_EXITCODE )); then
@@ -1464,8 +1430,6 @@ $print_logfile_info
done
- rm /tmp/G_CHECK_URL
-
return $G_ERROR_HANDLER_EXITCODE_RETURN
}
@@ -1904,7 +1868,7 @@ $print_logfile_info
G_CHECK_ROOT_USER 1
- du -k --max-depth=1 $1 | sort -nr | awk '
+ du -k --max-depth=1 $1 | sort -nr | mawk '
BEGIN {
split("KB,MB,GB,TB", Units, ",");
}
@@ -1921,26 +1885,6 @@ $print_logfile_info
'
}
- #rpi-update
- # - Holds APT packages
- # - Skips backup
- # - Creates file (/var/lib/dietpi/.G_RPI_UPDATE) on succesful update
- G_RPI_UPDATE(){
-
- G_CHECK_ROOT_USER 1
-
- if (( $G_HW_MODEL < 10 )); then
-
- G_DIETPI-NOTIFY 2 'Installing latest RPi dev kernel. Please wait, this make take some time...'
- G_AG_CHECK_INSTALL_PREREQ rpi-update
- SKIP_BACKUP=1 SKIP_WARNING=1 G_RUN_CMD rpi-update #PRUNE_MODULES=1 would remove old/unused /lib/modules/* directories, too dangerous if update fails/firmware is unstable?
- apt-mark hold raspberrypi-bootloader raspberrypi-kernel libraspberrypi-bin libraspberrypi0
- date > /var/lib/dietpi/.G_RPI_UPDATE
-
- fi
-
- }
-
#Returns current CPU temp 'C
G_OBTAIN_CPU_TEMP(){
@@ -1986,7 +1930,7 @@ $print_logfile_info
else
- cpu_temp_current=$( awk '{print $1/1000}' <<< "$cpu_temp_current" | xargs printf "%0.0f" )
+ cpu_temp_current=$(mawk '{print $1/1000}' <<< "$cpu_temp_current" | xargs printf "%0.0f")
fi
@@ -2041,7 +1985,7 @@ $print_logfile_info
local return_value=1
local input_path="$1"
local input_required_space=$2
- local available_space=$(df -mP $input_path | sed -n 2p | awk '{print $4}')
+ local available_space=$(df -mP $input_path | sed -n 2p | mawk '{print $4}')
local string_output="Free space check: path=$input_path | available=$available_space MB | required=$input_required_space MB"
if [[ -z $input_required_space ]]; then
@@ -2377,6 +2321,15 @@ $print_logfile_info
}
+ # Apply and update to different branch
+ G_DEV_BRANCH(){
+
+ G_CHECK_ROOT_USER 1
+ G_CONFIG_INJECT 'DEV_GITBRANCH=' "DEV_GITBRANCH=$1" /DietPi/dietpi.txt
+ /DietPi/dietpi/dietpi-update -1
+
+ }
+
# Automatically opt in to DietPi-Survey and run + send benchmark + data
G_DEV_BENCH(){
@@ -2477,7 +2430,7 @@ Please retry with more specific parameter \$1 or apply the setting manually:
[[ $error ]] && { syntax_error; return 1; }
[[ $GCI_BACKUP == 1 && ! -f $file.bak ]] && cp -a $file $file.bak && G_DIETPI-NOTIFY 2 "Config file backup created: \e[33m$file.bak\e[0m"
- error=$(sed -Ei "0,/^[[:blank:]]*$pattern.*/s//$setting/" $file 2>&1) || { syntax_error; return 1; }
+ error=$(sed -Ei "0,/^[[:blank:]]*$pattern.*$/s//$setting/" $file 2>&1) || { syntax_error; return 1; }
G_DIETPI-NOTIFY 0 "Setting in \e[33m$file\e[0m adjusted: \e[33m$(sed -E "c\\$setting" <<< '' | sed 's|\\|\\\\|g')\e[0m"
fi
@@ -2486,7 +2439,7 @@ Please retry with more specific parameter \$1 or apply the setting manually:
[[ $error ]] && { syntax_error; return 1; }
[[ $GCI_BACKUP == 1 && ! -f $file.bak ]] && cp -a $file $file.bak && G_DIETPI-NOTIFY 2 "Config file backup created: \e[33m$file.bak\e[0m"
- error=$(sed -Ei "0,/^[[:blank:]#;]*$pattern.*/s//$setting/" $file 2>&1) || { syntax_error; return 1; }
+ error=$(sed -Ei "0,/^[[:blank:]#;]*$pattern.*$/s//$setting/" $file 2>&1) || { syntax_error; return 1; }
G_DIETPI-NOTIFY 0 "Comment in \e[33m$file\e[0m converted to setting: \e[33m$(sed -E "c\\$setting" <<< '' | sed 's|\\|\\\\|g')\e[0m"
else
@@ -2497,7 +2450,7 @@ Please retry with more specific parameter \$1 or apply the setting manually:
if error=$(grep -Eq "^[[:blank:]]*$after" $file 2>&1); then
[[ $GCI_BACKUP == 1 && ! -f $file.bak ]] && cp -a $file $file.bak && G_DIETPI-NOTIFY 2 "Config file backup created: \e[33m$file.bak\e[0m"
- error=$(sed -Ei "0,/^[[:blank:]]*$after.*/s//&\n$setting/" $file 2>&1) || { syntax_error; return 1; }
+ error=$(sed -Ei "0,/^[[:blank:]]*$after.*$/s//&\n$setting/" $file 2>&1) || { syntax_error; return 1; }
G_DIETPI-NOTIFY 0 "Added setting \e[33m$(sed -E "c\\$setting" <<< '' | sed 's|\\|\\\\|g')\e[0m to \e[33m$file\e[0m after line \e[33m$(grep -Em1 "^[[:blank:]]*$after" $file | sed 's|\\|\\\\|g')\e[0m"
else
@@ -2518,7 +2471,7 @@ Please retry with valid parameter \$4 or apply the setting manually:
[[ $GCI_BACKUP == 1 && ! -f $file.bak ]] && cp -a $file $file.bak && G_DIETPI-NOTIFY 2 "Config file backup created: \e[33m$file.bak\e[0m"
# The following sed does not work on empty files:
[[ ! -s $file ]] && echo '# Added by DietPi:' >> $file
- error=$(sed -Ei "\$s/\$/\n$setting/" $file 2>&1) || { syntax_error; return 1; }
+ error=$(sed -Ei "\$a\\$setting" $file 2>&1) || { syntax_error; return 1; }
G_DIETPI-NOTIFY 0 "Added setting \e[33m$(sed -E "c\\$setting" <<< '' | sed 's|\\|\\\\|g')\e[0m to end of file \e[33m$file\e[0m"
fi
diff --git a/dietpi/func/dietpi-led_control b/dietpi/func/dietpi-led_control
index 6da25893a7..46229ad2db 100644
--- a/dietpi/func/dietpi-led_control
+++ b/dietpi/func/dietpi-led_control
@@ -18,18 +18,14 @@
#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
- G_CHECK_ROOT_USER
G_PROGRAM_NAME='DietPi-LED_Control'
+ G_CHECK_ROOT_USER
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
#Grab Input
INPUT=0
- if disable_error=1 G_CHECK_VALIDINT $1; then
-
- INPUT=$1
-
- fi
+ disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1
FP_SETTINGS='/DietPi/dietpi/.dietpi-led_control'
@@ -45,8 +41,8 @@
do
# Obtain available/cur settings
- aLED_SETTING_AVAILABLE[$i]=$(cat /sys/class/leds/${aLED_NAME[$i]}/trigger | tr -d '[]')
- aLED_SETTING_CURRENT[$i]=$(cat /sys/class/leds/${aLED_NAME[$i]}/trigger | grep -o '\[.*\]' | tr -d '[]')
+ aLED_SETTING_AVAILABLE[$i]=$(tr -d '[]' < /sys/class/leds/${aLED_NAME[$i]}/trigger)
+ aLED_SETTING_CURRENT[$i]=$(grep -o '\[.*\]' /sys/class/leds/${aLED_NAME[$i]}/trigger | tr -d '[]')
done
@@ -61,7 +57,7 @@
Settings_Write_Apply(){
- rm "$FP_SETTINGS" &> /dev/null
+ [[ -f $FP_SETTINGS ]] && rm $FP_SETTINGS
G_DIETPI-NOTIFY 3 "$G_PROGRAM_NAME" 'Applying LED triggers'
@@ -69,7 +65,7 @@
do
- echo -e "${aLED_SETTING_CURRENT[$i]}" > "/sys/class/leds/${aLED_NAME[$i]}/trigger"
+ echo "${aLED_SETTING_CURRENT[$i]}" > "/sys/class/leds/${aLED_NAME[$i]}/trigger"
if (( $? == 0 )); then
G_DIETPI-NOTIFY 0 "${aLED_NAME[$i]}: ${aLED_SETTING_CURRENT[$i]}"
@@ -80,9 +76,7 @@
fi
- cat << _EOF_ >> "$FP_SETTINGS"
-${aLED_NAME[$i]} ${aLED_SETTING_CURRENT[$i]}
-_EOF_
+ echo "${aLED_NAME[$i]} ${aLED_SETTING_CURRENT[$i]}" >> $FP_SETTINGS
done
@@ -90,7 +84,7 @@ _EOF_
Settings_Read(){
- if [ -f "$FP_SETTINGS" ]; then
+ if [[ -f $FP_SETTINGS ]]; then
local index=0
while read -r line
@@ -98,9 +92,9 @@ _EOF_
if (( $index < ${#aLED_NAME[@]} )); then #Only process available LED's at time of script
- if [[ ${aLED_NAME[$index]} == $(awk '{print $1}' <<< "$line") ]]; then
+ if [[ ${aLED_NAME[$index]} == $(mawk '{print $1}' <<< "$line") ]]; then
- aLED_SETTING_CURRENT[$index]=$(awk '{print $2}' <<< "$line")
+ aLED_SETTING_CURRENT[$index]=$(mawk '{print $2}' <<< "$line")
((index++))
fi
@@ -111,7 +105,7 @@ _EOF_
fi
- done < "$FP_SETTINGS"
+ done < $FP_SETTINGS
fi
@@ -138,8 +132,7 @@ _EOF_
done
G_WHIP_BUTTON_CANCEL_TEXT='Exit'
- G_WHIP_MENU 'Please select an LED to configure its options:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select an LED to configure its options:'; then
SELECTED_LED_NAME=$G_WHIP_RETURNED_VALUE
TARGETMENUID=1
@@ -160,7 +153,7 @@ _EOF_
if [[ $SELECTED_LED_NAME == ${aLED_NAME[$i]} ]]; then
- echo -e "${aLED_SETTING_AVAILABLE[$i]}" | tr ' ' '\n' > /tmp/aLED_SETTING_AVAILABLE
+ tr ' ' '\n' <<< "${aLED_SETTING_AVAILABLE[$i]}" > /tmp/aLED_SETTING_AVAILABLE
while read -r line
do
@@ -178,9 +171,8 @@ _EOF_
done
- G_WHIP_DEFAULT_ITEM="$DEFAULT_ITEM"
- G_WHIP_MENU "Please select an option for $SELECTED_LED_NAME LED:"
- if (( $? == 0 )); then
+ G_WHIP_DEFAULT_ITEM=$DEFAULT_ITEM
+ if G_WHIP_MENU "Please select an option for $SELECTED_LED_NAME LED:"; then
aLED_SETTING_CURRENT[$current_index]=$G_WHIP_RETURNED_VALUE
Settings_Write_Apply
@@ -217,11 +209,6 @@ _EOF_
fi
#-----------------------------------------------------------------------------------
- #Delete[] array
- unset aLED_NAME
- unset aLED_SETTING_AVAILABLE
- unset aLED_SETTING_CURRENT
- #-----------------------------------------------------------------------------------
exit
#-----------------------------------------------------------------------------------
}
diff --git a/dietpi/func/dietpi-logclear b/dietpi/func/dietpi-logclear
index 62cd847bc3..6115ba42ae 100644
--- a/dietpi/func/dietpi-logclear
+++ b/dietpi/func/dietpi-logclear
@@ -19,17 +19,17 @@
#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
G_PROGRAM_NAME='DietPi-Logclear'
- G_INIT
G_CHECK_ROOT_USER
+ G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
INPUT=-1
- disable_error=1 G_CHECK_VALIDINT $1 && INPUT=$1
+ disable_error=1 G_CHECK_VALIDINT "$1" && INPUT=$1
#////////////////////////////////////////////////////////////////
# Global
#////////////////////////////////////////////////////////////////
- TEMP_FILE='/tmp/dietpi-logclear'
+ TEMP_FILE='dietpi-logclear'
FILEPATH_LOGFOLDER='/var/log'
FILEPATH_BACKUPFOLDER="$HOME/logfile_storage"
@@ -61,6 +61,10 @@
#////////////////////////////////////////////////////////////////
Process_Logfiles(){
+ #-----------------------------------------------------------------------------------
+ #Remove internally rotated LetsEncrypt log files, prior to log loop
+ [[ -d $FILEPATH_LOGFOLDER/letsencrypt ]] && rm -f $FILEPATH_LOGFOLDER/letsencrypt/letsencrypt.log.*
+
#-----------------------------------------------------------------------------------
#Find existing logs and generate a filepath list.
find $FILEPATH_LOGFOLDER -type f > $TEMP_FILE
@@ -80,21 +84,20 @@
FILE_TYPE=0
#Special Filetypes
- #PiHole logs (contains dns stats) | FILE_TYPE 2
+ #Pi-hole logs (contains dns stats) | FILE_TYPE 2
if [[ ${ARRAY_LOG_FILEPATH[$i]} == '/var/log/pihole.log' ]]; then
FILE_TYPE=2
#Compessed files (zip etc) | FILE_TYPE 1
- elif [[ ${FILE_NAME: -4} == '.zip' || ${FILE_NAME: -3} == '.gz' ]]; then
+ elif [[ ${FILE_NAME: -4} == '.zip' || ${FILE_NAME: -3} == '.gz' ]]; then
FILE_TYPE=1
#Normal Log Files.
# - Exclude <= 10 byte size
# - Exclude .db* extentions SQLite (.db .db-shm .db.wal)
- elif (( $FILESIZE_BYTES <= 10 )) ||
- [[ $FILE_NAME =~ '.db' ]]; then
+ elif (( $FILESIZE_BYTES <= 10 )) || [[ $FILE_NAME =~ '.db' ]]; then
PROCESS_FILE=0
@@ -103,7 +106,7 @@
#Process File
if (( $PROCESS_FILE == 1 )); then
- #PiHole
+ #Pi-hole
if (( $FILE_TYPE == 2 )); then
local pihole_restart_required=0
@@ -118,12 +121,12 @@
# RAMlog mode 2:
if (( $INPUT == 0 )); then
- cat "${ARRAY_LOG_FILEPATH[$i]}" | sed "/$month_day_today/d" >> "$FILEPATH_BACKUPFOLDER/$FILE_NAME"
+ sed "/$month_day_today/d" "${ARRAY_LOG_FILEPATH[$i]}" >> "$FILEPATH_BACKUPFOLDER/$FILE_NAME"
((INFO_BACKUPS_MADE++))
fi
- G_DIETPI-NOTIFY 2 'Clearing log entries for PiHole, that are not from today, please wait...'
+ G_DIETPI-NOTIFY 2 'Clearing log entries for Pi-hole, that are not from today, please wait...'
sed -i '/'"$month_day_today"'/!d' /var/log/pihole.log
pihole_restart_required=1
@@ -228,7 +231,7 @@
done
#Remove temp files
- rm $TEMP_FILE &> /dev/null
+ rm $TEMP_FILE
#delete[] array
unset ARRAY_LOG_FILEPATH
@@ -262,11 +265,7 @@
Process_Logfiles
#Delete logfile backups
- if (( $INPUT == 2 )); then
-
- rm -R $FILEPATH_BACKUPFOLDER &> /dev/null
-
- fi
+ (( $INPUT == 2 )) && rm -R $FILEPATH_BACKUPFOLDER &> /dev/null
#Print Info
G_DIETPI-NOTIFY 2
diff --git a/dietpi/func/dietpi-obtain_hw_model b/dietpi/func/dietpi-obtain_hw_model
index ccbc9fb6d5..f8bd4d0bb0 100644
--- a/dietpi/func/dietpi-obtain_hw_model
+++ b/dietpi/func/dietpi-obtain_hw_model
@@ -9,10 +9,10 @@
#
# Info:
# - Generates /DietPi/dietpi/.hw_model
- # - Called from /DietPi/dietpi/boot
+ # - Called from /DietPi/dietpi/preboot
#
# In DietPi-Software:
- # MAX_G_HW_MODEL=64 #This needs to match highest G_HW_MODEL value in dietpi-obtain_hw_model
+ # MAX_G_HW_MODEL=71 #This needs to match highest G_HW_MODEL value in dietpi-obtain_hw_model
# MAX_G_HW_ARCH=10 #This needs to match highest G_HW_ARCH value in dietpi-obtain_hw_model
#
# - Line1 -
@@ -117,10 +117,12 @@
#Obtain Hardware Model index
#/////////////////////////////////////////////////////////////////////////////////////
+ FP_G_HW_MODEL_INDENTIFIER='/etc/.dietpi_hw_model_identifier'
+
G_HW_MODEL=0
G_HW_MODEL_DESCRIPTION='Unknown Device'
- FP_G_HW_MODEL_INDENTIFIER='/etc/.dietpi_hw_model_identifier'
G_DISTRO=0
+ ROOTFS_DEVICE_PATH=$(df | mawk '/\/$/ {print $1;exit}')
HW_UUID=0
G_HW_ARCH=0
G_HW_ARCH_DESCRIPTION='unknown'
@@ -128,8 +130,6 @@
G_HW_CPUID=0
HW_ONBOARD_WIFI=0
- ROOTFS_DEVICE_PATH=$(df | grep -m1 '/$' | awk '{print $1}')
-
# RPi Extras
HW_REVISION_CODE=0
HW_RELEASE_DATE='Unknown'
@@ -142,7 +142,7 @@
#-----------------------------------------------------------------------------------
#Obtain device info by revision number
# *" because 10000002 then it indicates that your Raspberry Pi has been over-volted
- HW_REVISION_CODE=$(grep -m1 'Revision' /proc/cpuinfo | awk '{print $3}')
+ HW_REVISION_CODE=$(mawk '/Revision/ {print $3;exit}' /proc/cpuinfo)
G_HW_MODEL_DESCRIPTION='RPi '
@@ -426,7 +426,7 @@
#Systems that use /etc/.dietpi_hw_model_identifier for G_HW_MODEL
if [[ -f $FP_G_HW_MODEL_INDENTIFIER ]]; then
- G_HW_MODEL=$(sed -n 1p "$FP_G_HW_MODEL_INDENTIFIER")
+ G_HW_MODEL=$(sed -n 1p $FP_G_HW_MODEL_INDENTIFIER)
#Beagle Bone Black
if (( $G_HW_MODEL == 71 )); then
@@ -677,13 +677,13 @@
fi
#Generate UUID if it does not exist
- if [[ ! -f '/DietPi/dietpi/.hw_model' ]]; then
+ if [[ -f '/DietPi/dietpi/.hw_model' ]]; then
- HW_UUID=$(cat /proc/sys/kernel/random/uuid)
+ HW_UUID=$(sed -n 5p /DietPi/dietpi/.hw_model)
else
- HW_UUID=$(sed -n 5p /DietPi/dietpi/.hw_model)
+ HW_UUID=$( /DietPi/dietpi/.hw_model
-$G_HW_MODEL
+ echo "$G_HW_MODEL
$G_HW_MODEL_DESCRIPTION
$G_DISTRO
$ROOTFS_DEVICE_PATH
@@ -727,12 +726,13 @@ $G_HW_ARCH_DESCRIPTION
$IMAGE_ADDITIONAL_CREDITS
$G_HW_CPUID
$HW_ONBOARD_WIFI
-$HW_REVISION_CODE
-$HW_RELEASE_DATE
-$HW_PCB_REVISION_CODE
-$HW_MEMORY_SIZE
-$HW_MANUFACTURER_NAME
-_EOF_
+HW_MEMORY_SIZE=$HW_MEMORY_SIZE" > /DietPi/dietpi/.hw_model
+
+ # - RPi Extras
+ (( $G_HW_MODEL < 10 )) && echo "$HW_REVISION_CODE
+HW_RELEASE_DATE=$HW_RELEASE_DATE
+HW_PCB_REVISION_CODE=$HW_PCB_REVISION_CODE
+HW_MANUFACTURER_NAME=$HW_MANUFACTURER_NAME" >> /DietPi/dietpi/.hw_model
}
diff --git a/dietpi/func/dietpi-ramlog b/dietpi/func/dietpi-ramlog
index 178f8f372d..7212380b29 100644
--- a/dietpi/func/dietpi-ramlog
+++ b/dietpi/func/dietpi-ramlog
@@ -41,18 +41,23 @@
echo "$(date) | $PROGRAM_NAME: Startup - Restoring log folder structure to RAMdisk..."
- # - Set bit permission
- chmod 775 /var/log
+ if [[ -d $FP_DIETPI_RAMLOG_SAVE ]]; then
- # - Apply previous attributes and ownerships. Generates empty file if it doesnt exist.
- [[ -d $FP_DIETPI_RAMLOG_SAVE ]] && cp -R -p --attributes-only $FP_DIETPI_RAMLOG_SAVE/. /var/log/
- EXIT_CODE=$?; if (( $EXIT_CODE )); then
+ # - Apply previous attributes and ownerships. Generates empty file if it doesnt exist.
+ cp -Rp --attributes-only $FP_DIETPI_RAMLOG_SAVE/. /var/log/
+ EXIT_CODE=$?; if (( $EXIT_CODE )); then
+
+ echo "$(date) | $PROGRAM_NAME: Startup failed with exit code $EXIT_CODE"
+
+ else
+
+ echo "$(date) | $PROGRAM_NAME: Startup completed"
- echo "$(date) | $PROGRAM_NAME: Startup failed with exit code $EXIT_CODE"
+ fi
else
- echo "$(date) | $PROGRAM_NAME: Startup completed"
+ echo "$(date) | $PROGRAM_NAME: No logs found on disk. Aborting..."
fi
@@ -64,7 +69,7 @@
# - Clear previous storage data
if [[ -d $FP_DIETPI_RAMLOG_SAVE ]]; then
- rm -R $FP_DIETPI_RAMLOG_SAVE/* &> /dev/null
+ rm -Rf $FP_DIETPI_RAMLOG_SAVE/{,.??,.[^.]}*
# - Create dir
else
@@ -74,7 +79,7 @@
fi
# - Copy logfile attributes and ownership to storage (not file contents)
- cp -R -p --attributes-only /var/log/. $FP_DIETPI_RAMLOG_SAVE/
+ cp -Rp --attributes-only /var/log/. $FP_DIETPI_RAMLOG_SAVE/
EXIT_CODE=$?; if (( $EXIT_CODE )); then
echo "$(date) | $PROGRAM_NAME: Shutdown failed with exit code $EXIT_CODE"
diff --git a/dietpi/func/dietpi-set_cpu b/dietpi/func/dietpi-set_cpu
index e8a9c454f1..4c115374b1 100644
--- a/dietpi/func/dietpi-set_cpu
+++ b/dietpi/func/dietpi-set_cpu
@@ -16,8 +16,8 @@
#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
- G_CHECK_ROOT_USER
G_PROGRAM_NAME='DietPi-CPU_set'
+ G_CHECK_ROOT_USER
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
@@ -29,10 +29,10 @@
fi
- CPU_GOVERNOR=$(grep -m1 '^CONFIG_CPU_GOVERNOR=' /DietPi/dietpi.txt | sed 's/.*=//')
- CPU_MAX_FREQ=$(grep -m1 '^CONFIG_CPU_MAX_FREQ=' /DietPi/dietpi.txt | sed 's/.*=//')
- CPU_MIN_FREQ=$(grep -m1 '^CONFIG_CPU_MIN_FREQ=' /DietPi/dietpi.txt | sed 's/.*=//')
- CPU_DISABLE_TURBO=$(grep -m1 '^CONFIG_CPU_DISABLE_TURBO=' /DietPi/dietpi.txt | sed 's/.*=//')
+ CPU_GOVERNOR=$(grep -m1 '^[[:blank:]]*CONFIG_CPU_GOVERNOR=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
+ CPU_MAX_FREQ=$(grep -m1 '^[[:blank:]]*CONFIG_CPU_MAX_FREQ=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
+ CPU_MIN_FREQ=$(grep -m1 '^[[:blank:]]*CONFIG_CPU_MIN_FREQ=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
+ CPU_DISABLE_TURBO=$(grep -m1 '^[[:blank:]]*CONFIG_CPU_DISABLE_TURBO=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
Check_GPU_Gov_Available(){
@@ -82,17 +82,8 @@
# - Intel based 0-100%:
if [[ -f /sys/devices/system/cpu/intel_pstate/max_perf_pct ]]; then
- if ! disable_error=1 G_CHECK_VALIDINT $CPU_MAX_FREQ; then
-
- CPU_MAX_FREQ=100
-
- fi
-
- if ! disable_error=1 G_CHECK_VALIDINT $CPU_MIN_FREQ; then
-
- CPU_MIN_FREQ=25
-
- fi
+ disable_error=1 G_CHECK_VALIDINT "$CPU_MAX_FREQ" || CPU_MAX_FREQ=100
+ disable_error=1 G_CHECK_VALIDINT "$CPU_MIN_FREQ" || CPU_MIN_FREQ=25
echo $CPU_MAX_FREQ > /sys/devices/system/cpu/intel_pstate/max_perf_pct
echo $CPU_MIN_FREQ > /sys/devices/system/cpu/intel_pstate/min_perf_pct
@@ -112,13 +103,13 @@
# Reset to defaults if no/invalid entry
local converted_hz_value_max=-1 #-1 indicates reset CPU freqs
local converted_hz_value_min=-1 #-1 indicates reset CPU freqs
- if disable_error=1 G_CHECK_VALIDINT $CPU_MAX_FREQ; then
+ if disable_error=1 G_CHECK_VALIDINT "$CPU_MAX_FREQ"; then
converted_hz_value_max=$(( $CPU_MAX_FREQ * 1000 ))
fi
- if disable_error=1 G_CHECK_VALIDINT $CPU_MIN_FREQ; then
+ if disable_error=1 G_CHECK_VALIDINT "$CPU_MIN_FREQ"; then
converted_hz_value_min=$(( $CPU_MIN_FREQ * 1000 ))
@@ -134,7 +125,7 @@
else
- cat /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_available_frequencies | awk '{print $1}' > /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_min_freq
+ mawk '{print $1}' /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_available_frequencies > /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_min_freq
fi
@@ -144,7 +135,7 @@
else
- cat /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_available_frequencies | awk '{print $NF}' > /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_max_freq
+ mawk '{print $NF}' /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_available_frequencies > /sys/devices/system/cpu/cpu${i}/cpufreq/scaling_max_freq
fi
diff --git a/dietpi/func/dietpi-set_dphys-swapfile b/dietpi/func/dietpi-set_dphys-swapfile
index edc6759f1c..7c60b0680b 100644
--- a/dietpi/func/dietpi-set_dphys-swapfile
+++ b/dietpi/func/dietpi-set_dphys-swapfile
@@ -19,33 +19,25 @@
#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
- G_CHECK_ROOT_USER
G_PROGRAM_NAME='DietPi-Swapfile'
+ G_CHECK_ROOT_USER
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
- SWAP_SIZE=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_SIZE=' /DietPi/dietpi.txt | sed 's/.*=//')
- SWAP_LOCATION="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=' /DietPi/dietpi.txt | sed 's/.*=//')"
+ SWAP_SIZE=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_SIZE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
+ SWAP_LOCATION="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
SWAP_SIZE_TARGET=$SWAP_SIZE
- if disable_error=1 G_CHECK_VALIDINT $1; then
-
- SWAP_SIZE_TARGET=$1
-
- fi
+ disable_error=1 G_CHECK_VALIDINT "$1" && SWAP_SIZE_TARGET=$1
SWAP_LOCATION_TARGET="$SWAP_LOCATION"
- if [[ $2 ]]; then
-
- SWAP_LOCATION_TARGET="$2"
-
- fi
+ [[ $2 ]] && SWAP_LOCATION_TARGET=$2
Delete_Swapfile(){
G_RUN_CMD swapoff -a
G_DIETPI-NOTIFY 2 "Deleting existing swapfile ($SWAP_LOCATION)"
- rm "$SWAP_LOCATION" &> /dev/null
+ [[ -f $SWAP_LOCATION ]] && rm "$SWAP_LOCATION"
sed -i '/[[:blank:]]swap[[:blank:]]/d' /etc/fstab
systemctl daemon-reload
@@ -54,16 +46,16 @@
Update_DietPi_Conf(){
# DietPi.txt
- sed -i "/^[[:blank:]]*AUTO_SETUP_SWAPFILE_SIZE=/c\AUTO_SETUP_SWAPFILE_SIZE=$SWAP_SIZE" /DietPi/dietpi.txt
- sed -i "/^[[:blank:]]*AUTO_SETUP_SWAPFILE_LOCATION=/c\AUTO_SETUP_SWAPFILE_LOCATION=$SWAP_LOCATION" /DietPi/dietpi.txt
+ G_CONFIG_INJECT 'AUTO_SETUP_SWAPFILE_SIZE=' "AUTO_SETUP_SWAPFILE_SIZE=$SWAP_SIZE" /DietPi/dietpi.txt
+ G_CONFIG_INJECT 'AUTO_SETUP_SWAPFILE_LOCATION=' "AUTO_SETUP_SWAPFILE_LOCATION=$SWAP_LOCATION" /DietPi/dietpi.txt
}
Update_Tmp(){
#Set /tmp to 50% of RAM+SWAP: https://github.com/Fourdee/DietPi/issues/1027#issuecomment-369373082
- local mem_total=$(free -m | grep -m1 'Mem:' | awk '{print $2}')
- local swap_size=$(free -m | grep -im1 'Swap:' | awk '{print $2}')
+ local mem_total=$(free -m | mawk '/Mem:/ {print $2;exit}')
+ local swap_size=$(free -m | mawk '/Swap:/ {print $2;exit}')
local tmp_target_size="$(( ( $mem_total + $swap_size ) / 2 ))M"
G_DIETPI-NOTIFY 2 "Setting /tmp tmpfs size: $tmp_target_size"
@@ -161,18 +153,10 @@ _EOF_
Swap_Disable
#Auto size?
- if (( $SWAP_SIZE_TARGET == 1 )); then
-
- SWAP_SIZE_TARGET=$(( 2048 - $(free -m | grep -m1 'Mem:' | awk '{print $2}') ))
-
- fi
+ (( $SWAP_SIZE_TARGET == 1 )) && SWAP_SIZE_TARGET=$(( 2048 - $(free -m | mawk '/Mem:/ {print $2;exit}') ))
#Configure new swapfile?
- if (( $SWAP_SIZE_TARGET > 0 )); then
-
- Swap_Enable
-
- fi
+ (( $SWAP_SIZE_TARGET > 0 )) && Swap_Enable
fi
#-----------------------------------------------------------------------------------
diff --git a/dietpi/func/dietpi-set_hardware b/dietpi/func/dietpi-set_hardware
index b1925240f4..04e6f0aad8 100644
--- a/dietpi/func/dietpi-set_hardware
+++ b/dietpi/func/dietpi-set_hardware
@@ -13,28 +13,29 @@
FP_SCRIPT='/DietPi/dietpi/func/dietpi-set_hardware'
AVAIABLE_COMMANDS="
Available commands
-$FP_SCRIPT rpi3_usb_boot enable
-$FP_SCRIPT rpi-camera enable/disable
-$FP_SCRIPT gpumemsplit 64/128/256 #RPi only
-$FP_SCRIPT remoteir odroid_remote/justboom_ir_remote
-$FP_SCRIPT eth-forcespeed 10/100/1000/disable
-$FP_SCRIPT rpi-opengl vc4-kms-v3d/vc4-fkms-v3d/disable
-$FP_SCRIPT i2c enable/disable/khz
-$FP_SCRIPT wificountrycode GB/US/DE
-$FP_SCRIPT wifimodules enable/disable/onboard_enable/onboard_disable
$FP_SCRIPT enableipv6 enable/disable
$FP_SCRIPT preferipv4 enable/disable
+$FP_SCRIPT eth-forcespeed 10/100/1000/disable
+$FP_SCRIPT wifimodules enable/disable/onboard_enable/onboard_disable
+$FP_SCRIPT wificountrycode GB/US/DE
$FP_SCRIPT bluetooth enable/disable
$FP_SCRIPT serialconsole enable/disable
-$FP_SCRIPT soundcard target_card (non-matching name for reset to default) add '-eq' to target_card string, enable alsa eq on card. HW:x,x (specify target card and device index eg: HW:9,1)
+$FP_SCRIPT i2c enable/disable/khz
+$FP_SCRIPT soundcard target_card (non-matching name for reset to default) add '-eq' to target_card string, enable alsa eq on card. HW:x,x (specify target card and device index eg: HW:9,1)
+$FP_SCRIPT remoteir odroid_remote/justboom_ir_remote # Odroid/RPi only
$FP_SCRIPT lcdpanel target_panel (none to remove all)
+$FP_SCRIPT gpumemsplit 64/128/256 # RPi only
+$FP_SCRIPT headless enable/disable
+$FP_SCRIPT rpi-camera enable/disable
+$FP_SCRIPT rpi-opengl vc4-kms-v3d/vc4-fkms-v3d/disable
+$FP_SCRIPT rpi3_usb_boot enable
"
#////////////////////////////////////
#Grab Inputs
- INPUT_DEVICE_NAME="${1,,}"
- INPUT_DEVICE_VALUE="${2,,}"
- # - support for 0/1 inputs for enable/disable
+ INPUT_DEVICE_NAME=${1,,}
+ INPUT_DEVICE_VALUE=${2,,}
+ # - Support for 1/0 inputs for enable/disable
if [[ $INPUT_DEVICE_VALUE == '1' ]]; then
INPUT_DEVICE_VALUE='enable'
@@ -69,8 +70,7 @@ $FP_SCRIPT lcdpanel target_panel (none to remove all)
EXIT_CODE=1
G_DIETPI-NOTIFY 2 "Unknown input name ($INPUT_DEVICE_NAME). Nothing has been applied."
-
- echo -e "$AVAIABLE_COMMANDS"
+ echo "$AVAIABLE_COMMANDS"
}
@@ -78,8 +78,21 @@ $FP_SCRIPT lcdpanel target_panel (none to remove all)
EXIT_CODE=1
G_DIETPI-NOTIFY 2 "Unknown input value ($INPUT_DEVICE_VALUE). Nothing has been applied."
+ echo "$AVAIABLE_COMMANDS"
+
+ }
+
+ Unsupported_Input_Name(){
+
+ EXIT_CODE=0
+ G_DIETPI-NOTIFY 2 "Input name ($INPUT_DEVICE_NAME) is not supported by $G_HW_MODEL_DESCRIPTION. Nothing has been applied."
+
+ }
+
+ Unsupported_Input_Mode(){
- echo -e "$AVAIABLE_COMMANDS"
+ EXIT_CODE=0
+ G_DIETPI-NOTIFY 2 "Input value ($INPUT_DEVICE_VALUE) is not supported by $G_HW_MODEL_DESCRIPTION. Nothing has been applied."
}
@@ -88,7 +101,8 @@ $FP_SCRIPT lcdpanel target_panel (none to remove all)
#/////////////////////////////////////////////////////////////////////////////////////
RPi_Camera_Main(){
- # - int, assume RPi
+ (( $G_HW_MODEL > 9 )) && { Unsupported_Input_Name; return 1; } # Exit path for non-RPi
+
if [[ $INPUT_DEVICE_VALUE == 'enable' ]]; then
# - Enable RPi Camera module
@@ -97,8 +111,9 @@ $FP_SCRIPT lcdpanel target_panel (none to remove all)
# - v4l2 module (motioneye /dev/video0)
G_CONFIG_INJECT 'bcm2835-v4l2' 'bcm2835-v4l2' /etc/modules
+ local gpu_mem=$(sed -n '/^[[:blank:]]*gpu_mem_1024/{s/^[^=]*=//p;q}' $FP_RPI_CONFIG)
# - requires 128MB memory split min.
- if (( $(grep -m1 'gpu_mem_' $FP_RPI_CONFIG | sed 's/^.*=//g') < 128 )); then
+ if (( ${gpu_mem:-0} < 128 )); then
local tmp=$INPUT_DEVICE_VALUE
INPUT_DEVICE_VALUE=128
@@ -109,11 +124,12 @@ $FP_SCRIPT lcdpanel target_panel (none to remove all)
unset tmp
fi
+ unset gpu_mem
elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then
G_CONFIG_INJECT 'start_x=' 'start_x=0' $FP_RPI_CONFIG
- sed -i '/bcm2835-v4l2/d' /etc/modules
+ sed -i '/^[[:blank:]]*bcm2835-v4l2/d' /etc/modules
else
@@ -128,6 +144,8 @@ $FP_SCRIPT lcdpanel target_panel (none to remove all)
#/////////////////////////////////////////////////////////////////////////////////////
RPi_USB_Boot_Main(){
+ (( $G_HW_MODEL > 9 )) && { Unsupported_Input_Name; return 1; } # Exit path for non-RPi
+
if [[ $INPUT_DEVICE_VALUE == 'enable' ]]; then
G_CONFIG_INJECT 'program_usb_boot_mode=' 'program_usb_boot_mode=1' $FP_RPI_CONFIG
@@ -140,9 +158,9 @@ After=dietpi-boot.service
[Service]
Type=simple
RemainAfterExit=yes
-ExecStartPre=/bin/sed -i '/program_usb_boot_mode=/d' $FP_RPI_CONFIG
-ExecStartPre=/bin/systemctl disable dietpi-rm_program_usb_boot_mode
-ExecStart=/bin/systemctl daemon-reload
+ExecStartPre=$(command -v sed) -i '/^[[:blank:]]*program_usb_boot_mode=/d' $FP_RPI_CONFIG
+ExecStartPre=$(command -v systemctl) disable dietpi-rm_program_usb_boot_mode
+ExecStart=$(command -v systemctl) daemon-reload
[Install]
WantedBy=multi-user.target
@@ -152,7 +170,7 @@ systemctl enable dietpi-rm_program_usb_boot_mode
elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then
- sed -i '/program_usb_boot_mode=/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*program_usb_boot_mode=/d' $FP_RPI_CONFIG
else
@@ -167,12 +185,19 @@ systemctl enable dietpi-rm_program_usb_boot_mode
#/////////////////////////////////////////////////////////////////////////////////////
Gpu_Memory_Split_Main(){
- # - int, assume RPi
- if disable_error=1 G_CHECK_VALIDINT $INPUT_DEVICE_VALUE; then
+ (( $G_HW_MODEL > 9 )) && { Unsupported_Input_Name; return 1; } # Exit path for non-RPi
+
+ # Remove overridden "gpu_mem" setting
+ sed -i '/^[[:blank:]]*gpu_mem=' $FP_RPI_CONFIG
+
+ if disable_error=1 G_CHECK_VALIDINT "$INPUT_DEVICE_VALUE" 16 944; then
- G_CONFIG_INJECT 'gpu_mem_256=' "gpu_mem_256=$INPUT_DEVICE_VALUE" $FP_RPI_CONFIG
- G_CONFIG_INJECT 'gpu_mem_512=' "gpu_mem_512=$INPUT_DEVICE_VALUE" $FP_RPI_CONFIG
G_CONFIG_INJECT 'gpu_mem_1024=' "gpu_mem_1024=$INPUT_DEVICE_VALUE" $FP_RPI_CONFIG
+ local gpu_mem_cap=$INPUT_DEVICE_VALUE
+ (( $INPUT_DEVICE_VALUE >= 512 )) && gpu_mem_cap=448
+ G_CONFIG_INJECT 'gpu_mem_512=' "gpu_mem_512=$gpu_mem_cap" $FP_RPI_CONFIG
+ (( $INPUT_DEVICE_VALUE >= 256 )) && gpu_mem_cap=192
+ G_CONFIG_INJECT 'gpu_mem_256=' "gpu_mem_256=$gpu_mem_cap" $FP_RPI_CONFIG
else
@@ -183,29 +208,108 @@ systemctl enable dietpi-rm_program_usb_boot_mode
}
#/////////////////////////////////////////////////////////////////////////////////////
- #remoteir
+ #headless
#/////////////////////////////////////////////////////////////////////////////////////
- RemoteIR_Prereqs(){
+ Headless_Main(){
+
+ if [[ $INPUT_DEVICE_VALUE == 'enable' ]]; then
+
+ if (( $G_HW_MODEL < 10 )); then
+
+ # - Framebuffer dimensions should not play a role here, but
+ # if NOT set, they appear as "0" by asking "vcgencmd get_config (max_)?framebuffer_(width|height)"
+ # otherwise vcgencmd shows the set value. So we simply comment it.
+ G_CONFIG_INJECT 'framebuffer_width=' '#framebuffer_width=0' /DietPi/config.txt
+ G_CONFIG_INJECT 'framebuffer_height=' '#framebuffer_height=0' /DietPi/config.txt
+ G_CONFIG_INJECT 'max_framebuffer_width=' '#max_framebuffer_width=0' /DietPi/config.txt
+ G_CONFIG_INJECT 'max_framebuffer_height=' '#max_framebuffer_height=0' /DietPi/config.txt
+ # - framebuffer_depth defaults to a set value of 16, even with HDMI disabled, so we manually reduce it to min 8
+ G_CONFIG_INJECT 'framebuffer_depth=' 'framebuffer_depth=8' /DietPi/config.txt
+ # - Splash cannot be seen anyway, without video output
+ G_CONFIG_INJECT 'disable_splash=' 'disable_splash=1' /DietPi/config.txt
+ # - hdmi_blanking should not play a role, however mode 1 should be generally preferred, which on idle disables HDMI output completely instead of just blanking the screen
+ G_CONFIG_INJECT 'hdmi_blanking=' 'hdmi_blanking=1' /DietPi/config.txt
+ # - Disable HDMI hotplug, which requires it to be generally responsive/active
+ G_CONFIG_INJECT 'hdmi_ignore_hotplug=' 'hdmi_ignore_hotplug=1' /DietPi/config.txt
+ # - Disable composite hotplug, which then allows to completely disable the video pipeline + framebuffer
+ G_CONFIG_INJECT 'hdmi_ignore_composite=' 'hdmi_ignore_composite=1' /DietPi/config.txt
+
+ #odroid C1
+ elif (( $G_HW_MODEL == 10 )); then
+
+ G_CONFIG_INJECT 'setenv hdmioutput ' 'setenv hdmioutput "0"' /DietPi/boot.ini
+ G_CONFIG_INJECT 'setenv vpu ' 'setenv vpu "0"' /DietPi/boot.ini
+ G_CONFIG_INJECT 'setenv m_bpp ' 'setenv m_bpp "32"' /DietPi/boot.ini
+
+ #Odroid C2
+ elif (( $G_HW_MODEL == 12 )); then
+
+ G_CONFIG_INJECT 'setenv nographics ' 'setenv nographics "1"' /DietPi/boot.ini
+
+ else
+
+ Unsupported_Input_Name
- # - LIRC
- G_AG_CHECK_INSTALL_PREREQ lirc
+ fi
+
+ elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then
+
+ if (( $G_HW_MODEL < 10 )); then
+
+ G_CONFIG_INJECT 'framebuffer_depth=' '#framebuffer_depth=16' /DietPi/config.txt
+ G_CONFIG_INJECT 'hdmi_ignore_hotplug=' '#hdmi_ignore_hotplug=0' /DietPi/config.txt
+ G_CONFIG_INJECT 'hdmi_ignore_composite=' '#hdmi_ignore_composite=0' /DietPi/config.txt
+ G_CONFIG_INJECT 'hdmi_blanking=' '#hdmi_blanking=0' /DietPi/config.txt
+
+ #odroid C1
+ elif (( $G_HW_MODEL == 10 )); then
+
+ G_CONFIG_INJECT 'setenv hdmioutput ' 'setenv hdmioutput "1"' /DietPi/boot.ini
+ G_CONFIG_INJECT 'setenv vpu ' 'setenv vpu "1"' /DietPi/boot.ini
+ G_CONFIG_INJECT 'setenv m_bpp ' 'setenv m_bpp "32"' /DietPi/boot.ini
+
+ #Odroid C2
+ elif (( $G_HW_MODEL == 12 )); then
+
+ G_CONFIG_INJECT 'setenv nographics ' 'setenv nographics "0"' /DietPi/boot.ini
+
+ else
+
+ Unsupported_Input_Name
+
+ fi
+
+ else
+
+ Unknown_Input_Mode
+
+ fi
}
+ #/////////////////////////////////////////////////////////////////////////////////////
+ #remoteir
+ #/////////////////////////////////////////////////////////////////////////////////////
+ RemoteIR_Prereqs(){ G_AG_CHECK_INSTALL_PREREQ lirc; }
+
RemoteIR_Reset_All(){
# - Disable JustBoom
if (( $G_HW_MODEL < 10 )); then
- systemctl stop justboom-ir-mpd.service
- systemctl disable justboom-ir-mpd.service
- rm /etc/systemd/system/justboom-ir-mpd.service
+ if [[ -f /etc/systemd/system/justboom-ir-mpd.service ]]; then
+
+ systemctl stop justboom-ir-mpd.service
+ systemctl disable justboom-ir-mpd.service
+ rm /etc/systemd/system/justboom-ir-mpd.service
+
+ fi
- sed -i '/dtoverlay=lirc-rpi/d' $FP_RPI_CONFIG
- sed -i '/dtparam=gpio_in_pin=25/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=lirc-rpi/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtparam=gpio_in_pin=25/d' $FP_RPI_CONFIG
- # - Disable odroids
- elif (( $G_HW_MODEL < 20 )); then
+ # - Disable Odroids
+ elif (( $G_HW_MODEL < 20 )) && [[ -f /etc/systemd/system/odroid-remote.service ]]; then
systemctl stop odroid-remote
systemctl disable odroid-remote
@@ -217,25 +321,29 @@ systemctl enable dietpi-rm_program_usb_boot_mode
RemoteIR_Main(){
+ (( $G_HW_MODEL > 19 )) && { Unsupported_Input_Name; return 1; } # Exit path for non-Odroid/non-RPi
+
if [[ $INPUT_DEVICE_VALUE == 'odroid_remote' ]]; then
+ (( $G_HW_MODEL < 10 )) && { Unsupported_Input_Mode; return 1; } # Exit path for non-Odroid
+
RemoteIR_Prereqs
- RemoteIR_Reset_All &> /dev/null
+ RemoteIR_Reset_All
- # - xu4 Cloudshell
+ # - XU4 Cloudshell
if (( $G_HW_MODEL == 11 )); then
# - modules
local string='options gpioplug_ir_recv gpio_nr=24 active_low=1'
G_CONFIG_INJECT "$string" "$string" /etc/modprobe.d/odroid-cloudshell.conf
- string="gpio-ir-recv"
+ string='gpio-ir-recv'
G_CONFIG_INJECT "$string" "$string" /etc/modules
- string="gpioplug-ir-recv"
+ string='gpioplug-ir-recv'
G_CONFIG_INJECT "$string" "$string" /etc/modules
- # - c1/c2
+ # - C1/C2
elif (( $G_HW_MODEL == 10 || $G_HW_MODEL == 12 )); then
# - Module
@@ -244,23 +352,23 @@ systemctl enable dietpi-rm_program_usb_boot_mode
fi
# - All
- # - SystemD
+ # - Systemd
systemctl disable lirc
- rm /etc/init.d/lirc
+ [[ -f /etc/init.d/lirc ]] && rm /etc/init.d/lirc
cat << _EOF_ > /etc/systemd/system/odroid-remote.service
[Unit]
Description=Odroid Remote C1/C2/XU4
[Service]
Type=forking
-ExecStartPre=/bin/bash -c 'mkdir -p /var/run/lirc'
-ExecStart=/usr/sbin/lircd --output=/run/lirc/lircd --driver=default --device=/dev/lirc0 --uinput
+ExecStartPre=$(command -v mkdir) -p /var/run/lirc
+ExecStart=$(command -v lircd) --output=/run/lirc/lircd --driver=default --device=/dev/lirc0 --uinput
[Install]
WantedBy=multi-user.target
_EOF_
systemctl daemon-reload
- systemctl enable odroid-remote.service
+ systemctl enable odroid-remote
# Lircd conf for Odroid Remote
cat << _EOF_ > /etc/lirc/lircd.conf
@@ -302,13 +410,13 @@ _EOF_
elif [[ $INPUT_DEVICE_VALUE == 'justboom_ir_remote' ]]; then
+ (( $G_HW_MODEL > 9 )) && { Unsupported_Input_Mode; return 1; } # Exit path for non-RPi
+
RemoteIR_Prereqs
- RemoteIR_Reset_All &> /dev/null
+ RemoteIR_Reset_All
- cat << _EOF_ >> $FP_RPI_CONFIG
-dtoverlay=lirc-rpi
-dtparam=gpio_in_pin=25
-_EOF_
+ G_CONFIG_INJECT 'dtoverlay=lirc-rpi' 'dtoverlay=lirc-rpi' $FP_RPI_CONFIG
+ G_CONFIG_INJECT 'dtparam=gpio_in_pin=' 'dtparam=gpio_in_pin=25' $FP_RPI_CONFIG
cat << _EOF_ > /etc/lirc/hardware.conf
LIRCD_ARGS="--uinput"
@@ -414,25 +522,25 @@ _EOF_
# service
cat << _EOF_ > /etc/systemd/system/justboom-ir-mpd.service
[Unit]
-Description=justboom-ir-mpd
+Description=justboom-ir-mpd (DietPi)
After=sound.target lirc.service
[Service]
User=$USER
Type=simple
-ExecStart=/usr/bin/irexec
+ExecStart=$(command -v irexec)
[Install]
WantedBy=default.target
_EOF_
systemctl daemon-reload
- systemctl enable justboom-ir-mpd.service
- systemctl start justboom-ir-mpd.service
+ systemctl enable justboom-ir-mpd
+ systemctl start justboom-ir-mpd
elif [[ $INPUT_DEVICE_VALUE == 'none' ]]; then
- RemoteIR_Reset_All &> /dev/null
+ RemoteIR_Reset_All
else
@@ -447,30 +555,30 @@ _EOF_
#/////////////////////////////////////////////////////////////////////////////////////
Eth_Force_Speed_Main(){
- if (( $INPUT_DEVICE_VALUE > 0 )); then
+ if disable_error=1 G_CHECK_VALIDINT "$INPUT_DEVICE_VALUE" 1; then
local eth_force_speed=$INPUT_DEVICE_VALUE
local eth_adapter="eth$(sed -n 1p /DietPi/dietpi/.network)"
cat << _EOF_ > /etc/systemd/system/ethtool_force_speed.service
[Unit]
-Description=ethtool force speed
+Description=ethtool force speed (DietPi)
After=network-online.target
[Service]
Type=oneshot
-ExecStart=/sbin/ethtool -s $eth_adapter speed $eth_force_speed duplex full autoneg off
+ExecStart=$(command -v ethtool) -s $eth_adapter speed $eth_force_speed duplex full autoneg off
[Install]
WantedBy=ifup@$eth_adapter.service
_EOF_
systemctl daemon-reload
- systemctl enable ethtool_force_speed.service
- systemctl start ethtool_force_speed.service
+ systemctl enable ethtool_force_speed
+ systemctl start ethtool_force_speed
- elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then #0 is converted to 'disabled'
+ elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then # 0 is converted to 'disabled'
- rm /etc/systemd/system/ethtool_force_speed.service &> /dev/null
+ [[ -f /etc/systemd/system/ethtool_force_speed.service ]] && rm /etc/systemd/system/ethtool_force_speed.service
systemctl daemon-reload
else
@@ -486,35 +594,25 @@ _EOF_
#/////////////////////////////////////////////////////////////////////////////////////
RPi_OpenGL_Main(){
- #Always remove previous vc4 overlay entry
- sed -i '/dtoverlay=vc4-/d' $FP_RPI_CONFIG
-
- if [[ $INPUT_DEVICE_VALUE == "vc4-"* ]]; then
+ (( $G_HW_MODEL > 9 )) && { Unsupported_Input_Name; return 1; } # Exit path for non-RPi
- #RPi 2/3+ only
- if (( $G_HW_MODEL >= 2 && $G_HW_MODEL < 10 )); then
+ #Always remove previous vc4 overlay entry
+ sed -i '/^[[:blank:]]*dtoverlay=vc4-/d' $FP_RPI_CONFIG
- # - GL packages
- G_AG_CHECK_INSTALL_PREREQ libgl1-mesa-dri libgles2-mesa mesa-utils
+ if [[ $INPUT_DEVICE_VALUE == 'vc4-'* ]]; then
- echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> $FP_RPI_CONFIG
+ (( $G_HW_MODEL < 2 )) && { Unsupported_Input_Mode; return 1; } # RPi 2/3+ only
- # - set 1080p by default
- G_CONFIG_INJECT 'framebuffer_width=' 'framebuffer_width=1920' $FP_RPI_CONFIG
- G_CONFIG_INJECT 'framebuffer_height=' 'framebuffer_height=1080' $FP_RPI_CONFIG
+ # - GL packages
+ G_AG_CHECK_INSTALL_PREREQ libgl1-mesa-dri libgles2-mesa mesa-utils
- else
+ echo "dtoverlay=$INPUT_DEVICE_VALUE" >> $FP_RPI_CONFIG
- G_DIETPI-NOTIFY 1 'OpenGL requires an RPi 2 or higher'
- sleep 2
+ # - set 1080p by default
+ G_CONFIG_INJECT 'framebuffer_width=' 'framebuffer_width=1920' $FP_RPI_CONFIG
+ G_CONFIG_INJECT 'framebuffer_height=' 'framebuffer_height=1080' $FP_RPI_CONFIG
- fi
-
- elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then
-
- echo -e 'already done' &> /dev/null
-
- else
+ elif [[ $INPUT_DEVICE_VALUE != 'disable' ]]; then
Unknown_Input_Mode
@@ -525,13 +623,6 @@ _EOF_
#/////////////////////////////////////////////////////////////////////////////////////
# lcdpanel eg: All non-HDMI/VGA based displays and monitors.
#/////////////////////////////////////////////////////////////////////////////////////
- Lcd_Panel_Not_Available_For_Device(){
-
- EXIT_CODE=1
- G_DIETPI-NOTIFY 2 "$INPUT_DEVICE_VALUE is not available for this device. Nothing has been applied."
-
- }
-
Lcd_Panel_Main(){
local update_dietpitxt=1
@@ -568,11 +659,7 @@ _EOF_
fi
#Update dietpi.txt entry?
- if (( $update_dietpitxt )); then
-
- G_CONFIG_INJECT 'CONFIG_LCDPANEL=' "CONFIG_LCDPANEL=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt
-
- fi
+ (( $update_dietpitxt )) && G_CONFIG_INJECT 'CONFIG_LCDPANEL=' "CONFIG_LCDPANEL=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt
}
@@ -639,6 +726,8 @@ _EOF_
Lcd_Panel_Waveshare32_Enable(){
+ (( $G_HW_MODEL > 19 )) && { Unsupported_Input_Mode; return 1; } # Exit path for non-RPi/non-Odroid
+
#Disable 1st to reset any existing installations:
Lcd_Panel_Waveshare32_Disable
@@ -663,11 +752,7 @@ _EOF_
G_CONFIG_INJECT 'SOFTWARE_CHROMIUM_RES_X=' "SOFTWARE_CHROMIUM_RES_X=320" /DietPi/dietpi.txt
G_CONFIG_INJECT 'SOFTWARE_CHROMIUM_RES_Y=' "SOFTWARE_CHROMIUM_RES_Y=240" /DietPi/dietpi.txt
- cat << _EOF_ >> $FP_RPI_CONFIG
-
-#Waveshare 32 LCD
-dtoverlay=waveshare32b:rotate=270
-_EOF_
+ G_CONFIG_INJECT 'dtoverlay=waveshare32b' 'dtoverlay=waveshare32b:rotate=270' $FP_RPI_CONFIG
# - Swap input axis
sed -i '/"SwapAxes"/c\ Option "SwapAxes" "1"' /etc/X11/xorg.conf.d/99-waveshare32_calibration.conf
@@ -676,7 +761,7 @@ _EOF_
mv /usr/share/X11/xorg.conf.d/99-fbturbo.conf /usr/share/X11/99-fbturbo.conf
#Odroids
- elif (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )); then
+ else
# + X11
Lcd_Panel_Xorg_All_Enable
@@ -689,8 +774,8 @@ Description=con2fbmap
[Service]
Type=oneshot
-ExecStart=/bin/con2fbmap 1 2
-ExecStop=/bin/con2fbmap 1 0
+ExecStart=$(command -v con2fbmap) 1 2
+ExecStop=$(command -v con2fbmap) 1 0
RemainAfterExit=yes
@@ -700,8 +785,8 @@ _EOF_
systemctl daemon-reload
systemctl enable con2fbmap
- echo 'spicc' >> /etc/modules
- echo 'fbtft_device' >> /etc/modules
+ G_CONFIG_INJECT 'spicc' 'spicc' /etc/modules
+ G_CONFIG_INJECT 'fbtft_device' 'fbtft_device' /etc/modules
cat << _EOF_ > /etc/modprobe.d/waveshare32.conf
options fbtft_device name=odroidc_tft32 rotate=270 gpios=reset:116,dc:115 speed=32000000 cs=0
@@ -719,10 +804,6 @@ EndSection
_EOF_
- else
-
- Lcd_Panel_Not_Available_For_Device
-
fi
@@ -731,37 +812,37 @@ _EOF_
Lcd_Panel_Waveshare32_Disable(){
#all
- rm /etc/X11/xorg.conf.d/99-waveshare32_calibration.conf &> /dev/null
- rm /etc/X11/xorg.conf.d/99-waveshare32_xorg.conf &> /dev/null
- rm /usr/share/applications/xinput_calibrator.desktop &> /dev/null
+ [[ -f /etc/X11/xorg.conf.d/99-waveshare32_calibration.conf ]] && rm /etc/X11/xorg.conf.d/99-waveshare32_calibration.conf
+ [[ -f /etc/X11/xorg.conf.d/99-waveshare32_xorg.conf ]] && rm /etc/X11/xorg.conf.d/99-waveshare32_xorg.conf
+ [[ -f /usr/share/applications/xinput_calibrator.desktop ]] && rm /usr/share/applications/xinput_calibrator.desktop
#RPi
if (( $G_HW_MODEL < 10 )); then
- rm /boot/overlays/waveshare32b.dtbo &> /dev/null
+ [[ -f /boot/overlays/waveshare32b.dtbo ]] && rm /boot/overlays/waveshare32b.dtbo
sed -i 's/ fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo//' /boot/cmdline.txt
sed -i '/Waveshare 32 LCD/d' $FP_RPI_CONFIG
- sed -i '/dtoverlay=waveshare32b/d' $FP_RPI_CONFIG
- sed -i '/dtoverlay=ads7846,cs=1,penirq=17/d' $FP_RPI_CONFIG
- sed -i '/dtoverlay=w1-gpio-pullup,gpiopin=4,extpullup=1/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=waveshare32b/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=ads7846,cs=1,penirq=17/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=w1-gpio-pullup,gpiopin=4,extpullup=1/d' $FP_RPI_CONFIG
# - Leave these enabled, just incase the user has other hardware that may use them.
- #sed -i "/dtparam=i2c_arm=/c\dtparam=i2c_arm=on" $FP_RPI_CONFIG
- #sed -i "/dtparam=spi=/c\dtparam=spi=on" $FP_RPI_CONFIG
+ #sed -i '/^[[:blank:]]*dtparam=i2c_arm=/c\dtparam=i2c_arm=on' $FP_RPI_CONFIG
+ #sed -i '/^[[:blank:]]*dtparam=spi=/c\dtparam=spi=on' $FP_RPI_CONFIG
# - Move fb0 xorg.conf back: https://github.com/Fourdee/DietPi/issues/767
- mv /usr/share/X11/99-fbturbo.conf /usr/share/X11/xorg.conf.d/99-fbturbo.conf &> /dev/null
+ [[ -f /usr/share/X11/99-fbturbo.conf ]] && mv /usr/share/X11/99-fbturbo.conf /usr/share/X11/xorg.conf.d/99-fbturbo.conf
#Odroids
elif (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )); then
- rm /etc/systemd/system/con2fbmap.service &> /dev/null
+ [[ -f /etc/systemd/system/con2fbmap.service ]] && rm /etc/systemd/system/con2fbmap.service
systemctl daemon-reload
- rm /etc/modprobe.d/waveshare32.conf &> /dev/null
- sed -i '/^spicc/d' /etc/modules
- sed -i '/^fbtft_device/d' /etc/modules
+ [[ -f /etc/modprobe.d/waveshare32.conf ]] && rm /etc/modprobe.d/waveshare32.conf
+ sed -i '/^[[:blank:]]*spicc/d' /etc/modules
+ sed -i '/^[[:blank:]]*fbtft_device/d' /etc/modules
fi
@@ -774,17 +855,17 @@ _EOF_
options fbtft_device name=hktft9340 busnum=1 rotate=270
_EOF_
- echo 'spi_s3c64xx' >> /etc/modules
- echo 'fbtft_device' >> /etc/modules
+ G_CONFIG_INJECT 'spi_s3c64xx' 'spi_s3c64xx' /etc/modules
+ G_CONFIG_INJECT 'fbtft_device' 'fbtft_device' /etc/modules
echo 'fbtft_device' >> /etc/modules #XU4 4.9 workaround: https://github.com/Fourdee/DietPi/issues/926#issuecomment-299480918
}
Lcd_Panel_Odroidcloudshell_Disable(){
- rm /etc/modprobe.d/odroid-cloudshell.conf
- sed -i '/^spi_s3c64xx/d' /etc/modules
- sed -i '/^fbtft_device/d' /etc/modules
+ [[ -f /etc/modprobe.d/odroid-cloudshell.conf ]] && rm /etc/modprobe.d/odroid-cloudshell.conf
+ sed -i '/^[[:blank:]]*spi_s3c64xx/d' /etc/modules
+ sed -i '/^[[:blank:]]*fbtft_device/d' /etc/modules
##Cant run it on the fly, locks up device.
#root@DietPi-XU4:~# modprobe -rf spi_s3c64xx
@@ -796,51 +877,51 @@ _EOF_
# - Odroid LCD 3.5
Lcd_Panel_OdroidLCD35_Enable(){
- if (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )); then
+ (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )) || { Unsupported_Input_Mode; return 1; } # Exit path for non-Odroid
- #Reset to disabled:
- Lcd_Panel_OdroidLCD35_Disable
+ #Reset to disabled:
+ Lcd_Panel_OdroidLCD35_Disable
- Lcd_Panel_Xorg_All_Enable
+ Lcd_Panel_Xorg_All_Enable
- cat << _EOF_ > /etc/modprobe.d/odroid-lcd35.conf
+ cat << _EOF_ > /etc/modprobe.d/odroid-lcd35.conf
options fbtft_device name=flexpfb rotate=90
options flexfb chip=ili9488
_EOF_
- local amodules=(
+ local amodules=(
- 'fbtft_device'
- 'flexfb'
- 'sx865x'
+ 'fbtft_device'
+ 'flexfb'
+ 'sx865x'
- )
+ )
- # - C1/2
- if (( $G_HW_MODEL != 11 )); then
+ # - C1/2
+ if (( $G_HW_MODEL != 11 )); then
- amodules+=('aml_i2c')
- amodules+=('pwm-meson')
- amodules+=('pwm-ctrl')
+ amodules+=('aml_i2c')
+ amodules+=('pwm-meson')
+ amodules+=('pwm-ctrl')
- fi
+ fi
- for i in ${!amodules[@]}
- do
+ for i in ${!amodules[@]}
+ do
- # - Enable modules now, as we need to detect pwm path for service
- G_RUN_CMD modprobe ${amodules[$i]}
- G_CONFIG_INJECT "${amodules[$i]}" "${amodules[$i]}" /etc/modules
+ # - Enable modules now, as we need to detect pwm path for service
+ G_RUN_CMD modprobe ${amodules[$i]}
+ G_CONFIG_INJECT "${amodules[$i]}" "${amodules[$i]}" /etc/modules
- done
+ done
- unset amodules
+ unset amodules
- #Service
- # - XU4
- if (( $G_HW_MODEL == 11 )); then
+ #Service
+ # - XU4
+ if (( $G_HW_MODEL == 11 )); then
- cat << _EOF_ > /etc/systemd/system/odroid-lcd35.service
+ cat << _EOF_ > /etc/systemd/system/odroid-lcd35.service
[Unit]
Description=Odroid LCD 3.5
@@ -850,22 +931,22 @@ PathExists=/dev/fb2
[Service]
Type=oneshot
RemainAfterExit=yes
-ExecStart=/usr/bin/setterm -blank 0 -powersave off
-ExecStart=/bin/con2fbmap 1 2
+ExecStart=$(command -v setterm) -blank 0 -powersave off
+ExecStart=$(command -v con2fbmap) 1 2
StandardOutput=tty
[Install]
WantedBy=multi-user.target
_EOF_
- # - C1/2
- else
+ # - C1/2
+ else
- # Detect correct control files: https://github.com/Fourdee/DietPi/issues/2256
- local fp_control='/sys/devices/platform/pwm-ctrl'
- [[ -e '/sys/devices/pwm-ctrl/enable0' ]] && fp_control='/sys/devices/pwm-ctrl'
+ # Detect correct control files: https://github.com/Fourdee/DietPi/issues/2256
+ local fp_control='/sys/devices/platform/pwm-ctrl'
+ [[ -e '/sys/devices/pwm-ctrl/enable0' ]] && fp_control='/sys/devices/pwm-ctrl'
- cat << _EOF_ > /etc/systemd/system/odroid-lcd35.service
+ cat << _EOF_ > /etc/systemd/system/odroid-lcd35.service
[Unit]
Description=Odroid LCD 3.5
@@ -878,23 +959,23 @@ RemainAfterExit=yes
ExecStart=/bin/bash -c 'echo 500000 > $fp_control/freq0'
ExecStart=/bin/bash -c 'echo 1 > $fp_control/enable0'
ExecStart=/bin/bash -c 'echo 1023 > $fp_control/duty0'
-ExecStart=/usr/bin/setterm -blank 0 -powersave off
-ExecStart=/bin/con2fbmap 1 2
+ExecStart=$(command -v setterm) -blank 0 -powersave off
+ExecStart=$(command -v con2fbmap) 1 2
StandardOutput=tty
[Install]
WantedBy=multi-user.target
_EOF_
- fi
- systemctl daemon-reload
- systemctl enable odroid-lcd35.service
+ fi
+ systemctl daemon-reload
+ systemctl enable odroid-lcd35
- #XORG
- rm /etc/X11/xorg.conf.d/exynos.conf #XU4
+ #XORG
+ [[ -f /etc/X11/xorg.conf.d/exynos.conf ]] && rm /etc/X11/xorg.conf.d/exynos.conf #XU4
- mkdir -p /etc/X11/xorg.conf.d
- cat << _EOF_ > /etc/X11/xorg.conf.d/99-odroid-lcd35.conf
+ mkdir -p /etc/X11/xorg.conf.d
+ cat << _EOF_ > /etc/X11/xorg.conf.d/99-odroid-lcd35.conf
Section "Device"
Identifier "C fbdev"
Driver "fbdev"
@@ -902,8 +983,8 @@ Section "Device"
EndSection
_EOF_
- # - default calibration
- cat << _EOF_ > /etc/X11/xorg.conf.d/99-calibration.conf
+ # - default calibration
+ cat << _EOF_ > /etc/X11/xorg.conf.d/99-calibration.conf
Section "InputClass"
Identifier "calibration"
MatchProduct "SX865X Touchscreen"
@@ -912,21 +993,14 @@ Section "InputClass"
EndSection
_EOF_
- else
-
- Lcd_Panel_Not_Available_For_Device
-
- fi
-
-
}
Lcd_Panel_OdroidLCD35_Disable(){
- rm /etc/X11/xorg.conf.d/99-calibration.conf
- rm /etc/modprobe.d/odroid-lcd35.conf
- rm /etc/systemd/system/odroid-lcd35.service
- rm /etc/X11/xorg.conf.d/99-odroid-lcd35.conf
+ [[ -f /etc/X11/xorg.conf.d/99-calibration.conf ]] && rm /etc/X11/xorg.conf.d/99-calibration.conf
+ [[ -f /etc/modprobe.d/odroid-lcd35.conf ]] && rm /etc/modprobe.d/odroid-lcd35.conf
+ [[ -f /etc/systemd/system/odroid-lcd35.service ]] && rm /etc/systemd/system/odroid-lcd35.service
+ [[ -f /etc/X11/xorg.conf.d/99-odroid-lcd35.conf ]] && rm /etc/X11/xorg.conf.d/99-odroid-lcd35.conf
systemctl daemon-reload
}
@@ -934,26 +1008,19 @@ _EOF_
#/////////////////////////////////////////////////////////////////////////////////////
# i2c
#/////////////////////////////////////////////////////////////////////////////////////
- # Currently only for RPi.
I2c_Main(){
+ (( $G_HW_MODEL > 9 )) && { Unsupported_Input_Name; return 1; } # Exit path for non-RPi
+
if [[ $INPUT_DEVICE_VALUE == 'enable' ]]; then
#Check/install pre-reqs
G_AG_CHECK_INSTALL_PREREQ python-smbus i2c-tools
#Kernel modules
- # - Remove all previous line references (includes commented ones)
- sed -i '/i2c-bcm2708/d' /etc/modules &> /dev/null
- sed -i '/i2c-dev/d' /etc/modules &> /dev/null
- # - Add modules
G_CONFIG_INJECT 'i2c-bcm2708' 'i2c-bcm2708' /etc/modules
G_CONFIG_INJECT 'i2c-dev' 'i2c-dev' /etc/modules
- #Remove from blacklist (Wheezy only. Jessie doesnt exist)
- sed -i '/blacklist spi-bcm2708/d' /etc/modprobe.d/raspi-blacklist.conf &> /dev/null
- sed -i '/blacklist i2c-bcm2708/d' /etc/modprobe.d/raspi-blacklist.conf &> /dev/null
-
#config.txt
G_CONFIG_INJECT 'dtparam=i2c_arm=' 'dtparam=i2c_arm=on' $FP_RPI_CONFIG
G_CONFIG_INJECT 'dtparam=i2c1=' 'dtparam=i2c1=on' $FP_RPI_CONFIG
@@ -963,19 +1030,19 @@ _EOF_
elif [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then
- sed -i '/i2c-bcm2708/d' /etc/modules &> /dev/null
- sed -i '/i2c-dev/d' /etc/modules &> /dev/null
+ sed -i '/^[[:blank:]]*i2c-bcm2708/d' /etc/modules
+ sed -i '/^[[:blank:]]*i2c-dev/d' /etc/modules
G_CONFIG_INJECT 'dtparam=i2c_arm=' 'dtparam=i2c_arm=off' $FP_RPI_CONFIG
G_CONFIG_INJECT 'dtparam=i2c1=' 'dtparam=i2c1=off' $FP_RPI_CONFIG
G_CONFIG_INJECT 'i2c_arm_baudrate=' 'i2c_arm_baudrate=100000' $FP_RPI_CONFIG
#Set baudrate (khz) | valid int
- elif disable_error=1 G_CHECK_VALIDINT $INPUT_DEVICE_VALUE 2 10000000; then
+ elif disable_error=1 G_CHECK_VALIDINT "$INPUT_DEVICE_VALUE" 2 10000000; then
G_CONFIG_INJECT 'i2c_arm_baudrate=' "i2c_arm_baudrate=$(( $INPUT_DEVICE_VALUE * 1000 ))" $FP_RPI_CONFIG
#inform user
- INPUT_DEVICE_VALUE+="Khz"
+ INPUT_DEVICE_VALUE+='Khz'
else
@@ -1003,7 +1070,7 @@ _EOF_
aBLUETOOTH_MODULES+=('hci_uart')
- rm /etc/modprobe.d/disable_bt.conf &> /dev/null
+ [[ -f /etc/modprobe.d/disable_bt.conf ]] && rm /etc/modprobe.d/disable_bt.conf
# - Disable
if [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then
@@ -1014,14 +1081,12 @@ _EOF_
systemctl stop brcm_patchram_plus 2> /dev/null
systemctl disable brcm_patchram_plus 2> /dev/null
- fi
-
# + RPi 3 (apply to all, as pi-bluetooth package is default installed on all RPi's now)
# + Asus TB
- if (( $G_HW_MODEL < 10 || $G_HW_MODEL == 52 )); then
+ elif (( $G_HW_MODEL < 10 || $G_HW_MODEL == 52 )); then
- systemctl stop hciuart
- systemctl disable hciuart
+ systemctl stop hciuart 2> /dev/null
+ systemctl disable hciuart 2> /dev/null
fi
@@ -1033,14 +1098,14 @@ _EOF_
do
modprobe -rf "${aBLUETOOTH_MODULES[$i]}" 2> /dev/null
- echo -e "blacklist ${aBLUETOOTH_MODULES[$i]}" >> /etc/modprobe.d/disable_bt.conf
+ echo "blacklist ${aBLUETOOTH_MODULES[$i]}" >> /etc/modprobe.d/disable_bt.conf
done
#Purge packages
if (( $G_DIETPI_INSTALL_STAGE >= 0 )); then
- G_AGP bluetooth bluez-firmware
+ G_AGP bluetooth bluez-firmware pi-bluetooth
G_AGA
fi
@@ -1050,11 +1115,7 @@ _EOF_
#Pre-Reqs
G_AG_CHECK_INSTALL_PREREQ bluetooth bluez-firmware
- if (( $G_HW_MODEL < 10 )); then
-
- G_AG_CHECK_INSTALL_PREREQ pi-bluetooth
-
- fi
+ (( $G_HW_MODEL < 10 )) && G_AG_CHECK_INSTALL_PREREQ pi-bluetooth
#bluetooth first
for ((i=0; i<${#aBLUETOOTH_MODULES[@]}; i++))
@@ -1225,11 +1286,7 @@ _EOF_
elif (( $G_HW_MODEL == 35 || $G_HW_MODEL == 64 )); then
#4.9 uses brcm, only enable dhd for 3.x
- if [[ ! -d '/boot/dtb' ]]; then
-
- aWIFI_MODULES+=('dhd')
-
- fi
+ [[ ! -d '/boot/dtb' ]] && aWIFI_MODULES+=('dhd')
fi
@@ -1239,14 +1296,14 @@ _EOF_
# - Disable
if [[ $INPUT_DEVICE_VALUE == 'disable' ]]; then
- rm /etc/modprobe.d/disable_wifi.conf &> /dev/null
+ [[ -f /etc/modprobe.d/disable_wifi.conf ]] && rm /etc/modprobe.d/disable_wifi.conf
#cfg80211 last
for ((i=$(( ${#aWIFI_MODULES[@]} - 1 )); i>=0; i--))
do
modprobe -rf "${aWIFI_MODULES[$i]}" 2> /dev/null
- echo -e "blacklist ${aWIFI_MODULES[$i]}" >> /etc/modprobe.d/disable_wifi.conf
+ echo "blacklist ${aWIFI_MODULES[$i]}" >> /etc/modprobe.d/disable_wifi.conf
done
@@ -1256,14 +1313,9 @@ _EOF_
# - Install prereqs
local pre_req_packages='crda iw rfkill wireless-tools wpasupplicant'
- G_AG_CHECK_INSTALL_PREREQ $pre_req_packages
- if (( $? != 0 )); then
-
- exit 1
+ G_AG_CHECK_INSTALL_PREREQ $pre_req_packages || exit 1
- fi
-
- rm /etc/modprobe.d/disable_wifi.conf &> /dev/null
+ [[ -f /etc/modprobe.d/disable_wifi.conf ]] && rm /etc/modprobe.d/disable_wifi.conf
# - Disable known powersaving options for specific chipsets
echo 'options 8192cu rtw_power_mgnt=0' > /etc/modprobe.d/8192cu.conf
@@ -1293,19 +1345,23 @@ _EOF_
elif [[ $INPUT_DEVICE_VALUE == 'onboard_enable' ]]; then
+ (( $HW_ONBOARD_WIFI )) ||
+
#NB: Requires reboot
#NB: Do not change filenames, -f check used by DietPi-Config to obtain state
- rm /etc/modprobe.d/disable_wifi_rpi3_onboard.conf &> /dev/null
+ [[ -f /etc/modprobe.d/disable_wifi_rpi3_onboard.conf ]] && rm /etc/modprobe.d/disable_wifi_rpi3_onboard.conf
elif [[ $INPUT_DEVICE_VALUE == 'onboard_disable' ]]; then
+ (( $HW_ONBOARD_WIFI )) ||
+
#NB: Requires reboot
#NB: Do not change filenames, -f check used by DietPi-Config to obtain state
# - RPi 3/ZeroW
- echo -e "blacklist brcmfmac" > /etc/modprobe.d/disable_wifi_rpi3_onboard.conf
- echo -e "blacklist brcmutil" >> /etc/modprobe.d/disable_wifi_rpi3_onboard.conf
+ echo 'blacklist brcmfmac' > /etc/modprobe.d/disable_wifi_rpi3_onboard.conf
+ echo 'blacklist brcmutil' >> /etc/modprobe.d/disable_wifi_rpi3_onboard.conf
else
@@ -1356,27 +1412,27 @@ _EOF_
#systemctl enable serial-getty@ttyAMA[0-9].service # Number wildcards do not work, we need to specify each possible tty device number
G_DIETPI-NOTIFY 2 'Enabling known serial-getty services, please wait...'
- systemctl unmask serial-getty@tty.service 2> /dev/null
- systemctl enable serial-getty@tty.service 2> /dev/null
+ systemctl unmask serial-getty@tty 2> /dev/null
+ systemctl enable serial-getty@tty 2> /dev/null
for ((i=0; i<=$MAX_SERIAL_CONSOLES; i++))
do
# - unmask v6.3+
- systemctl unmask serial-getty@ttyAMA$i.service 2> /dev/null
- systemctl unmask serial-getty@ttySAC$i.service 2> /dev/null
- systemctl unmask serial-getty@ttyS$i.service 2> /dev/null
- #systemctl unmask serial-getty@ttyFIQ$i.service 2> /dev/null #:https://github.com/Fourdee/DietPi/issues/1829#issuecomment-398302497
+ systemctl unmask serial-getty@ttyAMA$i 2> /dev/null
+ systemctl unmask serial-getty@ttySAC$i 2> /dev/null
+ systemctl unmask serial-getty@ttyS$i 2> /dev/null
+ #systemctl unmask serial-getty@ttyFIQ$i 2> /dev/null #:https://github.com/Fourdee/DietPi/issues/1829#issuecomment-398302497
# - Enable v6.2-
- systemctl enable serial-getty@ttyAMA$i.service 2> /dev/null
- systemctl enable serial-getty@ttySAC$i.service 2> /dev/null
- systemctl enable serial-getty@ttyS$i.service 2> /dev/null
- #systemctl enable serial-getty@ttyFIQ$i.service 2> /dev/null #:https://github.com/Fourdee/DietPi/issues/1829#issuecomment-398302497
+ systemctl enable serial-getty@ttyAMA$i 2> /dev/null
+ systemctl enable serial-getty@ttySAC$i 2> /dev/null
+ systemctl enable serial-getty@ttyS$i 2> /dev/null
+ #systemctl enable serial-getty@ttyFIQ$i 2> /dev/null #:https://github.com/Fourdee/DietPi/issues/1829#issuecomment-398302497
# - Allow root login for known TTY's not in /etc/securetty by default
# NanoPC-T4
- G_CONFIG_INJECT "^ttyFIQ$i" "ttyFIQ$i" /etc/securetty
+ G_CONFIG_INJECT "ttyFIQ$i" "ttyFIQ$i" /etc/securetty
done
@@ -1426,21 +1482,21 @@ _EOF_
#Disable services. Although, this seems to have no effect on the cmdline.txt boot.ini etc serial console entries. They run regardless. But lets do it for consistency.
G_DIETPI-NOTIFY 2 'Disabling known serial-getty services, please wait...'
- systemctl disable serial-getty@tty.service 2> /dev/null
- systemctl mask serial-getty@tty.service 2> /dev/null
+ systemctl disable serial-getty@tty 2> /dev/null
+ systemctl mask serial-getty@tty 2> /dev/null
for ((i=0; i<=$MAX_SERIAL_CONSOLES; i++))
do
# Disable first, to remove symlink from /etc/systemd/system/getty.target.wants/
- systemctl disable serial-getty@ttyAMA$i.service 2> /dev/null
- systemctl disable serial-getty@ttySAC$i.service 2> /dev/null
- systemctl disable serial-getty@ttyS$i.service 2> /dev/null
- #systemctl disable serial-getty@ttyFIQ$i.service 2> /dev/null #:https://github.com/Fourdee/DietPi/issues/1829#issuecomment-398302497
+ systemctl disable serial-getty@ttyAMA$i 2> /dev/null
+ systemctl disable serial-getty@ttySAC$i 2> /dev/null
+ systemctl disable serial-getty@ttyS$i 2> /dev/null
+ #systemctl disable serial-getty@ttyFIQ$i 2> /dev/null #:https://github.com/Fourdee/DietPi/issues/1829#issuecomment-398302497
- systemctl mask serial-getty@ttyAMA$i.service 2> /dev/null
- systemctl mask serial-getty@ttySAC$i.service 2> /dev/null
- systemctl mask serial-getty@ttyS$i.service 2> /dev/null
- #systemctl mask serial-getty@ttyFIQ$i.service 2> /dev/null #:https://github.com/Fourdee/DietPi/issues/1829#issuecomment-398302497
+ systemctl mask serial-getty@ttyAMA$i 2> /dev/null
+ systemctl mask serial-getty@ttySAC$i 2> /dev/null
+ systemctl mask serial-getty@ttyS$i 2> /dev/null
+ #systemctl mask serial-getty@ttyFIQ$i 2> /dev/null #:https://github.com/Fourdee/DietPi/issues/1829#issuecomment-398302497
done
@@ -1496,7 +1552,7 @@ _EOF_
ALSA_EQ_ENABLED=0
#Remove previous asound.conf
- rm /etc/asound.conf &> /dev/null
+ [[ -f /etc/asound.conf ]] && rm /etc/asound.conf
# - Pre-Reqs for any soundcard
G_AG_CHECK_INSTALL_PREREQ alsa-utils
@@ -1560,29 +1616,27 @@ _EOF_
G_CONFIG_INJECT 'dtparam=audio=' 'dtparam=audio=off' $FP_RPI_CONFIG
# - Remove known soundcard dtoverlays
- sed -i '/dtoverlay=rpi-bcm2835/d' $FP_RPI_CONFIG
- sed -i '/dtoverlay=hifiberry/d' $FP_RPI_CONFIG
- sed -i '/dtoverlay=iqaudio/d' $FP_RPI_CONFIG
- sed -i '/dtoverlay=justboom/d' $FP_RPI_CONFIG
- sed -i '/dtoverlay=allo-/d' $FP_RPI_CONFIG
- sed -i '/dtoverlay=rpi-dac/d' $FP_RPI_CONFIG
- sed -i '/dtoverlay=i-sabre-k2m/d' $FP_RPI_CONFIG
- sed -i '/dtoverlay=dionaudio/d' $FP_RPI_CONFIG
- sed -i '/dtoverlay=googlevoicehat-soundcard/d' $FP_RPI_CONFIG
- sed -i '/dtoverlay=applepi/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=rpi-bcm2835/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=hifiberry/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=iqaudio/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=justboom/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=allo-/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=rpi-dac/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=i-sabre-k2m/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=dionaudio/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=googlevoicehat-soundcard/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=applepi/d' $FP_RPI_CONFIG
# - Remove i2s maps
- sed -i '/dtoverlay=i2s-mmap/d' $FP_RPI_CONFIG
- sed -i '/dtparam=i2s=/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtoverlay=i2s-mmap/d' $FP_RPI_CONFIG
+ sed -i '/^[[:blank:]]*dtparam=i2s=/d' $FP_RPI_CONFIG
# onboard blacklist module
echo 'blacklist snd-bcm2835' > /etc/modprobe.d/rpi-bcm2708.conf
- G_CONFIG_INJECT 'avoid_pwm_pll=' 'avoid_pwm_pll=1' $FP_RPI_CONFIG
-
# - Disable forced analogue out
- systemctl disable rpi-bcm2835_forced_3.5mm.service &> /dev/null
- rm /etc/systemd/system/rpi-bcm2835_forced_3.5mm.service &> /dev/null
+ systemctl disable rpi-bcm2835_forced_3.5mm &> /dev/null
+ [[ -f /etc/systemd/system/rpi-bcm2835_forced_3.5mm.service ]] && rm /etc/systemd/system/rpi-bcm2835_forced_3.5mm.service
systemctl daemon-reload
# Return Auto
amixer -c 0 cset numid=3 0 &> /dev/null
@@ -1591,16 +1645,16 @@ _EOF_
Soundcard_Reset_Odroid(){
- rm /var/lib/dietpi/postboot.d/c2_smp.sh &> /dev/null
+ [[ -f /var/lib/dietpi/postboot.d/c2_smp.sh ]] && rm /var/lib/dietpi/postboot.d/c2_smp.sh
# - hifi shield plus
- sed -i '/snd-soc-pcm5102/d' /etc/modules
- sed -i '/snd-soc-odroid-dac/d' /etc/modules
+ sed -i '/^[[:blank:]]*snd-soc-pcm5102/d' /etc/modules
+ sed -i '/^[[:blank:]]*snd-soc-odroid-dac/d' /etc/modules
# - hifi shield 2
- sed -i '/snd-soc-pcm512x/d' /etc/modules
- sed -i '/snd-soc-pcm512x-i2c/d' /etc/modules
- sed -i '/snd-soc-odroid-dac2/d' /etc/modules
+ sed -i '/^[[:blank:]]*snd-soc-pcm512x/d' /etc/modules
+ sed -i '/^[[:blank:]]*snd-soc-pcm512x-i2c/d' /etc/modules
+ sed -i '/^[[:blank:]]*snd-soc-odroid-dac2/d' /etc/modules
if [[ -f '/etc/systemd/system/odroid-hifishield2.service' ]]; then
@@ -1636,7 +1690,7 @@ _EOF_
Soundcard_Reset_SparkySBC(){
- sed -i '/snd-soc-allo-piano-dac/d' /etc/modules
+ sed -i '/^[[:blank:]]*snd-soc-allo-piano-dac/d' /etc/modules
# - HDMI
SOUNDCARD_TARGET_DEVICE=1
@@ -1646,13 +1700,13 @@ _EOF_
sed -i 's/aotg.aotg1_speed=1/aotg.aotg1_speed=0/' /DietPi/uEnv.txt
# - auto unmute
- rm /var/lib/dietpi/postboot.d/sparky_unmute.sh &> /dev/null
+ [[ -f /var/lib/dietpi/postboot.d/sparky_unmute.sh ]] && rm /var/lib/dietpi/postboot.d/sparky_unmute.sh
}
Soundcard_Reset_PineA64(){
- rm /etc/modules-load.d/pine64-audiojack.conf
+ [[ -f /etc/modules-load.d/pine64-audiojack.conf ]] && rm /etc/modules-load.d/pine64-audiojack.conf
SOUNDCARD_TARGET_CARD=1
}
@@ -1691,15 +1745,10 @@ _EOF_
fi
# - Update DietPi global soundcard var
- sed -i "/^CONFIG_SOUNDCARD=/c\CONFIG_SOUNDCARD=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt
+ G_CONFIG_INJECT 'CONFIG_SOUNDCARD=' "CONFIG_SOUNDCARD=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt
# - RPi: Enable DTPARAM audio setting
- if (( $G_HW_MODEL < 10 )); then
-
- # - Enable dtparam audio
- G_CONFIG_INJECT 'dtparam=audio=' 'dtparam=audio=on' $FP_RPI_CONFIG
-
- fi
+ (( $G_HW_MODEL < 10 )) && G_CONFIG_INJECT 'dtparam=audio=' 'dtparam=audio=on' $FP_RPI_CONFIG
#Cards
case "$INPUT_DEVICE_VALUE" in
@@ -1709,18 +1758,18 @@ _EOF_
#Specify card + device indexs
hw:*)
- echo -e "$INPUT_DEVICE_VALUE"
- local split=$(echo -e "$INPUT_DEVICE_VALUE" | sed 's/,/ /g' | sed 's/hw://g' | sed 's/-eq//g')
- SOUNDCARD_TARGET_CARD=$(echo -e "$split" | awk '{print $1}' )
- SOUNDCARD_TARGET_DEVICE=$(echo -e "$split" | awk '{print $2}' )
+ echo "$INPUT_DEVICE_VALUE"
+ local split=$(sed 's/,/ /g' <<< "$INPUT_DEVICE_VALUE" | sed -E 's/(hw:|-eq)//g')
+ SOUNDCARD_TARGET_CARD=$(mawk '{print $1}' <<< "$split")
+ SOUNDCARD_TARGET_DEVICE=$(mawk '{print $2}' <<< "$split")
;;
usb-dac*)
# - detect card
- local usb_detection_card_index=$(aplay -l | grep -m1 'USB Audio' | awk '{print $2}' | sed 's/://g')
- if disable_error=1 G_CHECK_VALIDINT $usb_detection_card_index; then
+ local usb_detection_card_index=$(aplay -l | mawk '/USB Audio/ {print $2;exit}' | sed 's/://g')
+ if disable_error=1 G_CHECK_VALIDINT "$usb_detection_card_index"; then
SOUNDCARD_TARGET_CARD=$usb_detection_card_index
@@ -1759,7 +1808,7 @@ _EOF_
# - Not found
else
- G_DIETPI-NOTIFY 1 "Unable to find a USB-DAC on system."
+ G_DIETPI-NOTIFY 1 'Unable to find a USB-DAC on system.'
EXIT_CODE=1
# - Reset
@@ -1779,17 +1828,7 @@ _EOF_
rpi-bcm2835*)
# - remove from blacklist to enable:
- rm /etc/modprobe.d/rpi-bcm2708.conf
-
- # - Enable HQ audio
- G_CONFIG_INJECT 'avoid_pwm_pll=' 'avoid_pwm_pll=0' $FP_RPI_CONFIG
-
- # - Expermental UltraHQ audio: https://www.raspberrypi.org/forums/viewtopic.php?p=907075#p907075
- if [[ $INPUT_DEVICE_VALUE == *'ultrahq'* ]]; then
-
- sed -i '/avoid_pwm_pll=/c\avoid_pwm_pll=2' $FP_RPI_CONFIG
-
- fi
+ [[ -f /etc/modprobe.d/rpi-bcm2708.conf ]] && rm /etc/modprobe.d/rpi-bcm2708.conf
# - Force 3.5mm out?
if [[ $INPUT_DEVICE_VALUE == *'3.5mm'* ]]; then
@@ -1810,8 +1849,8 @@ ExecStart=/usr/bin/amixer -c 0 cset numid=3 1
WantedBy=multi-user.target
_EOF_
systemctl daemon-reload
- systemctl enable rpi-bcm2835_forced_3.5mm.service
- systemctl start rpi-bcm2835_forced_3.5mm.service
+ systemctl enable rpi-bcm2835_forced_3.5mm
+ systemctl start rpi-bcm2835_forced_3.5mm
fi
@@ -1826,7 +1865,7 @@ _EOF_
hifiberry-*)
# - enable dtoverlay
- echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> $FP_RPI_CONFIG
+ G_CONFIG_INJECT "dtoverlay=$INPUT_DEVICE_VALUE" "dtoverlay=$INPUT_DEVICE_VALUE" $FP_RPI_CONFIG
;;
@@ -1849,7 +1888,7 @@ _EOF_
justboom-*)
# - enable dtoverlay
- echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> $FP_RPI_CONFIG
+ G_CONFIG_INJECT "dtoverlay=$INPUT_DEVICE_VALUE" "dtoverlay=$INPUT_DEVICE_VALUE" $FP_RPI_CONFIG
;;
@@ -1865,12 +1904,12 @@ _EOF_
wget "$INSTALL_URL_ADDRESS" -O package.zip
unzip -o package.zip
rm package.zip
- cp -R piano-firmware-master/lib/firmware/allo /lib/firmware/
+ mv piano-firmware-master/lib/firmware/allo /lib/firmware/
rm -R piano-firmware-master
fi
- echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> $FP_RPI_CONFIG
+ G_CONFIG_INJECT "dtoverlay=$INPUT_DEVICE_VALUE" "dtoverlay=$INPUT_DEVICE_VALUE" $FP_RPI_CONFIG
;;
@@ -1890,7 +1929,7 @@ _EOF_
fi
- echo -e "$INPUT_DEVICE_VALUE" >> /etc/modules
+ G_CONFIG_INJECT "$INPUT_DEVICE_VALUE" "$INPUT_DEVICE_VALUE" /etc/modules
SOUNDCARD_TARGET_CARD=1
SOUNDCARD_TARGET_DEVICE=0
amixer -c 0 sset 'audio output mode switch' 'i2s'
@@ -1928,11 +1967,14 @@ _EOF_
allo-*)
# - enable dtoverlay
- echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> $FP_RPI_CONFIG
+ G_CONFIG_INJECT "dtoverlay=$INPUT_DEVICE_VALUE" "dtoverlay=$INPUT_DEVICE_VALUE" $FP_RPI_CONFIG
if [[ $INPUT_DEVICE_VALUE == 'allo-katana-dac-audio' && ! -d '/var/www/allo' ]]; then
- G_RPI_UPDATE
+ local rpi-firmware='raspberrypi-bootloader raspberrypi-kernel libraspberrypi-bin libraspberrypi0'
+ G_AGUP
+ G_AGI $rpi_firmware
+ apt-mark unhold $rpi_firmware
fi
@@ -1943,7 +1985,7 @@ _EOF_
rpi-dac)
# - enable dtoverlay
- echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> $FP_RPI_CONFIG
+ G_CONFIG_INJECT "dtoverlay=$INPUT_DEVICE_VALUE" "dtoverlay=$INPUT_DEVICE_VALUE" $FP_RPI_CONFIG
;;
@@ -1951,43 +1993,51 @@ _EOF_
# i-sabre-k2m
i-sabre-k2m)
- # - Sourcebuild
- if [[ ! -f '/var/lib/dietpi/.G_RPI_UPDATE' ]]; then
+ # Check existing and compatible dtoverlay via dtoverlay command
+ if ! dtoverlay $INPUT_DEVICE_VALUE &> /dev/null; then
- G_RPI_UPDATE
- G_CONFIG_INJECT 'CONFIG_SOUNDCARD=' 'CONFIG_SOUNDCARD=none' /DietPi/dietpi.txt
- G_WHIP_MSG "Stage 1 completed (ni-sabre-k2m_build):\n\nThe device will now reboot.\n\nOnce rebooted, please run dietpi-config > Audio Options again. Reselect the soundcard (i-sabre-k2m) to complete installation."
- reboot
+ # - Source build, update kernel packages and install headers
+ local old_firmware=$(ls /lib/modules/)
+ local rpi_firmware='raspberrypi-bootloader raspberrypi-kernel libraspberrypi-bin libraspberrypi0'
+ G_AGUP
+ G_AGI $rpi_firmware raspberrypi-kernel-headers make
+ apt-mark unhold $rpi_firmware # Should be not required, since we did that on v6.20 patch, but better be failsafe
- fi
+ if [[ $old_firmware != $(ls /lib/modules/) ]]; then
- local install_url_address='https://raw.githubusercontent.com/notro/rpi-source/master/rpi-source'
- G_CHECK_URL "$install_url_address"
- G_AG_CHECK_INSTALL_PREREQ python build-essential git device-tree-compiler gcc-4.9 g++-4.9
+ G_CONFIG_INJECT 'CONFIG_SOUNDCARD=' 'CONFIG_SOUNDCARD=none' /DietPi/dietpi.txt
+ G_WHIP_MSG '[ OK ] Stage 1 completed: Kernel upgraded\n\nThe device will now reboot.\n
+Once rebooted, please rerun dietpi-config > Audio Options. Re-select the sound card (i-sabre-k2m) to complete installation.'
+ reboot
- mkdir -p $HOME/i-sabre-k2m_build
- cd $HOME/i-sabre-k2m_build
- wget "$install_url_address" -O /usr/bin/rpi-source
- chmod +x /usr/bin/rpi-source
- /usr/bin/rpi-source -q --tag-update
- rpi-source -d . --skip-gcc
+ fi
- install_url_address='https://dietpi.com/downloads/sourcebuild/I-Sabre-K2M.7z'
- G_CHECK_URL "$install_url_address"
- wget "$install_url_address" -O package.7z
- 7z x -y package.7z
- rm package.7z
+ # - Build dtoverlay
+ mkdir -p i-sabre-k2m_build
+ cd i-sabre-k2m_build
+ install_url_address='https://dietpi.com/downloads/sourcebuild/I-Sabre-K2M.7z'
+ G_CHECK_URL "$install_url_address"
+ wget "$install_url_address" -O package.7z
+ 7z x -y package.7z
+ rm package.7z
- G_RUN_CMD make
- G_RUN_CMD make modules_install
- G_RUN_CMD make dtbs
- G_RUN_CMD make install_dtbo
+ G_RUN_CMD make
+ G_RUN_CMD make modules_install
+ G_RUN_CMD make dtbs
+ G_RUN_CMD make install_dtbo
- cd $HOME
- rm -R i-sabre-k2m_build
+ cd /tmp/$G_PROGRAM_NAME
+ rm -R i-sabre-k2m_build
- # - enable dtoverlay
- echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> $FP_RPI_CONFIG
+ # - Enable dtoverlay
+ dtoverlay $INPUT_DEVICE_VALUE
+
+ fi
+
+ G_CONFIG_INJECT "dtoverlay=$INPUT_DEVICE_VALUE" "dtoverlay=$INPUT_DEVICE_VALUE" $FP_RPI_CONFIG
+
+ G_WHIP_MSG '[ OK ] i-sabre-k2m module successfully installed\n
+NB: The module must be rebuilt each time the kernel is upgraded. For this, simply re-select the sound card via dietpi-config > Audio Options.'
;;
@@ -1996,14 +2046,14 @@ _EOF_
applepi*)
# - enable dtoverlay
- echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> $FP_RPI_CONFIG
+ G_CONFIG_INJECT "dtoverlay=$INPUT_DEVICE_VALUE" "dtoverlay=$INPUT_DEVICE_VALUE" $FP_RPI_CONFIG
;;
iqaudio-*)
# - enable dtoverlay
- echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> $FP_RPI_CONFIG
+ G_CONFIG_INJECT "dtoverlay=$INPUT_DEVICE_VALUE" "dtoverlay=$INPUT_DEVICE_VALUE" $FP_RPI_CONFIG
;;
@@ -2012,7 +2062,7 @@ _EOF_
dionaudio-loco*)
# - enable dtoverlay
- echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> $FP_RPI_CONFIG
+ G_CONFIG_INJECT "dtoverlay=$INPUT_DEVICE_VALUE" "dtoverlay=$INPUT_DEVICE_VALUE" $FP_RPI_CONFIG
;;
@@ -2045,15 +2095,15 @@ Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/bash -c 'echo pcm5242 0x4c > /sys/class/i2c-adapter/i2c-1/new_device'
-ExecStart=/bin/bash -c 'amixer -c 1 sset Analogue 0'
-ExecStart=/bin/bash -c 'amixer -c 1 sset Digital 201'
-ExecStart=/bin/bash -c 'amixer -c 1 sset Deemphasis on'
+ExecStart=$(command -v amixer) -c 1 sset Analogue 0
+ExecStart=$(command -v amixer) -c 1 sset Digital 201
+ExecStart=$(command -v amixer) -c 1 sset Deemphasis on
[Install]
WantedBy=sound.target
_EOF_
systemctl daemon-reload
- systemctl enable odroid-hifishield2.service
+ systemctl enable odroid-hifishield2
;;
@@ -2260,6 +2310,10 @@ _EOF_
RPi_USB_Boot_Main
+ elif [[ $INPUT_DEVICE_NAME == 'headless' ]]; then
+
+ Headless_Main
+
else
Unknown_Input_Name
diff --git a/dietpi/func/dietpi-set_software b/dietpi/func/dietpi-set_software
index 24fa8e9897..e1919c7ea8 100644
--- a/dietpi/func/dietpi-set_software
+++ b/dietpi/func/dietpi-set_software
@@ -27,20 +27,20 @@ $FP_SCRIPT setpermissions Applies required filesystem permissions to DietPi
#////////////////////////////////////
#Grab inputs
- INPUT_MODE_NAME="$1"
- INPUT_MODE_VALUE="$2"
+ INPUT_MODE_NAME=$1
+ INPUT_MODE_VALUE=$2
- INPUT_ADDITIONAL_1="$3"
- INPUT_ADDITIONAL_2="$4"
- INPUT_ADDITIONAL_3="$5"
- INPUT_ADDITIONAL_4="$6"
+ INPUT_ADDITIONAL_1=$3
+ INPUT_ADDITIONAL_2=$4
+ INPUT_ADDITIONAL_3=$5
+ INPUT_ADDITIONAL_4=$6
#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
G_PROGRAM_NAME='DietPi-Set_software'
- G_INIT
G_CHECK_ROOT_USER
G_CHECK_ROOTFS_RW
+ G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
EXIT_CODE=0
@@ -69,20 +69,17 @@ $FP_SCRIPT setpermissions Applies required filesystem permissions to DietPi
if [[ $INPUT_MODE_VALUE =~ 'UTF-8' ]]; then
- cat << _EOF_ > /etc/locale.gen
-$INPUT_MODE_VALUE UTF-8
-_EOF_
+ echo "$INPUT_MODE_VALUE UTF-8" > /etc/locale.gen
# - Add en_GB.UTF-8 back in, if its not the default
if [[ $INPUT_MODE_VALUE != 'en_GB.UTF-8' ]]; then
- cat << _EOF_ >> /etc/locale.gen
-en_GB.UTF-8 UTF-8
-_EOF_
+ echo 'en_GB.UTF-8 UTF-8' >> /etc/locale.gen
+
fi
# - Remove exisiting settings that will break dpkg-reconfigure
- rm /etc/default/locale &> /dev/null
+ [[ -f /etc/default/locale ]] && rm /etc/default/locale
G_RUN_CMD dpkg-reconfigure -f noninteractive locales
@@ -91,10 +88,10 @@ _EOF_
export LC_ALL=en_GB.UTF8
# - Update /etc/default/locales with new values (not effective until next load of bash session, eg: logout/in)
- update-locale LANG="$INPUT_MODE_VALUE"
- update-locale LC_CTYPE="$INPUT_MODE_VALUE"
- update-locale LC_TIME="$INPUT_MODE_VALUE"
- update-locale LC_ALL="$INPUT_MODE_VALUE"
+ update-locale "LANG=$INPUT_MODE_VALUE"
+ update-locale "LC_CTYPE=$INPUT_MODE_VALUE"
+ update-locale "LC_TIME=$INPUT_MODE_VALUE"
+ update-locale "LC_ALL=$INPUT_MODE_VALUE"
G_CONFIG_INJECT 'AUTO_SETUP_LOCALE=' "AUTO_SETUP_LOCALE=$INPUT_MODE_VALUE" /DietPi/dietpi.txt
@@ -131,13 +128,10 @@ _EOF_
# - Set raspbian
if (( $G_HW_MODEL < 10 )); then
- cat << _EOF_ > /etc/apt/sources.list
-deb $INPUT_MODE_VALUE $G_DISTRO_NAME main contrib non-free rpi
-_EOF_
+ echo "deb $INPUT_MODE_VALUE $G_DISTRO_NAME main contrib non-free rpi" > /etc/apt/sources.list
+
+ echo "deb https://archive.raspberrypi.org/debian/ $G_DISTRO_NAME main ui" > /etc/apt/sources.list.d/raspi.list
- cat << _EOF_ > /etc/apt/sources.list.d/raspi.list
-deb https://archive.raspberrypi.org/debian/ $G_DISTRO_NAME main ui
-_EOF_
# Highest available raspi.list distro is currently Stretch, working good enough for testing purposes with Raspbian Buster:
(( $G_DISTRO > 4 )) && sed -i "s/$G_DISTRO_NAME/stretch/" /etc/apt/sources.list.d/raspi.list
@@ -160,11 +154,7 @@ _EOF_
sed -i 's/https:/http:/g' /etc/apt/sources.list
# - ARM64 packages no longer available: https://github.com/Fourdee/DietPi/issues/1915
- if (( $G_HW_ARCH == 3 )); then
-
- sed -i '/debian-security/d' /etc/apt/sources.list
-
- fi
+ (( $G_HW_ARCH == 3 )) && sed -i '/debian-security/d' /etc/apt/sources.list
# Buster, remove backports: https://github.com/Fourdee/DietPi/issues/1285#issuecomment-351830101
elif (( $G_DISTRO > 4 )); then
@@ -192,7 +182,7 @@ _EOF_
#/////////////////////////////////////////////////////////////////////////////////////
NtpdMode_Main(){
- if G_CHECK_VALIDINT $INPUT_MODE_VALUE 0 4; then
+ if G_CHECK_VALIDINT "$INPUT_MODE_VALUE" 0 4; then
# - Reset global to disabled, prevents run_ntpd in dietpi-software
sed -i '/CONFIG_NTP_MODE=/c\CONFIG_NTP_MODE=0' /DietPi/dietpi.txt
@@ -211,11 +201,12 @@ _EOF_
# - Gateway, auto detect local gateway(s) (router) to use as NTP server.
elif [[ ${ntp_mirror,,} == gateway ]]; then
- local gateway="$(ip r | grep '^default' | awk '{print $3}')"
+ # NB: Turn output output into single line string via echo
+ local gateway=$(echo $(ip r | mawk '/^default/ {print $3}'))
if [[ $gateway ]]; then
- G_DIETPI-NOTIFY 0 "Gateway(s) detected:$(printf ' %s' $gateway), adding as NTP server(s)."
- ntp_mirror_entry='Servers='$(ip r | grep '^default' | awk '{print $3}')
+ G_DIETPI-NOTIFY 0 "Gateway(s) detected: $gateway, adding as NTP server(s)."
+ ntp_mirror_entry="Servers=$gateway"
else
@@ -346,17 +337,15 @@ _EOF_
chmod -R 777 /var/www/ompd/cache #(required for downloading files)
# - MPD
- chmod 644 /var/log/mpd/mpd.log
- chmod 0666 /etc/mpd.conf
- chmod -R 777 /var/lib/mpd $G_FP_DIETPI_USERDATA/.mpd_cache
-
- chown -R root:dietpi /etc/mpd.conf /var/log/mpd $G_FP_DIETPI_USERDATA/.mpd_cache /var/lib/mpd
+ chmod 0664 /var/log/mpd/mpd.log /etc/mpd.conf
+ chmod -R 775 /var/lib/mpd $G_FP_DIETPI_USERDATA/.mpd_cache
+ chown -R mpd:dietpi /etc/mpd.conf /var/log/mpd $G_FP_DIETPI_USERDATA/.mpd_cache /var/lib/mpd
# - MyMPD
chown -R mympd:dietpi /var/lib/mympd
# - Mopidy
- chown -R mopidy:dietpi $G_FP_DIETPI_USERDATA/mopidy
+ chown -R mopidy:root $G_FP_DIETPI_USERDATA/mopidy
# - Minidlna
chown -R minidlna:dietpi $G_FP_DIETPI_USERDATA/.MiniDLNA_Cache
@@ -397,7 +386,7 @@ _EOF_
chown -R nodered:nodered $G_FP_DIETPI_USERDATA/node-red
# - grafana
- chown -R grafana:grafana $G_FP_DIETPI_USERDATA/grafana
+ chown -R grafana:grafana $G_FP_DIETPI_USERDATA/grafana /var/lib/grafana
# - influxDB
chown -R influxdb:influxdb $G_FP_DIETPI_USERDATA/influxdb
@@ -418,9 +407,12 @@ _EOF_
# - cubrite
chown -R cuberite:dietpi $G_FP_DIETPI_USERDATA/cubrite
- # - sickrage
- chown -R sickrage:dietpi $G_FP_DIETPI_USERDATA/sickrage
- chown sickrage:dietpi /var/log/sickrage.log
+ # - sickrage # pre-v6.20 compatibility
+ [[ -d $G_FP_DIETPI_USERDATA/sickrage ]] && chown -R sickrage:dietpi $G_FP_DIETPI_USERDATA/sickrage
+ [[ -f /var/log/sickrage.log ]] && chown sickrage:dietpi /var/log/sickrage.log
+
+ # - Medusa
+ chown -R medusa:dietpi $G_FP_DIETPI_USERDATA/medusa
# - Sonarr
chown -R sonarr:dietpi $G_FP_DIETPI_USERDATA/sonarr
@@ -549,7 +541,7 @@ _EOF_
# - Delete $INPUT_MODE_VALUE
userdel -f "$INPUT_MODE_VALUE"
- rm -R /home/"$INPUT_MODE_VALUE"
+ rm -R "/home/$INPUT_MODE_VALUE"
# - Remove from sudoers
sed -i "/^$INPUT_MODE_VALUE[[:space:]]/d" /etc/sudoers.d/dietpi
@@ -566,11 +558,7 @@ _EOF_
#Verify entries with git dietpi.txt
local gitbranch=$(grep -m1 '^[[:blank:]]*DEV_GITBRANCH=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
- if [[ ! $gitbranch ]]; then
-
- gitbranch='master'
-
- fi
+ [[ $gitbranch ]] || gitbranch='master'
INSTALL_URL="https://raw.githubusercontent.com/Fourdee/DietPi/$gitbranch/dietpi.txt"
G_CHECK_URL "$INSTALL_URL"
@@ -706,10 +694,6 @@ It is highly recommended to change this password, ideally, it should be differen
Userdel_Main
- elif [[ $INPUT_MODE_NAME == 'ntpd-mirror' ]]; then
-
- NtpdMirror_Main
-
elif [[ $INPUT_MODE_NAME == 'ntpd-mode' ]]; then
NtpdMode_Main
diff --git a/dietpi/func/dietpi-set_userdata b/dietpi/func/dietpi-set_userdata
index d5efff446c..65d57c9ab9 100644
--- a/dietpi/func/dietpi-set_userdata
+++ b/dietpi/func/dietpi-set_userdata
@@ -46,8 +46,7 @@
G_DIETPI-NOTIFY 2 'Please wait...\n'
# - Begin transfer
- cp -a "$SOURCE_DIRECTORY"/. "$TARGET_DIRECTORY"/
- if (( ! $? )); then
+ if cp -a "$SOURCE_DIRECTORY"/. "$TARGET_DIRECTORY"/; then
# - Remove source
rm -R "$SOURCE_DIRECTORY"
@@ -122,7 +121,7 @@
# - Remove $G_FP_DIETPI_USERDATA symlink, if chosen as target
[[ $TARGET_DIRECTORY == $G_FP_DIETPI_USERDATA ]] && rm $G_FP_DIETPI_USERDATA &> /dev/null
- mkdir -p "$TARGET_DIRECTORY" &> /dev/null
+ mkdir -p "$TARGET_DIRECTORY"
# - Ensure we can create, write and set permissions to target directory
if ! G_CHECK_FS_PERMISSION_SUPPORT $TARGET_DIRECTORY; then
@@ -136,7 +135,7 @@
# "-BM" => result in MiB actual disc usage, respecting disk block size, e.g. "144M"
# "-b" => result in bytes apparent size, ignoring disk block size, e.g. "142662603"
# Trailing slash required with "du" to correctly check symlink target in case
- FREESPACE_REQUIRED_SOURCE=$(du -sBM "$SOURCE_DIRECTORY/" | awk '{print $1}' | sed 's/[^0-9]*//g')
+ FREESPACE_REQUIRED_SOURCE=$(du -sBM "$SOURCE_DIRECTORY/" | mawk '{print $1}' | sed 's/[^0-9]*//g')
if ! G_CHECK_FREESPACE "$TARGET_DIRECTORY" $FREESPACE_REQUIRED_SOURCE; then
LOGFILE_OUTPUT_TEXT="ERROR: Not enough free space in target directory $TARGET_DIRECTORY.\n - Required $FREESPACE_REQUIRED_SOURCE"
@@ -155,7 +154,7 @@
#-----------------------------------------------------------------------------------
#Print results and send to logfile
- rm $FP_LOGFILE &> /dev/null
+ [[ -f $FP_LOGFILE ]] && rm $FP_LOGFILE
if [[ $LOGFILE_OUTPUT_TEXT ]]; then
# - Info
diff --git a/dietpi/func/run_ntpd b/dietpi/func/run_ntpd
index a6bea5c4dc..26f4a59907 100644
--- a/dietpi/func/run_ntpd
+++ b/dietpi/func/run_ntpd
@@ -27,62 +27,108 @@
INPUT=0
disable_error=1 G_CHECK_VALIDINT $1 && INPUT=$1
- EXIT_CODE=-1
+ EXIT_CODE=1
FP_EXIT_CODE='/DietPi/dietpi/.timesync_exit_status'
- NTPD_UPDATE_MODE=$(grep -m1 '^[[:blank:]]*CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/^.*=//')
+ NTP_UPDATE_MODE=$(grep -m1 '^[[:blank:]]*CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/^.*=//')
MAX_LOOPS_CHECK=${MAX_LOOPS_CHECK:-60} #*2 = seconds
Update_NTPD(){
- #systemd-timesyncd
- if (( $NTPD_UPDATE_MODE >= 1 && $NTPD_UPDATE_MODE <= 4 )); then
+ #Loop NTP check until sucess, or, non-G_USER_INPUTS and timed out.
+ while (( $EXIT_CODE == 1 ))
+ do
- G_RUN_CMD systemctl restart systemd-timesyncd
+ NTP_UPDATE_MODE=$(grep -m1 '^[[:blank:]]*CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/^.*=//')
- local current_loop=1
+ #systemd-timesyncd
+ if (( $NTP_UPDATE_MODE >= 1 && $NTP_UPDATE_MODE <= 4 )); then
- while true
- do
+ G_RUN_CMD systemctl restart systemd-timesyncd
- #NB: Following will always report "Synced", once systemd has completed it once
- # - Jessie: "using", Stretch+: "synchronized to"
- if systemctl status systemd-timesyncd | grep -qiE '^[[:blank:]]*status: "(synchronized to|using) time server'; then
+ for ((i=0; i<=$MAX_LOOPS_CHECK; i++))
+ do
- G_DIETPI-NOTIFY 0 'NTPD: systemd-timesyncd synced'
- if (( $NTPD_UPDATE_MODE >= 1 && $NTPD_UPDATE_MODE <= 3 )); then
+ #NB: Following will always report "Synced", once systemd has completed it once
+ # - Jessie: "using", Stretch+: "synchronized to"
+ if systemctl status systemd-timesyncd | grep -qiE '^[[:blank:]]*status: "(synchronized to|using) time server'; then
- systemctl stop systemd-timesyncd
- #systemctl stop systemd-timedated
+ G_DIETPI-NOTIFY 0 'NTPD: systemd-timesyncd synced'
+ if (( $NTP_UPDATE_MODE >= 1 && $NTP_UPDATE_MODE <= 3 )); then
- fi
+ systemctl stop systemd-timesyncd
+ #systemctl stop systemd-timedated
- EXIT_CODE=0
- break
+ fi
- elif (( $current_loop >= $MAX_LOOPS_CHECK )); then
+ EXIT_CODE=0
+ break
- G_DIETPI-NOTIFY 2 'NTPD: time out waiting for systemd-timesyncd'
- EXIT_CODE=1
- break
+ elif (( $i == $MAX_LOOPS_CHECK )); then
- else
+ G_DIETPI-NOTIFY 2 'NTPD: time out waiting for systemd-timesyncd'
- G_DIETPI-NOTIFY 2 "NTPD: Waiting for completion of systemd-timesyncd ($current_loop/$MAX_LOOPS_CHECK)"
- sleep 2
- ((current_loop++))
+ if (( $G_USER_INPUTS )); then
- fi
+ # - Ask
+ G_WHIP_MENU_ARRAY=(
- done
+ 'Retry' ': (Recommended) Rerun network time sync'
+ 'NTP mirror' ': Change the NTP mirror used'
+ 'NTP mode' ': Change the NTP mode (eg: daemon + drift)'
+ 'Override' ': (NOT RECOMMENDED) Ignore failure and override time sync status'
- #other method: assume status is ok
- else
+ )
- G_DIETPI-NOTIFY 0 'NTPD: manual mode detected'
- EXIT_CODE=0
+ G_WHIP_BUTTON_CANCEL_TEXT='Retry'
+ G_WHIP_MENU 'Network time sync has not yet completed, or, failed to update.\nTo prevent issues with outdated system time during installations, please select an option below.\n
+NB: We highly recommend choosing "Retry" first. Failing that, "NTP mirror" then "NTP mode".\n"Override" is a last resort and may cause follow-up issues due to incorrect system clock time.'
+ if (( ! $? )); then
- fi
+ if [[ $G_WHIP_RETURNED_VALUE == 'NTP mirror' ]]; then
+
+ G_WHIP_MSG 'DietPi-Config will now be launched, on the next screen:\n - Select "NTP Mirror"\n - Select a different NTP mirror\n\nOnce completed, exit dietpi-config to resume setup'
+ /DietPi/dietpi/dietpi-config 16 1
+
+ elif [[ $G_WHIP_RETURNED_VALUE == 'NTP mode' ]]; then
+
+ G_WHIP_MSG 'DietPi-Config will now be launched, on the next screen:\n - Select "Time sync mode"\n - Select a different time sync mode (eg: Daemon + Drift)\n\nOnce completed, exit dietpi-config to resume setup'
+ /DietPi/dietpi/dietpi-config 3 1
+
+ elif [[ $G_WHIP_RETURNED_VALUE == 'Override' ]]; then
+
+ EXIT_CODE=0
+ echo 1 > /var/lib/dietpi/.ntpd_override
+
+ fi
+
+ fi
+
+ # - Automated, allow fail
+ else
+
+ EXIT_CODE=2 #end loop.
+
+ fi
+
+ else
+
+ G_DIETPI-NOTIFY 2 "NTPD: Waiting for completion of systemd-timesyncd ($(( $i + 1 ))/$MAX_LOOPS_CHECK)"
+ sleep 2
+
+ fi
+
+ done
+
+ #other method: assume status is ok
+ else
+
+ G_DIETPI-NOTIFY 0 'NTPD: manual mode detected'
+ EXIT_CODE=0
+
+ fi
+
+ done
# - log status of completion, prevent software installs: https://github.com/Fourdee/DietPi/issues/786
echo $EXIT_CODE > $FP_EXIT_CODE
@@ -110,19 +156,18 @@
fi
- #-----------------------------------------------------------------------------------
- #Always return status
+ #return status
G_DIETPI-NOTIFY -1 $EXIT_CODE 'NTPD: time sync |'
if (( $EXIT_CODE != 0 )); then
- if (( $NTPD_UPDATE_MODE >= 1 && $NTPD_UPDATE_MODE <= 4 )); then
+ if (( $NTP_UPDATE_MODE >= 1 && $NTP_UPDATE_MODE <= 4 )); then
G_DIETPI-NOTIFY 2 'NTPD: Please check the service status for more information:'
G_DIETPI-NOTIFY 2 'NTPD: systemctl status systemd-timesyncd -l'
else
- echo -e 'Should never occur'
+ echo 'Should never occur'
fi
diff --git a/dietpi/login b/dietpi/login
index acbca12407..6f06a7ceec 100644
--- a/dietpi/login
+++ b/dietpi/login
@@ -11,11 +11,10 @@
# Info:
# - filename /DietPi/dietpi/login
# - activates on login /etc/bashrc.d/dietpi-login.sh
- # - requires /DietPi/dietpi/.install_stage to have a value of 0 for it to run /DietPi/dietpi/dietpi-software (active after /dietpi/boot has completed first run setup)
#////////////////////////////////////
#Precaution: Wait for DietPi Ramdisk to finish
- while [[ ! -f /DietPi/.ramdisk ]]
+ until [[ -f /DietPi/.ramdisk ]]
do
G_DIETPI-NOTIFY 2 'Waiting for DietPi-RAMDISK to finish mounting DietPi to RAM...'
@@ -38,7 +37,8 @@
#/////////////////////////////////////////////////////////////////////////////////////
#DietPi-Autostart
#/////////////////////////////////////////////////////////////////////////////////////
- AUTO_START_INDEX=$(= $max_seconds )) && break
+
+ done
+
#Kodi
if (( $AUTO_START_INDEX == 1 )); then
@@ -90,38 +105,16 @@
#Amiberry standard boot
elif (( $AUTO_START_INDEX == 8 )); then
- $G_FP_DIETPI_USERDATA/amiberry/run.sh
+ systemctl start amiberry
#DXX-Rebirth
elif (( $AUTO_START_INDEX == 9 )); then
- #wait for DietPi-PostBoot to finish
- local max_seconds=15
- local current_seconds=0
- while ! systemctl status dietpi-postboot | grep -qi 'exited'
- do
-
- sleep 1
- ((current_seconds++))
-
- #max loop limit
- (( $current_seconds >= $max_seconds )) && break
-
- done
-
$G_FP_DIETPI_USERDATA/dxx-rebirth/run.sh
#CAVA
elif (( $AUTO_START_INDEX == 10 )); then
- #wait for DietPi-PostBoot to finish
- while ! systemctl status dietpi-postboot | grep -qi 'code=exited, status=0/SUCCESS'
- do
-
- sleep 1
-
- done
-
# wait for MPD fifo to start
sleep 4
@@ -144,74 +137,118 @@
}
- #/////////////////////////////////////////////////////////////////////////////////////
- # Main Loop
- #/////////////////////////////////////////////////////////////////////////////////////
+ Run_First_Update_Setup(){
- #Update network details for banner IP address.
- /DietPi/dietpi/func/obtain_network_details
+ /DietPi/dietpi/func/dietpi-banner 0
+ local automated_setup=0
- #----------------------------------------------------------------
- #Normal Login
- if (( $G_DIETPI_INSTALL_STAGE == 1 )); then
+ until (( $G_DIETPI_INSTALL_STAGE == 2 ))
+ do
- /DietPi/dietpi/func/dietpi-banner 1
+ # - Automated?
+ if grep -qi '^[[:blank:]]*AUTO_SETUP_AUTOMATED=1' /DietPi/dietpi.txt; then
- (( $AUTO_START_INDEX > 0 )) && Run_AutoStart
+ automated_setup=1
+ # Set non-interactive shell, if automated installation (as .bashrc run via STDIN check is interactive)
+ export G_USER_INPUTS=0
- #----------------------------------------------------------------
- #Run DietPi-Software (1st run setup)
- elif (( $G_DIETPI_INSTALL_STAGE == 0 )); then
+ fi
- /DietPi/dietpi/func/dietpi-banner 0
+ # - 1st run dietpi-update
+ if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
- #Wait for DietPi-Software if already running, else run it
- while pgrep 'dietpi-software' &> /dev/null
- do
+ # Check internet
+ optional_cmd_inputs='--no-check-certificate' G_CHECK_URL "$(grep -m1 '^[[:blank:]]*deb ' /etc/apt/sources.list | awk '{print $2}')" # Will exit on failure here then prompt user to configure network
- # - Automated
- if grep -qi '^[[:blank:]]*AUTO_SETUP_AUTOMATED=1' /DietPi/dietpi.txt; then
+ # Check NTP synced
+ /DietPi/dietpi/func/run_ntpd
- G_DIETPI-NOTIFY 2 'DietPi is currently installing and configuring your system. Please wait for this to complete, check back later.'
+ # Show GPL license
+ if [[ -f /var/lib/dietpi/license.txt ]]; then
- else
+ G_WHIP_VIEWFILE /var/lib/dietpi/license.txt
+ rm /var/lib/dietpi/license.txt
- G_DIETPI-NOTIFY 2 'DietPi-Software is already running on another terminal/screen. Please complete or exit, before continuing.'
+ fi
+
+ /DietPi/dietpi/dietpi-update 1 #Sets G_DIETPI_INSTALL_STAGE=1
+
+ # - 1st run dietpi-software installs
+ elif (( $G_DIETPI_INSTALL_STAGE == 1 )); then
+
+ # Wait for DietPi-Software if already running, else run it
+ local run_dietpi_software=1
+ while pgrep 'dietpi-software' &> /dev/null
+ do
+
+ run_dietpi_software=0
+
+ # - Automated
+ if (( $automated_setup )); then
+
+ G_DIETPI-NOTIFY 2 'DietPi is currently installing and configuring your system. Please wait for this to complete, check back later.'
+
+ else
+
+ G_DIETPI-NOTIFY 2 'DietPi-Software is already running on another terminal/screen. Please complete or exit, before continuing.'
+
+ fi
+
+ sleep 2
+
+ done
+
+ # Start DietPi-Software
+ if (( $run_dietpi_software )); then
+
+ /DietPi/dietpi/dietpi-software | tee $FP_TMP_DIETPI_FIRSTRUNSETUP_LOG #Sets G_DIETPI_INSTALL_STAGE=2
+ mv $FP_TMP_DIETPI_FIRSTRUNSETUP_LOG $FP_DIETPI_FIRSTRUNSETUP_LOG
+
+ fi
fi
- sleep 2
+ # - reset to auto detection
+ unset G_USER_INPUTS
done
- # - Start DietPi-Software
+ }
+
+ #/////////////////////////////////////////////////////////////////////////////////////
+ # Main Loop
+ #/////////////////////////////////////////////////////////////////////////////////////
+
+ #Update network details for banner IP address.
+ /DietPi/dietpi/func/obtain_network_details
- #Set non-interactive shell, if automated installation (as .bashrc run via STDIN check is interactive)
- if grep -qi '^[[:blank:]]*AUTO_SETUP_AUTOMATED=1' /DietPi/dietpi.txt; then
+ #----------------------------------------------------------------
+ #Normal Login
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )); then
- export G_USER_INPUTS=0
+ /DietPi/dietpi/func/dietpi-banner 1
- fi
+ (( $AUTO_START_INDEX > 0 )) && Run_AutoStart
- /DietPi/dietpi/dietpi-software | tee $FP_TMP_DIETPI_FIRSTRUNSETUP_LOG
- mv $FP_TMP_DIETPI_FIRSTRUNSETUP_LOG $FP_DIETPI_FIRSTRUNSETUP_LOG
+ #----------------------------------------------------------------
+ #Run DietPi-Update/DietPi-Software (1st run setup) (G_DIETPI_INSTALL_STAGE=0/1)
+ elif (( $G_DIETPI_INSTALL_STAGE >= 0 )); then
- # reset to auto detection
- unset G_USER_INPUTS
+ Run_First_Update_Setup
#----------------------------------------------------------------
#DietPi finishing up bootloader.
elif (( $G_DIETPI_INSTALL_STAGE == -1 )); then
/DietPi/dietpi/func/dietpi-banner 0
- echo -e ' >> DietPi System prep is nearly completed: \n Please run /DietPi/dietpi/login after a few seconds'
+ echo -e ' >> DietPi System prep is nearly completed: \n Please run /DietPi/dietpi/login after a few seconds.'
#----------------------------------------------------------------
#DietPi running filesystem prep
else
/DietPi/dietpi/func/dietpi-banner 0
- echo -e ' >> Filesystem prep has not yet completed: \n Please wait for the system to reboot'
+ echo -e ' >> Filesystem prep has not yet completed: \n Please wait for the system to reboot.'
fi
diff --git a/dietpi/misc/dietpi-justboom b/dietpi/misc/dietpi-justboom
index a682113279..ecd40a0761 100644
--- a/dietpi/misc/dietpi-justboom
+++ b/dietpi/misc/dietpi-justboom
@@ -41,11 +41,7 @@
EQ_ENABLED=0
SOUNDCARD_CURRENT=0
SOUNDCARD_CARD_INDEX=0
- if [[ -f /etc/asound.conf ]]; then
-
- SOUNDCARD_CARD_INDEX=$(grep -m1 'card ' /etc/asound.conf | awk '{print $2}')
-
- fi
+ [[ -f /etc/asound.conf ]] && SOUNDCARD_CARD_INDEX=$(mawk '/card / {print $2;exit}' /etc/asound.conf)
# - MPD
OUTPUT_FREQ_CURRENT=0
@@ -58,12 +54,7 @@
FP_MPD_CONF='/etc/mpd.conf'
MPD_INSTALLED=0
-
- if [[ -f $FP_MPD_CONF ]]; then
-
- MPD_INSTALLED=1
-
- fi
+ [[ -f $FP_MPD_CONF ]] && MPD_INSTALLED=1
# - CAVA
CAVA_ENABLED=1
@@ -76,18 +67,13 @@
FP_CAVA_CONF="$HOME/.config/cava/config"
CAVA_INSTALLED=0
-
- if [[ -f $FP_CAVA_CONF ]]; then
-
- CAVA_INSTALLED=1
-
- fi
+ [[ -f $FP_CAVA_CONF ]] && CAVA_INSTALLED=1
Reset_Globals(){
#ALSA EQ levels
- rm $HOME/.alsaequal.bin &> /dev/null
+ [[ -f $HOME/.alsaequal.bin ]] && rm $HOME/.alsaequal.bin
#MPD
OUTPUT_FREQ_TARGET=44100
@@ -98,7 +84,7 @@
MPD_AUDIO_BUFFER_SIZE=2048
# - Reset CAVA config
- cp /DietPi/dietpi/conf/cava.conf $HOME/.config/cava/config
+ cp /var/lib/dietpi/dietpi-software/conf/cava.conf $HOME/.config/cava/config
CAVA_ENABLED=1
CAVA_FRAMERATE=30
@@ -121,24 +107,24 @@
#MPD specific
if (( $MPD_INSTALLED )); then
- OUTPUT_FREQ_CURRENT=$(grep -m1 '^format' $FP_MPD_CONF | sed 's/\"//g' | sed 's/:/ /g' | awk '{print $2}')
+ OUTPUT_FREQ_CURRENT=$(grep -m1 '^format' $FP_MPD_CONF | sed 's/\"//g' | sed 's/:/ /g' | mawk '{print $2}')
OUTPUT_FREQ_TARGET=$OUTPUT_FREQ_CURRENT
- OUTPUT_BITRATE_CURRENT=$(grep -m1 '^format' $FP_MPD_CONF | sed 's/\"//g' | sed 's/:/ /g' | awk '{print $3}')
+ OUTPUT_BITRATE_CURRENT=$(grep -m1 '^format' $FP_MPD_CONF | sed 's/\"//g' | sed 's/:/ /g' | mawk '{print $3}')
OUTPUT_BITRATE_TARGET=$OUTPUT_BITRATE_CURRENT
SOXR_ENABLED=$(grep -ci -m1 '^samplerate_converter \"soxr' $FP_MPD_CONF)
- SOXR_QUALITY=$(grep -m1 'samplerate_converter \"soxr' $FP_MPD_CONF | sed 's/\"//g' | awk '{for(i=3;i<=NF;i++){printf "%s ", $i}; printf "\n"}' | sed 's/ *$//')
- MPD_AUDIO_BUFFER_SIZE=$(grep -m1 '^audio_buffer_size' $FP_MPD_CONF | awk '{print $2}' | sed 's/\"//g')
+ SOXR_QUALITY=$(grep -m1 'samplerate_converter \"soxr' $FP_MPD_CONF | sed 's/\"//g' | mawk '{for(i=3;i<=NF;i++){printf "%s ", $i}; printf "\n"}' | sed 's/ *$//')
+ MPD_AUDIO_BUFFER_SIZE=$(grep -m1 '^audio_buffer_size' $FP_MPD_CONF | mawk '{print $2}' | sed 's/\"//g')
fi
#CAVA specific
if (( $CAVA_INSTALLED )); then
- CAVA_FRAMERATE=$(grep -m1 'framerate =' $FP_CAVA_CONF | awk '{print $NF}')
- CAVA_COLOUR_BG=$(grep -m1 'background =' $FP_CAVA_CONF | awk '{print $NF}')
- CAVA_COLOUR_FG=$(grep -m1 'foreground =' $FP_CAVA_CONF | awk '{print $NF}')
- CAVA_BAR_GRAVITY=$(grep -m1 'gravity =' $FP_CAVA_CONF | awk '{print $NF}')
- CAVA_BAR_WIDTH=$(grep -m1 'bar_width =' $FP_CAVA_CONF | awk '{print $NF}')
+ CAVA_FRAMERATE=$(mawk '/framerate =/ {print $NF;exit}' $FP_CAVA_CONF)
+ CAVA_COLOUR_BG=$(mawk '/background =/ {print $NF;exit}' $FP_CAVA_CONF)
+ CAVA_COLOUR_FG=$(mawk '/foreground =/ {print $NF;exit}' $FP_CAVA_CONF)
+ CAVA_BAR_GRAVITY=$(mawk '/gravity =/ {print $NF;exit}' $FP_CAVA_CONF)
+ CAVA_BAR_WIDTH=$(mawk '/bar_width =/ {print $NF;exit}' $FP_CAVA_CONF)
fi
@@ -236,8 +222,7 @@
Menu_Exit(){
G_WHIP_SIZE_X_MAX=50
- G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"
- if (( $? == 0 )); then
+ if G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"; then
#exit
TARGETMENUID=-1
@@ -257,29 +242,16 @@
Read_Globals
local eq_enabled_text='[Off]'
- if (( $EQ_ENABLED )); then
-
- eq_enabled_text='[On]'
-
- fi
+ (( $EQ_ENABLED )) && eq_enabled_text='[On]'
local soxr_enabled_text='[Off]'
- if (( $SOXR_ENABLED )); then
-
- soxr_enabled_text='[On]'
-
- fi
+ (( $SOXR_ENABLED )) && soxr_enabled_text='[On]'
G_WHIP_MENU_ARRAY=('' '●─ Global Options ')
G_WHIP_MENU_ARRAY+=('ALSA Mixer' ': Launches ALSA Mixer, tweak sound card settings')
G_WHIP_MENU_ARRAY+=('ALSA Output Info' ': View info on current ALSA playback stream')
G_WHIP_MENU_ARRAY+=("EQ Enable" ": $eq_enabled_text | Select to toggle EQ")
- if (( $EQ_ENABLED )); then
-
- G_WHIP_MENU_ARRAY+=('EQ Configure' ': Launches AlsaMixer to configure EQ settings')
-
- fi
-
+ (( $EQ_ENABLED )) && G_WHIP_MENU_ARRAY+=('EQ Configure' ': Launches AlsaMixer to configure EQ settings')
G_WHIP_MENU_ARRAY+=('Reset' ': Reset all options to defaults')
#Allo Piano 2.1 specials
@@ -290,11 +262,11 @@
local dsp_filter=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'DSP Program'" | grep 'Item0:' | sed 's/.*Item0: //')
G_WHIP_MENU_ARRAY+=("DSP Filter" ": $dsp_filter")
- local digital_volume_int=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Digital'" | grep 'Front Left:' | awk '{print $4}')
- local digital_volume_db=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Digital'" | grep 'Front Left:' | awk '{print $6}' | tr -d '\[\]')
+ local digital_volume_int=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Digital'" | grep 'Front Left:' | mawk '{print $4}')
+ local digital_volume_db=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Digital'" | grep 'Front Left:' | mawk '{print $6}' | tr -d '\[\]')
local subwoofer_mode=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Subwoofer mode'" | grep 'Item0:' | sed 's/.*Item0: //')
- local subwoofer_volume_int=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Subwoofer'" | grep 'Front Left:' | awk '{print $4}')
- local subwoofer_volume_db=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Subwoofer'" | grep 'Front Left:' | awk '{print $6}' | tr -d '\[\]')
+ local subwoofer_volume_int=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Subwoofer'" | grep 'Front Left:' | mawk '{print $4}')
+ local subwoofer_volume_db=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Subwoofer'" | grep 'Front Left:' | mawk '{print $6}' | tr -d '\[\]')
local subwoofer_crossover_frequency=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Lowpass'" | grep 'Item0:' | sed 's/.*Item0: //')
local dualoutput_mode=$(amixer -c $SOUNDCARD_CARD_INDEX sget "'Dual Mode'" | grep 'Item0:' | sed 's/.*Item0: //')
@@ -322,11 +294,7 @@
G_WHIP_MENU_ARRAY+=('Audio Buffer' ": $MPD_AUDIO_BUFFER_SIZE Bytes | Select to change")
G_WHIP_MENU_ARRAY+=('SOXR Enable' ": $soxr_enabled_text | Select to toggle SOXR resampling")
- if (( $SOXR_ENABLED )); then
-
- G_WHIP_MENU_ARRAY+=('SOXR Quality' ": $SOXR_QUALITY | Select SOXR quality level")
-
- fi
+ (( $SOXR_ENABLED )) && G_WHIP_MENU_ARRAY+=('SOXR Quality' ": $SOXR_QUALITY | Select SOXR quality level")
fi
@@ -336,11 +304,7 @@
G_WHIP_MENU_ARRAY+=('' '●─ CAVA Specific ')
G_WHIP_MENU_ARRAY+=('Cava Start/Restart' ': Launch Cava on main screen')
- if (( $(ps aux | grep -ci -m1 '[c]ava') )); then
-
- G_WHIP_MENU_ARRAY+=('Cava Stop' ': Stop Cava')
-
- fi
+ pgrep 'cava' &> /dev/null && G_WHIP_MENU_ARRAY+=('Cava Stop' ': Stop Cava')
G_WHIP_MENU_ARRAY+=('Cava Framerate' ": $CAVA_FRAMERATE fps | Select to change")
G_WHIP_MENU_ARRAY+=('Cava FG Colour' ": $CAVA_COLOUR_FG | Select to change")
@@ -352,8 +316,7 @@
G_WHIP_DEFAULT_ITEM="$LAST_SELECTED_NAME"
G_WHIP_BUTTON_CANCEL_TEXT='Exit'
- G_WHIP_MENU 'Tweak your High-End Audiophile JustBoom (and others) sound card:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Tweak your High-End Audiophile JustBoom (and others) sound card:'; then
LAST_SELECTED_NAME="$G_WHIP_RETURNED_VALUE"
@@ -384,8 +347,7 @@
)
G_WHIP_DEFAULT_ITEM="$subwoofer_mode"
- G_WHIP_MENU 'Please select a channel mode for Subwoofer output:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a channel mode for Subwoofer output:'; then
amixer -c $SOUNDCARD_CARD_INDEX sset 'Subwoofer mode' $G_WHIP_RETURNED_VALUE
@@ -401,8 +363,7 @@
)
G_WHIP_DEFAULT_ITEM="$dualoutput_mode"
- G_WHIP_MENU 'Please select a channel mode for Subwoofer output:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a channel mode for Subwoofer output:'; then
amixer -c $SOUNDCARD_CARD_INDEX sset 'Dual Mode' $G_WHIP_RETURNED_VALUE
@@ -432,8 +393,7 @@
done
G_WHIP_DEFAULT_ITEM="$digital_volume_int"
- G_WHIP_MENU 'Please select a volume level for Master output:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a volume level for Master output:'; then
amixer -c $SOUNDCARD_CARD_INDEX sset 'Digital' ''$G_WHIP_RETURNED_VALUE''
@@ -463,8 +423,7 @@
done
G_WHIP_DEFAULT_ITEM="$subwoofer_volume_int"
- G_WHIP_MENU 'Please select a volume level for Subwoofer output:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a volume level for Subwoofer output:'; then
amixer -c $SOUNDCARD_CARD_INDEX sset 'Subwoofer' ''$G_WHIP_RETURNED_VALUE''
@@ -513,8 +472,7 @@
)
G_WHIP_DEFAULT_ITEM="$dsp_filter"
- G_WHIP_MENU 'Please select a DSP Filter:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a DSP Filter:'; then
amixer -c $SOUNDCARD_CARD_INDEX sset 'DSP Program' "$G_WHIP_RETURNED_VALUE"
@@ -545,8 +503,7 @@
)
G_WHIP_DEFAULT_ITEM="$CAVA_FRAMERATE"
- G_WHIP_MENU 'Please select a framerate:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a framerate:'; then
CAVA_FRAMERATE=$G_WHIP_RETURNED_VALUE
Write_Apply_Globals
@@ -568,8 +525,7 @@
)
G_WHIP_DEFAULT_ITEM="$CAVA_BAR_WIDTH"
- G_WHIP_MENU 'Please select a bar width:\n - The size of the bars affects how many are displayed'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a bar width:\n - The size of the bars affects how many are displayed'; then
CAVA_BAR_WIDTH=$G_WHIP_RETURNED_VALUE
Write_Apply_Globals
@@ -601,8 +557,7 @@
)
G_WHIP_DEFAULT_ITEM="$default_item"
- G_WHIP_MENU 'Please select a colour:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a colour:'; then
if (( $apply_fg_colour )); then
@@ -660,22 +615,14 @@
elif [[ $G_WHIP_RETURNED_VALUE == 'EQ Enable' ]]; then
((EQ_ENABLED++))
- if (( $EQ_ENABLED > 1 )); then
-
- EQ_ENABLED=0
-
- fi
+ (( $EQ_ENABLED > 1 )) && EQ_ENABLED=0
Write_Apply_Globals
elif [[ $G_WHIP_RETURNED_VALUE == 'SOXR Enable' ]]; then
((SOXR_ENABLED++))
- if (( $SOXR_ENABLED > 1 )); then
-
- SOXR_ENABLED=0
-
- fi
+ (( $SOXR_ENABLED > 1 )) && SOXR_ENABLED=0
Write_Apply_Globals
@@ -690,8 +637,7 @@
)
G_WHIP_DEFAULT_ITEM="$SOXR_QUALITY"
- G_WHIP_MENU 'Please select a SOXR quality level:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a SOXR quality level:'; then
SOXR_QUALITY=$G_WHIP_RETURNED_VALUE
Write_Apply_Globals
@@ -714,8 +660,7 @@
)
G_WHIP_DEFAULT_ITEM="$MPD_AUDIO_BUFFER_SIZE"
- G_WHIP_MENU 'Please select a audio buffer size (bytes):'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a audio buffer size (bytes):'; then
MPD_AUDIO_BUFFER_SIZE=$G_WHIP_RETURNED_VALUE
Write_Apply_Globals
@@ -738,8 +683,7 @@
)
G_WHIP_DEFAULT_ITEM="$OUTPUT_FREQ_CURRENT"
- G_WHIP_MENU 'Please select a output frequency:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a output frequency:'; then
OUTPUT_FREQ_TARGET=$G_WHIP_RETURNED_VALUE
Write_Apply_Globals
@@ -757,8 +701,7 @@
)
G_WHIP_DEFAULT_ITEM="$OUTPUT_BITRATE_CURRENT"
- G_WHIP_MENU 'Please select a output bitrate:'
- if (( $? == 0 )); then
+ if G_WHIP_MENU 'Please select a output bitrate:'; then
OUTPUT_BITRATE_TARGET=$G_WHIP_RETURNED_VALUE
Write_Apply_Globals
@@ -789,11 +732,7 @@
while (( $TARGETMENUID >= 0 ))
do
- if (( $TARGETMENUID == 0 )); then
-
- Menu_Main
-
- fi
+ (( $TARGETMENUID == 0 )) && Menu_Main
done
#-----------------------------------------------------------------------------------
diff --git a/dietpi/misc/dietpi-nordvpn b/dietpi/misc/dietpi-nordvpn
new file mode 100644
index 0000000000..b9ce207832
--- /dev/null
+++ b/dietpi/misc/dietpi-nordvpn
@@ -0,0 +1,276 @@
+#!/bin/bash
+{
+ #////////////////////////////////////
+ # DietPi NordVPN
+ #
+ #////////////////////////////////////
+ # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com
+ #
+ #////////////////////////////////////
+ #
+ # Info:
+ # - GUI to setup a NordVPN connection
+ # - Automatically starts service during boot
+ # Usage:
+ # - /DietPi/dietpi/misc/dietpi-nordvpn
+ #////////////////////////////////////
+
+ #Import DietPi-Globals ---------------------------------------------------------------
+ . /DietPi/dietpi/func/dietpi-globals
+ G_PROGRAM_NAME='DietPi-NordVPN'
+ G_CHECK_ROOT_USER
+ G_CHECK_ROOTFS_RW
+ G_INIT
+ #Import DietPi-Globals ---------------------------------------------------------------
+
+ FP_SETTINGS_DIETPI='/var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn/settings_dietpi.conf'
+ FP_SETTINGS_OVPN='/var/lib/dietpi/dietpi-software/installed/dietpi-nordvpn/settings_ovpn.conf'
+ NORDVPN_USERNAME=''
+ NORDVPN_PASSWORD=''
+ NORDVPN_SERVER=''
+ PROTOCOL='udp'
+
+ NORDVPN_CONNECTED=0
+ MAX_WAIT_FOR_CONNECTION=5
+
+ Init(){
+
+ #Check installed
+ until grep -q 'aSOFTWARE_INSTALL_STATE\[171\]=2' /DietPi/dietpi/.installed
+ do
+
+ if G_WHIP_YESNO "$G_PROGRAM_NAME is not installed, would you like to install it now?"; then
+
+ /DietPi/dietpi/dietpi-software install 171
+
+ else
+
+ TARGETMENUID=-1
+ break
+
+ fi
+
+ done
+
+ Read_Settings
+
+ }
+
+ Check_Connected(){
+
+ NORDVPN_CONNECTED=0
+ local status=1
+ #if systemctl status dietpi-nordvpn | grep -qi 'initialization sequence completed'; then
+ if ip r | grep -q 'tun0'; then
+
+ status=0
+ NORDVPN_CONNECTED=1
+
+ fi
+
+ return $status
+
+ }
+
+ Read_Settings(){ [[ -f $FP_SETTINGS_DIETPI ]] && . $FP_SETTINGS_DIETPI; }
+
+ Save_Settings(){
+
+ systemctl stop dietpi-nordvpn
+
+ cat << _EOF_ > $FP_SETTINGS_OVPN
+${NORDVPN_USERNAME//\'/\'\\\'\'}
+${NORDVPN_PASSWORD//\'/\'\\\'\'}
+_EOF_
+
+ cat << _EOF_ > $FP_SETTINGS_DIETPI
+NORDVPN_USERNAME='${NORDVPN_USERNAME//\'/\'\\\'\'}'
+NORDVPN_PASSWORD='${NORDVPN_PASSWORD//\'/\'\\\'\'}'
+NORDVPN_SERVER='$NORDVPN_SERVER'
+PROTOCOL='$PROTOCOL'
+_EOF_
+ G_CONFIG_INJECT 'auth-user-pass[[:blank:]]' "auth-user-pass $FP_SETTINGS_OVPN" /etc/openvpn/ovpn_$PROTOCOL/$NORDVPN_SERVER
+
+ chmod 600 $FP_SETTINGS_OVPN $FP_SETTINGS_DIETPI /etc/openvpn/ovpn_$PROTOCOL/$NORDVPN_SERVER
+ chown root:root $FP_SETTINGS_OVPN $FP_SETTINGS_DIETPI /etc/openvpn/ovpn_$PROTOCOL/$NORDVPN_SERVER
+
+ cat << _EOF_ > /lib/systemd/system/dietpi-nordvpn.service
+[Unit]
+Description=NordVPN (DietPi)
+After=network.target dietpi-boot.service
+
+[Service]
+User=root
+Type=simple
+ExecStart=$(which openvpn) /etc/openvpn/ovpn_$PROTOCOL/$NORDVPN_SERVER
+
+[Install]
+WantedBy=multi-user.target
+_EOF_
+
+ systemctl daemon-reload
+ G_RUN_CMD systemctl enable dietpi-nordvpn
+ G_RUN_CMD systemctl restart dietpi-nordvpn
+
+ for (( i=1; i<=$MAX_WAIT_FOR_CONNECTION; i++ ))
+ do
+
+ if Check_Connected; then
+
+ break
+
+ else
+
+ G_DIETPI-NOTIFY 2 "Waiting for connection ($i/$MAX_WAIT_FOR_CONNECTION)"
+ sleep 1
+
+ fi
+
+ done
+
+ (( $NORDVPN_CONNECTED )) || G_WHIP_MSG "Connection failed/time out: $NORDVPN_SERVER\n\nPlease verify account details are correct.\n\nIf problems persist, please check the status of 'systemctl status dietpi-nordvpn -l'"
+
+ }
+
+ #/////////////////////////////////////////////////////////////////////////////////////
+ # Whip
+ #/////////////////////////////////////////////////////////////////////////////////////
+ TARGETMENUID=0
+ LAST_SELECTED_NAME=0
+
+ Menu_Exit(){
+
+ G_WHIP_SIZE_X_MAX=50
+ if G_WHIP_YESNO "Exit $G_PROGRAM_NAME?"; then
+
+ #exit
+ TARGETMENUID=-1
+
+ else
+
+ #Return to Main Menu
+ TARGETMENUID=0
+
+ fi
+
+ }
+
+ #TARGETMENUID=0
+ Menu_Main(){
+
+ local text_status='Status:\n'
+ if Check_Connected; then
+
+ text_status+=" - Connected to $NORDVPN_SERVER"
+
+ else
+
+ text_status+=' - Disconnected\n'
+ text_status+=' - NordVPN subscription: https://go.nordvpn.net/aff_c?offer_id=15&aff_id=5305&url_id=902'
+
+ fi
+
+ G_WHIP_MENU_ARRAY=('' '●─ Global Options ')
+ G_WHIP_MENU_ARRAY+=('Username' ": [$NORDVPN_USERNAME]")
+ G_WHIP_MENU_ARRAY+=('Password' ": [$NORDVPN_PASSWORD]")
+ G_WHIP_MENU_ARRAY+=('Server' ": [$NORDVPN_SERVER]")
+ G_WHIP_MENU_ARRAY+=('Refresh' ': Update VPN connection status')
+ (( $NORDVPN_CONNECTED )) && G_WHIP_MENU_ARRAY+=('Disconnect' '')
+ G_WHIP_MENU_ARRAY+=('' '●─ Save Settings ')
+ G_WHIP_MENU_ARRAY+=('Apply' ': Save settings and restart VPN connection')
+
+ G_WHIP_DEFAULT_ITEM=$LAST_SELECTED_NAME
+ G_WHIP_BUTTON_CANCEL_TEXT='Exit'
+ if G_WHIP_MENU "$text_status"; then
+
+ LAST_SELECTED_NAME="$G_WHIP_RETURNED_VALUE"
+
+ if [[ $G_WHIP_RETURNED_VALUE == 'Apply' ]]; then
+
+ Save_Settings
+
+ elif [[ $G_WHIP_RETURNED_VALUE == 'Username' ]]; then
+
+ G_WHIP_DEFAULT_ITEM=$NORDVPN_USERNAME
+ if G_WHIP_INPUTBOX 'Please enter your NordVPN username:'; then
+
+ NORDVPN_USERNAME=$G_WHIP_RETURNED_VALUE
+
+ fi
+
+ elif [[ $G_WHIP_RETURNED_VALUE == 'Password' ]]; then
+
+ if G_WHIP_PASSWORD 'Please enter your NordVPN password:'; then
+
+ NORDVPN_PASSWORD=$result
+ unset result
+
+ fi
+
+ elif [[ $G_WHIP_RETURNED_VALUE == 'Disconnect' ]]; then
+
+ G_RUN_CMD systemctl stop dietpi-nordvpn
+
+ elif [[ $G_WHIP_RETURNED_VALUE == 'Server' ]]; then
+
+ # Select protocol
+ G_WHIP_MENU_ARRAY=(
+
+ 'UDP' ': Recommended'
+ 'TCP' ''
+
+ )
+
+ G_WHIP_DEFAULT_ITEM=$PROTOCOL
+ if G_WHIP_MENU 'Please select the connection protocol type:'; then
+
+ PROTOCOL=${G_WHIP_RETURNED_VALUE,,}
+
+ fi
+
+ # Select server
+ G_WHIP_MENU_ARRAY=()
+ G_DIETPI-NOTIFY 2 'Populating NordVPN server list, please wait...'
+ cd /etc/openvpn/ovpn_$PROTOCOL
+ for i in *
+ do
+
+ G_WHIP_MENU_ARRAY+=("$i" '')
+
+ done
+
+ cd /tmp/$G_PROGRAM_NAME
+
+ G_WHIP_DEFAULT_ITEM=$NORDVPN_SERVER
+ if G_WHIP_MENU 'Please select a NordVPN server to use'; then
+
+ NORDVPN_SERVER=$G_WHIP_RETURNED_VALUE
+
+ fi
+
+ fi
+
+ else
+
+ Menu_Exit
+
+ fi
+
+ }
+
+ #/////////////////////////////////////////////////////////////////////////////////////
+ # Main Loop
+ #/////////////////////////////////////////////////////////////////////////////////////
+ #-----------------------------------------------------------------------------------
+ Init
+ #-----------------------------------------------------------------------------------
+ while (( $TARGETMENUID >= 0 ))
+ do
+
+ (( $TARGETMENUID == 0 )) && Menu_Main
+
+ done
+ #-----------------------------------------------------------------------------------
+ exit
+ #-----------------------------------------------------------------------------------
+}
diff --git a/dietpi/patch_file b/dietpi/patch_file
index cfb4b956a6..1fcb648a32 100644
--- a/dietpi/patch_file
+++ b/dietpi/patch_file
@@ -30,10 +30,32 @@
export G_DIETPI_VERSION_SUB=$INPUT
#/////////////////////////////////////////////////////////////////////////////////////
+ #Patches that require a restart of DietPi-Update and patch system.
+ Restart_DietPi_Update(){
+
+ #Save current version, to re-run patch on next launch
+ G_VERSIONDB_SAVE
+
+ #Remove DietPi-Update and DietPi-Patchfile working directories do allow concurrent execution
+ cd /tmp
+ rm -R /tmp/DietPi-Update /tmp/DietPi-Patchfile
+
+ G_DIETPI-NOTIFY 0 'Re-running DietPi-Update, to apply this new system'
+
+ #Apply update forcefully, since user has already chosen to do so
+ /DietPi/dietpi/dietpi-update 1
+
+ #Kill parental dietpi-update instance and exit this script to avoid obsolete update finish
+ kill $PPID
+ exit
+
+ }
+
#Pre-v6.17: Switch to new branch and versioning system
+ # As loaded pre-v6.17 dietpi-update will overwrite .version to previous 2 line system, we need to rerun dietpi-update.
if (( $G_DIETPI_VERSION_SUB < 17 )) && [[ ! $(sed -n 6p /DietPi/dietpi/.version) ]]; then
- # - Switch from obsolete testing to new dev branch
+ #Switch from obsolete testing to new dev branch
BRANCH_INFO=''
if grep -q '^[[:blank:]]*DEV_GITBRANCH=testing$' /DietPi/dietpi.txt; then
@@ -42,24 +64,40 @@
fi
- # - Addition of RC version
- G_VERSIONDB_SAVE
+ #Inform user to avoid confusion
+ echo ''
+ G_DIETPI-NOTIFY 0 "DietPi has applied a new$BRANCH_INFO versioning system to the device."
+
+ [[ -f /DietPi/dietpi/.update_stage ]] && G_VERSIONDB_SAVE || Restart_DietPi_Update
+
+ fi
+
+ #Update G_DIETPI_INSTALL_STAGE to new versioning system.
+ if [[ -f /DietPi/dietpi/.update_stage ]]; then
+
+ rm /DietPi/dietpi/.update_stage /boot/dietpi/.update_stage
- # - As loaded pre-v6.17 dietpi-update will overwrite .version to previous 2 line system, we need to rerun dietpi-update.
- # - Remove DietPi-Update and DietPi-Patchfile working directories do allow concurrent execution
- cd /tmp
- rm -R /tmp/DietPi-Update /tmp/DietPi-Patchfile
- # - Inform user to avoid confusion
echo ''
- G_DIETPI-NOTIFY 0 "DietPi has applied a new$BRANCH_INFO versioning system to the device. To allow DietPi-Update to use this new system, it will now restart.\n"
- # - Apply update forcefully, since user has already chosen to do so
- /DietPi/dietpi/dietpi-update 1
- # - Kill parental dietpi-update instance and exit this script to avoid obsolete update finish
- kill $PPID
- exit
+ G_DIETPI-NOTIFY 0 'DietPi has applied a new G_DIETPI_INSTALL_STAGE system to the device.'
+
+ #System already installed, re-run patch
+ if (( $( /DietPi/dietpi/.install_stage
+ Restart_DietPi_Update
+
+ #System updating for the 1st time. We need to reboot the system, to kill dietpi-software old code and reload the new one.
+ else
+
+ echo 0 > /DietPi/dietpi/.install_stage
+ G_WHIP_MSG 'A system reboot is required to update G_DIETPI_INSTALL_STAGE system. Once the system reboots, please login to continue setup.'
+ reboot
+
+ fi
fi
+
#/////////////////////////////////////////////////////////////////////////////////////
#Incremental patch system:
Incremental_Patch_System(){
@@ -109,7 +147,7 @@
# Kodi: https://github.com/Fourdee/DietPi/issues/1428
# Fail2Ban: https://github.com/Fourdee/DietPi/issues/1431
# Tonido: https://github.com/Fourdee/DietPi/issues/1432
- (( $G_DIETPI_INSTALL_STAGE == 1 )) && /DietPi/dietpi/dietpi-software reinstall 31 73 134
+ (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/dietpi-software reinstall 31 73 134
#-------------------------------------------------------------------------------
elif (( $G_DIETPI_VERSION_SUB == 1 )); then
@@ -176,8 +214,7 @@
fi
#-------------------------------------------------------------------------------
#Reinstalls:
- # NetData 1.9
- (( $G_DIETPI_INSTALL_STAGE == 1 )) && /DietPi/dietpi/dietpi-software reinstall 65
+ # # => v6.20 NetData 1.9
#-------------------------------------------------------------------------------
elif (( $G_DIETPI_VERSION_SUB == 2 )); then
@@ -206,13 +243,12 @@ _EOF_
cat << _EOF_ > /etc/systemd/system/rc-local.service
[Unit]
Description=rc.local backwards compatibility
-Requires=dietpi-boot.service dietpi-ramdisk.service
-After=dietpi-boot.service dietpi-ramdisk.service dietpi-ramlog.service dietpi-postboot.service
+After=dietpi-boot.service
[Service]
Type=idle
RemainAfterExit=yes
-ExecStart=/bin/bash -c '/etc/rc.local'
+ExecStart=/etc/rc.local
StandardOutput=tty
[Install]
@@ -222,7 +258,7 @@ _EOF_
systemctl enable rc-local.service
systemctl enable dietpi-postboot
- if (( $G_DIETPI_INSTALL_STAGE == 1 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[168\]=2' /DietPi/dietpi/.installed; then
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[168\]=2' /DietPi/dietpi/.installed; then
[[ -d /var/lib/dietpi/postboot.d ]] || mkdir /var/lib/dietpi/postboot.d
cat << _EOF_ > /var/lib/dietpi/postboot.d/moode
@@ -253,25 +289,25 @@ _EOF_
cat << _EOF_ > $G_ERROR_HANDLER_COMMAND
APT::Install-Recommends "false";
APT::Install-Suggests "false";
-#APT::AutoRemove::RecommendsImportant "false";
-#APT::AutoRemove::SuggestsImportant "false";
+APT::AutoRemove::RecommendsImportant "false";
+APT::AutoRemove::SuggestsImportant "false";
_EOF_
G_ERROR_HANDLER_EXITCODE=$?
G_ERROR_HANDLER
#-------------------------------------------------------------------------------
#Reinstalls:
- # Shairport-sync 3.1.7
+ # # => v6.5 Shairport-sync 3.1.7
# RPi Cam
# Aria2 for .conf addition: https://github.com/Fourdee/DietPi/issues/1575#issuecomment-370248708
- # Sonarr/Radarr: https://github.com/Fourdee/DietPi/issues/1566#issuecomment-369334473
- if (( $G_DIETPI_INSTALL_STAGE == 1 )); then
+ # # => v6.18 Sonarr/Radarr: https://github.com/Fourdee/DietPi/issues/1566#issuecomment-369334473
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )); then
# - RPi cam pre-patch
mv /var/www/dietpicam /var/www/rpicam &> /dev/null
mv $G_FP_DIETPI_USERDATA/dietpicam $G_FP_DIETPI_USERDATA/rpicam &> /dev/null
rm /var/www/rpicam/media &> /dev/null
- /DietPi/dietpi/dietpi-software reinstall 37 59 132 144 145
+ /DietPi/dietpi/dietpi-software reinstall 59 132
fi
#-------------------------------------------------------------------------------
@@ -328,7 +364,7 @@ _EOF_
#-------------------------------------------------------------------------------
#Service updates: https://dietpi.com/phpbb/viewtopic.php?f=11&t=1148&p=11322#p11322
- $(which mkdir) -p /var/tmp/dietpi/logs
+ $(command -v mkdir) -p /var/tmp/dietpi/logs
#-------------------------------------------------------------------------------
#Fix microcode installation based on image creation CPU instead of image target CPU: https://github.com/Fourdee/DietPi/pull/1596
if (( $G_HW_ARCH == 10 )); then
@@ -349,7 +385,7 @@ _EOF_
#-------------------------------------------------------------------------------
#Reinstalls
# UrBackupServer
- (( $G_DIETPI_INSTALL_STAGE == 1 )) && /DietPi/dietpi/dietpi-software reinstall 111
+ (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/dietpi-software reinstall 111
#-------------------------------------------------------------------------------
#Cron minutely support: https://github.com/Fourdee/DietPi/pull/1578
mkdir -p /etc/cron.minutely
@@ -373,7 +409,7 @@ _EOF_
if [[ -f /etc/dphys-swapfile ]]; then
swap_size=$(grep -m1 '^[[:blank:]]*CONF_SWAPSIZE=' /etc/dphys-swapfile | sed 's/^[^=]*=//')
- swap_location="$(grep -m1 '^[[:blank:]]*CONF_SWAPFILE=' /etc/dphys-swapfile | sed 's/^[^=]*=//')"
+ swap_location=$(grep -m1 '^[[:blank:]]*CONF_SWAPFILE=' /etc/dphys-swapfile | sed 's/^[^=]*=//')
fi
@@ -387,17 +423,17 @@ _EOF_
G_AGP dphys-swapfile
#-------------------------------------------------------------------------------
#Reinstalls
- # Shairport-sync: https://github.com/Fourdee/DietPi/issues/1620#issuecomment-373086888
+ # # => v6.20 Shairport-sync: https://github.com/Fourdee/DietPi/issues/1620#issuecomment-373086888
# Squeezebox server:
- # AmiBerry 2.18: https://github.com/Fourdee/DietPi/issues/1410#issuecomment-374060452
+ # # => v6.20 AmiBerry 2.18: https://github.com/Fourdee/DietPi/issues/1410#issuecomment-374060452
# Mopidy: https://github.com/Fourdee/DietPi/issues/1625
- # MPD: https://github.com/Fourdee/DietPi/issues/1614
- if (( $G_DIETPI_INSTALL_STAGE == 1 )); then
+ # # => v6.17 MPD: https://github.com/Fourdee/DietPi/issues/1614
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )); then
- $(which killall) -w squeezeboxserver &> /dev/null
- rm /var/lib/dietpi/dietpi-software/services/squeezeboxserver.service &> /dev/null
+ killall -qw squeezeboxserver
+ [[ -f /var/lib/dietpi/dietpi-software/services/squeezeboxserver.service ]] && rm /var/lib/dietpi/dietpi-software/services/squeezeboxserver.service
- /DietPi/dietpi/dietpi-software reinstall 35 37 118 128
+ /DietPi/dietpi/dietpi-software reinstall 35 118
fi
#-------------------------------------------------------------------------------
@@ -438,7 +474,7 @@ _EOF_
rm /etc/cron.d/make_nas_processes_faster &> /dev/null
#-------------------------------------------------------------------------------
#Add Dropbear ecdsa and dss host keys, if missing: https://github.com/Fourdee/DietPi/issues/1670
- if (( $G_DIETPI_INSTALL_STAGE == 1 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[104\]=2' /DietPi/dietpi/.installed; then
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[104\]=2' /DietPi/dietpi/.installed; then
[[ -f /etc/dropbear/dropbear_ecdsa_host_key ]] || dropbearkey -t ecdsa -f /etc/dropbear/dropbear_ecdsa_host_key &> /dev/null
[[ -f /etc/dropbear/dropbear_dss_host_key ]] || dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key &> /dev/null
@@ -483,7 +519,7 @@ Description=DietPi Deluged Service
[Service]
Type=simple
-ExecStart=$(which deluged) -d -l /var/log/deluged.log -L warning
+ExecStart=$(command -v deluged) -d -l /var/log/deluged.log -L warning
[Install]
WantedBy=multi-user.target
@@ -495,7 +531,7 @@ Description=DietPi Deluge-web Service
[Service]
Type=simple #forking causes systemd-tty-ask-password-agent hang
-ExecStart=$(which deluge-web) -l /var/log/deluge-web.log -L warning
+ExecStart=$(command -v deluge-web) -l /var/log/deluge-web.log -L warning
[Install]
WantedBy=multi-user.target
@@ -516,13 +552,13 @@ _EOF_
#-------------------------------------------------------------------------------
#Uninstalls:
# Removal of fbset on new installs: https://github.com/Fourdee/DietPi/issues/1716
- (( $G_DIETPI_INSTALL_STAGE <= 0 )) && apt-mark auto fbset
+ (( $G_DIETPI_INSTALL_STAGE == 0 )) && apt-mark auto fbset
#-------------------------------------------------------------------------------
#Reinstalls:
# XRDP: https://github.com/Fourdee/DietPi/issues/1727#issuecomment-383858979
- # AmiBerry 2.19: https://github.com/Fourdee/DietPi/issues/1707
+ # # => v6.20 AmiBerry 2.19: https://github.com/Fourdee/DietPi/issues/1707
# Pi-SPC
- (( $G_DIETPI_INSTALL_STAGE == 1 )) && /DietPi/dietpi/dietpi-software reinstall 29 108 166
+ (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/dietpi-software reinstall 29 166
#-------------------------------------------------------------------------------
#Pi-hole: Enable FTLDNS support by removing pihole-FTL from DietPi control: https://github.com/Fourdee/DietPi/pull/1714
systemctl enable pihole-FTL 2> /dev/null
@@ -607,56 +643,30 @@ _EOF_
#-------------------------------------------------------------------------------
#Reinstalls
# RPi (apply to all) LXDE missing icons under pcmanfm reinstall: https://github.com/Fourdee/DietPi/issues/1558#issuecomment-390328173
- # SubSonic/AirSonic
+ # # => v6.12 AirSonic
+ # SubSonic
# Cava
# CloudPrint
# TightVNC/VNC4/RealVNC: https://github.com/Fourdee/DietPi/pull/1798#issuecomment-392594878
- # Xserver: https://github.com/Fourdee/DietPi/issues/1823
- (( $G_DIETPI_INSTALL_STAGE == 1 )) && /DietPi/dietpi/dietpi-software reinstall 23 33 34 119 137 27 28 120 6
- #-------------------------------------------------------------------------------
- #Sickrage service update: https://github.com/Fourdee/DietPi/issues/1762
- if [[ -f /etc/systemd/system/sickrage.service ]]; then
-
- cat << _EOF_ > /etc/systemd/system/sickrage.service
-[Unit]
-Description=SickRage
-
-[Service]
-User=root
-Group=root
-Type=forking
-GuessMainPID=no
-TimeoutSec=infinity
-TimeoutStopSec=20
-Restart=always
-ExecStart=/usr/bin/python /etc/sickrage/SickBeard.py -q --daemon --nolaunch --datadir=$G_FP_DIETPI_USERDATA/sickrage
-
-[Install]
-WantedBy=multi-user.target
-_EOF_
-
- fi
+ # # => v6.19 Xserver: https://github.com/Fourdee/DietPi/issues/1823
+ (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/dietpi-software reinstall 23 27 28 34 119 120 137
#-------------------------------------------------------------------------------
#Initially allow non-root users to obtain network details as well: https://github.com/Fourdee/DietPi/commit/15c0d495c33d3091e219c87bb2d09a22f8d27e9c
- [[ -f /DietPi/dietpi/.network ]] && chmod 666 /DietPi/dietpi/.network
- [[ -f /boot/dietpi/.network ]] && chmod 666 /boot/dietpi/.network
+ chmod -f 666 /{DietPi,boot}/dietpi/.network
#-------------------------------------------------------------------------------
#Re-Run set uid for sudo: https://github.com/Fourdee/DietPi/issues/794#issuecomment-392335392
- chmod 4755 $(which sudo)
+ chmod 4755 $(command -v sudo)
#-------------------------------------------------------------------------------
#Removal due to changed file locations: https://github.com/Fourdee/DietPi/pull/1802
- rm /DietPi/dietpi/func/dietpi-set_core_environment &> /dev/null
- rm /boot/dietpi/func/dietpi-set_core_environment &> /dev/null
- rm /DietPi/dietpi/conf/cron.daily_dietpi &> /dev/null
- rm /boot/dietpi/conf/cron.daily_dietpi &> /dev/null
- rm /DietPi/dietpi/conf/cron.hourly_dietpi &> /dev/null
- rm /boot/dietpi/conf/cron.hourly_dietpi &> /dev/null
+ rm -f /{DietPi,boot}/dietpi/func/dietpi-set_core_environment
+ rm -f /{DietPi,boot}/dietpi/conf/cron.daily_dietpi
+ rm -f /{DietPi,boot}/dietpi/conf/cron.hourly_dietpi
rm /var/lib/dietpi/fs_partition_resize.sh &> /dev/null
rm /var/lib/dietpi/dietpi-software/services/kill-ssh-user-sessions-before-network.sh &> /dev/null
#-------------------------------------------------------------------------------
#Offer to change global and unix user passwords to make users aware of the existance or "dietpi" and how the dietpi.txt password is used.
# If already installed only, else, dietpi-software will handle this on first run, after the update
- (( $G_DIETPI_INSTALL_STAGE == 1 )) && /DietPi/dietpi/func/dietpi-set_software passwords
+ (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/func/dietpi-set_software passwords
elif (( $G_DIETPI_VERSION_SUB == 9 )); then
@@ -676,9 +686,8 @@ _EOF_
fi
#-------------------------------------------------------------------------------
#Reinstalls
- # GMrender: https://dietpi.com/phpbb/viewtopic.php?f=11&t=3900&p=12985#p12985
- # Xserver (ASUSTB GPU)
- (( $G_DIETPI_INSTALL_STAGE == 1 )) && /DietPi/dietpi/dietpi-software reinstall 163 6
+ # # => v6.19 GMrender: https://dietpi.com/phpbb/viewtopic.php?f=11&t=3900&p=12985#p12985
+ # # => v6.19 Xserver (ASUSTB GPU)
#-------------------------------------------------------------------------------
#DietPi-Backup rewrite, no longer supports older backups: https://github.com/Fourdee/DietPi/issues/1851
if [[ -f '/DietPi/dietpi/.dietpi-backup_settings' ]]; then
@@ -708,12 +717,7 @@ _EOF_
fi
#-------------------------------------------------------------------------------
#Remove config.txt for non-RPi devices: https://github.com/Fourdee/DietPi/pull/1863
- if (( $G_HW_MODEL >= 10 )); then
-
- [[ -f /DietPi/config.txt ]] && rm /DietPi/config.txt
- [[ -f /boot/config.txt ]] && rm /boot/config.txt
-
- fi
+ (( $G_HW_MODEL >= 10 )) && rm -f /{DietPi,boot}/config.txt
#-------------------------------------------------------------------------------
#Removal of NTP from dietpi-software
sed -i '/^aSOFTWARE_INSTALL_STATE\[106\]=/c\aSOFTWARE_INSTALL_STATE\[106\]=0' /DietPi/dietpi/.installed &> /dev/null
@@ -730,7 +734,7 @@ _EOF_
#ASUS TB fonts broken as /usr/share/font removed but pkg's still exist, need to also do a fresh PREP on this image
if (( $G_HW_MODEL == 52 )); then
- if (( $G_DIETPI_INSTALL_STAGE <= 0 )); then
+ if (( $G_DIETPI_INSTALL_STAGE == 0 )); then
apt-mark auto fonts-dejavu-core libfontconfig1 libfreetype6 fontconfig-config fontconfig xserver-*
@@ -750,7 +754,7 @@ _EOF_
elif (( $G_DIETPI_VERSION_SUB == 10 )); then
#-------------------------------------------------------------------------------
- echo 0 &> /dev/null
+ :
#-------------------------------------------------------------------------------
elif (( $G_DIETPI_VERSION_SUB == 11 )); then
@@ -767,35 +771,23 @@ _EOF_
# https://github.com/Fourdee/DietPi/issues/1877#issuecomment-403421942
# Items which run as own user:
# YMPD
- # MPD
+ # # => v6.17 MPD
# minidlna
# AirSonic
- # Sickrage
- # Sonarr
- # Radarr
+ # # => v6.18 Sonarr
+ # # => v6.18 Radarr
# NZBget
- # RoonBridge
+ # # => v6.18 RoonBridge
# RoonServer
- # GMrender
- # PlexPy
+ # # => v6.19 GMrender
+ # # => v6.15 PlexPy
# Koel
- # Deluge
- # O!MPD: https://github.com/Fourdee/DietPi/issues/1934#issuecomment-406059462
+ # # => v6.18 O!MPD: https://github.com/Fourdee/DietPi/issues/1934#issuecomment-406059462
# - NO REINSTALL: due to many changes, or, too much risk for existing user settings, fresh installs only
# CubeRite
# qBitTorrent
# tonido
- if (( $G_DIETPI_INSTALL_STAGE == 1 )); then
-
- #Moved to userdata folder, pre-reinstall to keep existing settings
- if [[ -d '/etc/sickrage' ]]; then
-
- G_RUN_CMD mv /etc/sickrage/* $G_FP_DIETPI_USERDATA/sickrage/
- rm -R /etc/sickrage
-
- G_WHIP_MSG "INFO:\n\nSickrage has been moved to the DietPi userdata directory:\n\n - /etc/sickrage > $G_FP_DIETPI_USERDATA/sickrage"
-
- fi
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )); then
if [[ -d '/root/.config/NzbDrone' ]]; then
@@ -820,7 +812,7 @@ _EOF_
fi
- /DietPi/dietpi/dietpi-software reinstall 32 128 39 33 116 144 145 149 121 154 163 146 143 45 129
+ /DietPi/dietpi/dietpi-software reinstall 32 33 39 143 149 154
# O!MPD requires libary refresh by end user
if grep -q '^aSOFTWARE_INSTALL_STATE\[129\]=2' /DietPi/dietpi/.installed; then
@@ -843,9 +835,7 @@ _EOF_
fi
sed -i '/[[:space:]]\/var\/log[[:space:]]/d' /etc/fstab
- cat << _EOF_ >> /etc/fstab
-tmpfs /var/log tmpfs defaults,size=${var_log_size_new}m,noatime,nodev,nosuid,mode=1777 0 0
-_EOF_
+ echo "tmpfs /var/log tmpfs defaults,size=${var_log_size_new}m,noatime,nodev,nosuid,mode=1777 0 0" >> /etc/fstab
fi
#-------------------------------------------------------------------------------
@@ -853,12 +843,12 @@ _EOF_
(( $G_DISTRO < 4 && $G_HW_ARCH == 3 )) && sed -i '/debian-security/d' /etc/apt/sources.list
#-------------------------------------------------------------------------------
#Fix Xserver uninstall issus by not purging dependencies, but leaving them for autoremove: https://github.com/Fourdee/DietPi/pull/1930/files
- local dpkg_list="$(dpkg --get-selections)"
+ local dpkg_list=$(dpkg --get-selections)
grep -q '^xinit[[:space:]]' <<< "$dpkg_list" && apt-mark auto xauth x11-common
grep -q '^mesa-utils-extra[[:space:]]' <<< "$dpkg_list" && apt-mark auto libgles2-mesa
#-------------------------------------------------------------------------------
#Reinstall net-tools as dependency, if HomeAssistant is installed. Thanks to @lupa18 for reporting this: https://github.com/Fourdee/DietPi/issues/1911
- if (( $G_DIETPI_INSTALL_STAGE == 1 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[157\]=2' /DietPi/dietpi/.installed; then
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[157\]=2' /DietPi/dietpi/.installed; then
G_AGI net-tools
@@ -872,7 +862,7 @@ _EOF_
rm -R /var/lib/dietpi/dietpi-ramlog/storage &> /dev/null
#-------------------------------------------------------------------------------
#Reinstall "netbase", in case of installed NFS client and/or server, to reenable NFSv3 support: https://github.com/Fourdee/DietPi/issues/1898
- if (( $G_DIETPI_INSTALL_STAGE == 1 )); then
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )); then
if grep -q '^aSOFTWARE_INSTALL_STATE\[109\]=2' /DietPi/dietpi/.installed ||
grep -q '^aSOFTWARE_INSTALL_STATE\[110\]=2' /DietPi/dietpi/.installed; then
@@ -960,7 +950,7 @@ _EOF_
#Encrypt and secure GLOBAL_PW used by DietPi-Software: https://github.com/Fourdee/DietPi/issues/2021
if [[ ! -r '/var/lib/dietpi/dietpi-software/.GLOBAL_PW.bin' ]]; then
- local pw_dietpi_software="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_GLOBAL_PASSWORD=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
+ local pw_dietpi_software=$(grep -m1 '^[[:blank:]]*AUTO_SETUP_GLOBAL_PASSWORD=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')
# - Failsafe, should never occur.
[[ $pw_dietpi_software ]] || pw_dietpi_software='dietpi'
@@ -997,8 +987,7 @@ _EOF_
fi
#-------------------------------------------------------------------------------
#Reinstalls:
- # NAA: https://dietpi.com/phpbb/viewtopic.php?f=11&t=4420&p=13914#p13914
- (( $G_DIETPI_INSTALL_STAGE == 1 )) && /DietPi/dietpi/dietpi-software reinstall 124
+ # # => v6.20 NAA: https://dietpi.com/phpbb/viewtopic.php?f=11&t=4420&p=13914#p13914
#-------------------------------------------------------------------------------
elif (( $G_DIETPI_VERSION_SUB == 14 )); then
@@ -1031,9 +1020,9 @@ _EOF_
fi
#-------------------------------------------------------------------------------
#Reinstalls:
- # MPD: https://github.com/Fourdee/DietPi/issues/2032#issuecomment-415559451
+ # # => v6.17 MPD: https://github.com/Fourdee/DietPi/issues/2032#issuecomment-415559451
# PlexPy: https://github.com/Fourdee/DietPi/issues/2047
- (( $G_DIETPI_INSTALL_STAGE == 1 )) && /DietPi/dietpi/dietpi-software reinstall 128 146
+ (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/dietpi-software reinstall 146
#-------------------------------------------------------------------------------
#Update DietPi-Sync save file to new format
if [[ -f /DietPi/dietpi/.dietpi-sync_settings ]] && ! grep -q '^FP_SOURCE=' /DietPi/dietpi/.dietpi-sync_settings; then
@@ -1043,7 +1032,6 @@ _EOF_
FP_SOURCE=$(sed -n 1p /DietPi/dietpi/.dietpi-sync_settings_bk)
FP_TARGET=$(sed -n 2p /DietPi/dietpi/.dietpi-sync_settings_bk)
SYNC_DELETE_MODE=$(sed -n 3p /DietPi/dietpi/.dietpi-sync_settings_bk)
-SYNC_COMPRESSION=$(sed -n 4p /DietPi/dietpi/.dietpi-sync_settings_bk)
SYNC_CRONDAILY=$(sed -n 5p /DietPi/dietpi/.dietpi-sync_settings_bk)
_EOF_
@@ -1060,18 +1048,18 @@ _EOF_
if [[ ! -f /var/lib/dietpi/dietpi-wifi.db ]]; then
cat << _EOF_ > /var/lib/dietpi/dietpi-wifi.db
-aWIFI_SSID[0]="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_SSID=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
-aWIFI_KEY[0]="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_KEY=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
-aWIFI_KEYMGR[0]="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_KEYMGR=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
-aWIFI_PROTO[0]="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_PROTO=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
-aWIFI_PAIRWISE[0]="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_PAIRWISE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
-aWIFI_AUTH_ALG[0]="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_AUTH_ALG=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
-aWIFI_EAP[0]="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_EAP=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
-aWIFI_IDENTITY[0]="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_IDENTITY=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
-aWIFI_PASSWORD[0]="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_PASSWORD=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
-aWIFI_PHASE1[0]="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_PHASE1=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
-aWIFI_PHASE2[0]="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_PHASE2=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
-aWIFI_CERT[0]="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_CERT=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
+aWIFI_SSID[0]='$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_SSID=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')'
+aWIFI_KEY[0]='$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_KEY=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')'
+aWIFI_KEYMGR[0]='$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_KEYMGR=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')'
+aWIFI_PROTO[0]='$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_PROTO=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')'
+aWIFI_PAIRWISE[0]='$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_PAIRWISE=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')'
+aWIFI_AUTH_ALG[0]='$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_AUTH_ALG=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')'
+aWIFI_EAP[0]='$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_EAP=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')'
+aWIFI_IDENTITY[0]='$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_IDENTITY=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')'
+aWIFI_PASSWORD[0]='$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_PASSWORD=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')'
+aWIFI_PHASE1[0]='$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_PHASE1=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')'
+aWIFI_PHASE2[0]='$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_PHASE2=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')'
+aWIFI_CERT[0]='$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_WIFI_CERT=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')'
_EOF_
# - Apply + init the remaninder of array (5) + set permissions on file
@@ -1082,9 +1070,6 @@ _EOF_
#Fix rare WiFi interface start issue: https://github.com/Fourdee/DietPi/issues/2074
sed -i '\|^[[:blank:]]ifconfig "$IFACE" up$|c\\t/sbin/ip link set dev "$IFACE" up' /etc/network/if-pre-up.d/wireless-tools &> /dev/null
#-------------------------------------------------------------------------------
- #Missing from PREP, and on ASUS TB image:
- 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
- #-------------------------------------------------------------------------------
elif (( $G_DIETPI_VERSION_SUB == 16 )); then
@@ -1171,11 +1156,9 @@ We strongly recommend you select "0 : Re-enable IPv6 on kernel level". By doing
fi
#-------------------------------------------------------------------------------
#Reinstalls:
- # MPD
- # Chromium: Update kiosk mode autostart script: https://github.com/Fourdee/DietPi/issues/2158
- if (( $G_DIETPI_INSTALL_STAGE == 1 )); then
-
- /DietPi/dietpi/dietpi-software reinstall 113 128
+ # # => v6.20 MPD
+ # # => v6.19 Chromium: Update kiosk mode autostart script: https://github.com/Fourdee/DietPi/issues/2158
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )); then
#Run Transmission and Plex Media Server as "dietpi" group: https://github.com/Fourdee/DietPi/issues/2067#issuecomment-427579779
if grep -q '^aSOFTWARE_INSTALL_STATE\[44\]=2' /DietPi/dietpi/.installed; then
@@ -1302,9 +1285,9 @@ _EOF_
# RoonBridge: https://community.roonlabs.com/t/dietpi-allo-units-not-getting-the-roonbridge-b167-update-from-b164/52503/10?u=dan_knight
# Radarr/lidarr/sonarr/jacket: https://github.com/Fourdee/DietPi/issues/2219
# Mosquitto: https://github.com/Fourdee/DietPi/issues/2243#issuecomment-439492463
- if (( $G_DIETPI_INSTALL_STAGE == 1 )); then
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )); then
- /DietPi/dietpi/dietpi-software reinstall 121 129 148 106 144 145 147 123
+ /DietPi/dietpi/dietpi-software reinstall 106 121 123 129 144 145 147 148
# - Switch to "mariadb" systemd service on Stretch+: https://github.com/Fourdee/DietPi/pull/2196
if (( $G_DISTRO > 3 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[88\]=2' /DietPi/dietpi/.installed; then
@@ -1317,7 +1300,7 @@ You will not face any practical differences, since both services start the same
fi
#-------------------------------------------------------------------------------
#systemd-logind required for shutdown options: https://github.com/Fourdee/DietPi/issues/2155#issuecomment-437702869
- if (( $G_DIETPI_INSTALL_STAGE == 1 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[31\]=2' /DietPi/dietpi/.installed; then
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[31\]=2' /DietPi/dietpi/.installed; then
systemctl unmask systemd-logind
@@ -1371,7 +1354,7 @@ You will not face any practical differences, since both services start the same
for i in "${!afp_config_remove[@]}"
do
- rm /DietPi/dietpi/conf/${afp_config_remove[$i]} /boot/dietpi/conf/${afp_config_remove[$i]} &> /dev/null
+ rm -f /{DietPi,boot}/dietpi/conf/${afp_config_remove[$i]}
done
@@ -1383,14 +1366,12 @@ You will not face any practical differences, since both services start the same
a2dissite owncloud
mv /etc/apache2/sites-available/owncloud.conf /etc/apache2/sites-available/dietpi-owncloud.conf
- a2ensite dietpi-owncloud
fi
if [[ -f /etc/apache2/sites-available/nextcloud.conf ]]; then
a2dissite nextcloud
mv /etc/apache2/sites-available/nextcloud.conf /etc/apache2/sites-available/dietpi-nextcloud.conf
- a2ensite dietpi-nextcloud
fi
if [[ -f /etc/apache2/sites-available/rutorrent.conf ]]; then
@@ -1413,7 +1394,8 @@ You will not face any practical differences, since both services start the same
done
# - Apply to Nginx vhost
- grep -q 'include /etc/nginx/sites-dietpi/\*\.config;' /etc/nginx/sites-available/default &> /dev/null && G_CONFIG_INJECT 'include /etc/nginx/sites-dietpi/\*\.config;' 'include /etc/nginx/sites-dietpi/*.conf;' /etc/nginx/sites-available/default
+ # - Move to v6.19 => v6.20 patch for users, which update directly from v6.19.5 to v6.20
+ #grep -q 'include /etc/nginx/sites-dietpi/\*\.config;' /etc/nginx/sites-available/default &> /dev/null && G_CONFIG_INJECT 'include /etc/nginx/sites-dietpi/\*\.config;' 'include /etc/nginx/sites-dietpi/*.conf;' /etc/nginx/sites-available/default
# - Kodi input rules
[[ -f /etc/udev/rules.d/99-input.rules ]] && mv /etc/udev/rules.d/99-input.rules /etc/udev/rules.d/99-dietpi-kodi.rules
#-------------------------------------------------------------------------------
@@ -1434,32 +1416,228 @@ You will not face any practical differences, since both services start the same
# Allo GUI: https://github.com/Fourdee/DietPi/issues/2305
# GMrender: Due to Allo GUI service enable failure.
# Xorg: XU4 conf
- (( $G_DIETPI_INSTALL_STAGE == 1 )) && /DietPi/dietpi/dietpi-software reinstall 48 113 160 163 6
+ # Pydio: https://github.com/Fourdee/DietPi/issues/2308
+ (( $G_DIETPI_INSTALL_STAGE == 2 )) && /DietPi/dietpi/dietpi-software reinstall 6 48 113 160 163
+ #-------------------------------------------------------------------------------
+
+ elif (( $G_DIETPI_VERSION_SUB == 19 )); then
+
+ #-------------------------------------------------------------------------------
+ #PB, fix kernel upgrades, switch from dev to stable and enable auto upgrades.
+ if (( $G_HW_MODEL == 44 )) && [[ ! -f /etc/armbian-release ]]; then
+
+ cat << _EOF_ > /etc/armbian-release
+# PLEASE DO NOT EDIT THIS FILE
+BOARD=pinebook-a64
+BOARD_NAME="Pinebook A64"
+BOARDFAMILY=sun50iw1
+VERSION=5.67
+LINUXFAMILY=sunxi64
+BRANCH=next
+ARCH=arm64
+IMAGE_TYPE=stable
+BOARD_TYPE=conf
+INITRD_ARCH=arm64
+KERNEL_IMAGE_TYPE=Image
+_EOF_
+ G_RUN_CMD apt-mark unhold linux-image-dev-sunxi64 linux-dtb-dev-sunxi64
+ G_AGP linux-image-dev-sunxi64 linux-dtb-dev-sunxi64
+ G_AGA
+ G_AGI linux-image-next-sunxi64 linux-dtb-next-sunxi64
+
+ fi
+ #-------------------------------------------------------------------------------
+ #rpi-update drop support info
+ if command -v rpi-update &> /dev/null && G_WHIP_YESNO '[INFO] RPi-Update detected\n\nIn our effort to improve system stability, and, offer software installations which build custom modules (eg: WireGuard), we can no longer support systems with non-stock-APT kernel installed (eg: rpi-update).\n\nWould you like to revert to the APT kernel now, ensuring stability and official DietPi system support?'; then
+
+ local rpi_firmware='raspberrypi-bootloader raspberrypi-kernel libraspberrypi-bin libraspberrypi0'
+ G_AGP rpi-update
+ command -v rpi-source &> /dev/null && rm $(command -v rpi-source)
+ G_AGI --reinstall $rpi_firmware
+ apt-mark unhold $rpi_firmware
+
+ fi
+ #-------------------------------------------------------------------------------
+ #Apply Nginx vhost patch: https://github.com/Fourdee/DietPi/pull/2327
+ # - Moved from v6.18 => v6.19 patch for users, which update directly from v6.19.5 to v6.20
+ grep -q 'include /etc/nginx/sites-dietpi/\*\.config;' /etc/nginx/sites-available/default &> /dev/null && G_CONFIG_INJECT 'include /etc/nginx/sites-dietpi/\*\.config;' 'include /etc/nginx/sites-dietpi/*.conf;' /etc/nginx/sites-available/default
+ #-------------------------------------------------------------------------------
+ #Migrate Blynk to new dir structure: https://github.com/Fourdee/DietPi/issues/2322
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )) && grep -q '^aSOFTWARE_INSTALL_STATE\[131\]=2' /DietPi/dietpi/.installed &&
+ [[ -d $G_FP_DIETPI_USERDATA/blynk && ! -d $G_FP_DIETPI_USERDATA/blynk/data ]]; then
+
+ mv $G_FP_DIETPI_USERDATA/blynk $G_FP_DIETPI_USERDATA/blynk_bak
+ mv /etc/blynkserver $G_FP_DIETPI_USERDATA/blynk
+ mv $G_FP_DIETPI_USERDATA/blynk/server.jar $G_FP_DIETPI_USERDATA/blynk/blynkserver.jar
+ mv $G_FP_DIETPI_USERDATA/blynk_bak/server.properties $G_FP_DIETPI_USERDATA/blynk/
+ mv $G_FP_DIETPI_USERDATA/blynk_bak $G_FP_DIETPI_USERDATA/blynk/data
+ G_CONFIG_INJECT 'data.folder=' "data.folder=$G_FP_DIETPI_USERDATA/blynk/data" $G_FP_DIETPI_USERDATA/blynk/server.properties
+
+ fi
+ #-------------------------------------------------------------------------------
+ #Grafana: Remove obsolete x86_64 APT source, reinstall below to apply official repo: https://github.com/Fourdee/DietPi/issues/2449
+ rm -f /etc/apt/sources.list.d/grafana*.list
+ #-------------------------------------------------------------------------------
+ # - Reinstalls
+ # Blynk: Apply new run user, update binary (jar)
+ # Deluge: https://github.com/Fourdee/DietPi/issues/2339
+ # Netdata: https://github.com/Fourdee/DietPi/pull/2337
+ # NAA Daemon: https://github.com/Fourdee/DietPi/issues/2387#issue-395321320
+ # MPD: https://github.com/Fourdee/DietPi/issues/2377
+ # Samba: https://github.com/Fourdee/DietPi/issues/2396#issuecomment-451701569
+ # Amiberry 2.24
+ # Shairport Sync: https://github.com/Fourdee/DietPi/issues/2439
+ # Grafana: https://github.com/Fourdee/DietPi/issues/2449
+ if (( $G_DIETPI_INSTALL_STAGE == 2 )); then
+
+ /DietPi/dietpi/dietpi-software reinstall 37 45 65 77 108 124 128 131
+
+ # - Samba: Link disk cache to RAM: https://github.com/Fourdee/DietPi/issues/2396
+ if grep -q '^aSOFTWARE_INSTALL_STATE\[96\]=2' /DietPi/dietpi/.installed; then
+
+ [[ -e /var/cache/samba ]] && rm -R /var/cache/samba
+ mkdir -p /var/run/samba-cache
+ ln -s /var/run/samba-cache /var/cache/samba
+ echo 'd /var/run/samba-cache - - - - -' > /etc/tmpfiles.d/dietpi-samba_cache.conf
+
+ fi
+
+ fi
#-------------------------------------------------------------------------------
#Docker fix on RPi due to faulty current "docker-ce" repo version: https://github.com/Fourdee/DietPi/issues/2282
local dpkg_out=''
- if (( G_HW_MODEL < 10 )) && dpkg_out="$(dpkg-query -s 'docker-ce' 2>&1)"; then
+ if (( $G_HW_MODEL < 10 )) && dpkg_out=$(dpkg-query -s 'docker-ce' 2>&1); then
- echo 'Package: docker-ce
+ echo 'Package: docker-ce
Pin: version 5:18.09.0~3-0~raspbian-stretch
Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix
- if grep -q '5:18.09.0~3-0~raspbian-stretch' <<< "$dpkg_out"; then
+ if grep -q '5:18.09.0~3-0~raspbian-stretch' <<< "$dpkg_out"; then
- G_DIETPI-NOTIFY 2 'Docker: Downgrading your "docker-ce" package to the last working version'
+ G_DIETPI-NOTIFY 2 'Docker: Downgrading your "docker-ce" package to the last working version'
G_AGI docker-ce=18.06.1~ce~3-0~raspbian
G_AGA
- fi
+ fi
+
+ fi
+ #-------------------------------------------------------------------------------
+ #DietPi file renaming/removal:
+ # - autologin.conf: https://github.com/Fourdee/DietPi/pull/2343
+ [[ -f /etc/systemd/system/getty@tty1.service.d/autologin.conf ]] && mv /etc/systemd/system/getty@tty1.service.d/autologin.conf /etc/systemd/system/getty@tty1.service.d/dietpi-autologin.conf
+ # - README.md: https://github.com/Fourdee/DietPi/pull/2341
+ [[ -f /boot/README.md ]] && mv /boot/README.md /boot/dietpi-README.md
+ # - kill-ssh-user-sessions-before-network: https://github.com/Fourdee/DietPi/pull/2357/commits/c8eb15c169cfaba69fec0b3e631e2241e0bdb7d5
+ systemctl disable kill-ssh-user-sessions-before-network 2> /dev/null
+ [[ -f /etc/systemd/system/kill-ssh-user-sessions-before-network.service ]] && rm /etc/systemd/system/kill-ssh-user-sessions-before-network.service
+ [[ -f /var/lib/dietpi/services/kill-ssh-user-sessions-before-network.sh ]] && rm /var/lib/dietpi/services/kill-ssh-user-sessions-before-network.sh
+ systemctl daemon-reload
+ systemctl enable dietpi-kill_ssh
+ # - dietpi-unsupported_terminal.sh: https://github.com/Fourdee/DietPi/issues/2347
+ [[ -f /etc/profile.d/dietpi-unsupported_terminal.sh ]] && rm /etc/profile.d/dietpi-unsupported_terminal.sh
+ # - Possible leftover from PREP:
+ rm -f /{DietPi,boot}/dietpi/pre-patch_file
+ # - dietpi/conf removal from RAMdisk: https://github.com/Fourdee/DietPi/pull/2393
+ rm -Rf /{DietPi,boot}/dietpi/conf
+ #-------------------------------------------------------------------------------
+ #.dietpi-autostart_index removal, if zero: https://github.com/Fourdee/DietPi/pull/2343
+ [[ -f /DietPi/dietpi/.dietpi-autostart_index ]] && (( $( 1 )); then
+
+ # - Last match is the correct one, added by "dietpi-set_hardware headless 1"
+ local current=$(grep '^[[:blank:]]*AUTO_SETUP_HEADLESS=' /DietPi/dietpi.txt | tail -1 | sed 's/^[^=]*=//')
+ sed -i '/^[[:blank:]]*AUTO_SETUP_HEADLESS=/d' /DietPi/dietpi.txt
+ echo "AUTO_SETUP_HEADLESS=$current" >> /DietPi/dietpi.txt
+
+ fi
+
+ # - Apply new headless mode method, if set
+ if grep -q '^[[:blank:]]*CONFIG_HDMI_OUTPUT=0' /DietPi/dietpi.txt; then
+
+ /DietPi/dietpi/func/dietpi-set_hardware headless 1
+
+ fi
+
+ # - Renamed to: AUTO_SETUP_HEADLESS (added by verify_dietpi.txt automatically)
+ sed -i '/CONFIG_HDMI_OUTPUT/d' /DietPi/config.txt
- fi
+ fi
+ #-------------------------------------------------------------------------------
+ #Buster: "systemd" does not depend on "procps" anymore, thus we need to set it manually installed, simply applied on all distro versions.
+ G_AGI procps
+ #-------------------------------------------------------------------------------
+ #Remove wireless-power setting from /etc/network/interfaces, if not supported by adapter/firmware: https://github.com/Fourdee/DietPi/issues/2198
+ iwconfig wlan$(sed -n 2p /DietPi/dietpi/.network) power off &> /dev/null || sed -i '/^wireless-power/d' /etc/network/interfaces
+ #-------------------------------------------------------------------------------
+ if (( $G_HW_MODEL == 43 )) && #$G_HW_MODEL == 42 || #Kernel panic...
+ [[ ! -f /etc/armbian-release ]]; then
+
+ G_WHIP_MSG "[INFO]:\nThe base image for $G_HW_MODEL_DESCRIPTION has been updated.\nPlease reinstall your system with the latest image from https://dietpi.com/download.\n\nYou can continue to use this existing installation, however, some kernel features may not be available."
+
+ fi
+ #-------------------------------------------------------------------------------
+ #Grafana port change
+ [[ -f /etc/grafana/grafana.ini ]] && G_WHIP_MSG '[INFO]:\nGrafana port has changed to 3001 (previously 3000).'
+ #-------------------------------------------------------------------------------
+ #Remove armbian banner/profiles left on ASUS TB image
+ rm -f /etc/profile.d/armbian-*
#-------------------------------------------------------------------------------
fi
#-------------------------------------------------------------------------------
- #NB: all if statements must contain at least one command. Prevents bash having a hissy fit :)
+ #NB: All if statements must contain at least one command. Prevents bash having a hissy fit :)
# The fastest dummy command is ":", which really does nothing ;).
+ #NBB: Avoid multiple reinstalls of same software ID. Check last column of table: https://github.com/Fourdee/DietPi/wiki/DietPi-Software-list
#-------------------------------------------------------------------------------
}
diff --git a/dietpi/postboot b/dietpi/postboot
index e94f1dfdac..0310887412 100644
--- a/dietpi/postboot
+++ b/dietpi/postboot
@@ -3,13 +3,24 @@
# Please do not manually edit this file, instead create your own code snipped within: /var/lib/dietpi/postboot.d/
# - Safe boot time to log
-awk '{print $1 " Seconds"}' /proc/uptime > /var/log/boottime &
+mawk '{print $1 " Seconds"}' /proc/uptime > /var/log/boottime &
# - Move all boot logs to disk
mv /tmp/dietpi-*.log /var/tmp/dietpi/logs/ &
-# - Start dietpi-services after regular boot
-(( $( /dev/null &
+
+ fi
+
+ # - Start dietpi-services after regular boot
+ /DietPi/dietpi/dietpi-services start
+
+fi
# - Execute users custom boot scripts
for f in /var/lib/dietpi/postboot.d/*
diff --git a/dietpi/pre-patch_file b/dietpi/pre-patch_file
index 20e40cd1d1..179ffb54dc 100644
--- a/dietpi/pre-patch_file
+++ b/dietpi/pre-patch_file
@@ -53,93 +53,8 @@
echo -e '[ \e[33mWARN\e[0m ] Pre-patch 1 | Clearing /var/log files to free up RAMlog space (<2MB) before update will continue'
/DietPi/dietpi/func/dietpi-logclear 1 || EXIT_CODE=1; break
- #-------------------------------------------------------------------------------
- # Pre-patch 2: Hotfix to apply new naming scheme for /etc/nginx/sites-dietpi/*.(config => conf): https://github.com/Fourdee/DietPi/issues/2325#issuecomment-444564109
- # Pre-patch 3: Fix "systemctl force-reload" error in DietPi-Software
- elif [[ $G_DIETPI_VERSION_SUB.$(sed -n 4p /DietPi/dietpi/.version) == '19.G_DIETPI_VERSION_RC=5' ]]; then
-
- if grep -q 'include /etc/nginx/sites-dietpi/\*\.config;' /etc/nginx/sites-available/default &> /dev/null; then
-
- echo -e '[ \e[1mINFO\e[0m ] Pre-patch 2 | Nginx: Hotfix to apply new naming scheme for /etc/nginx/sites-dietpi/*.(config => conf)'
- sed -i 's|include /etc/nginx/sites-dietpi/\*\.config;|include /etc/nginx/sites-dietpi/\*\.conf;|g' /etc/nginx/sites-available/default
- (( $? )) && echo -e '[\e[31mFAILED\e[0m] Pre-patch 2 | An error occurred while applying the fix to: /etc/nginx/sites-available/default
- - Please apply it manually. Replace the line:
- include /etc/nginx/sites-dietpi/*.config; with
- include /etc/nginx/sites-dietpi/*.conf;'
-
- fi
-
- echo -e '[ \e[1mINFO\e[0m ] Pre-patch 3 | DietPi-Software: Resolving "systemctl force-reload" error in case of inactive services'
- sed -Ei 's/G_RUN_CMD systemctl force-reload (lighttpd|nginx|apache2)/G_RUN_CMD systemctl restart \1/g' /DietPi/dietpi/dietpi-software
- (( $? )) && echo -e '[\e[31mFAILED\e[0m] Pre-patch 3 | An error occurred while applying the fix to: /DietPi/dietpi/dietpi-software
- - Please apply it manually. Replace the 3 lines:
- G_RUN_CMD systemctl force-reload lighttpd|nginx|apache2 with
- G_RUN_CMD systemctl restart lighttpd|nginx|apache2 respectively'
-
- sed -i '/G_DIETPI_VERSION_RC=/c\G_DIETPI_VERSION_RC=6' /DietPi/dietpi/.version
-
fi
- #-------------------------------------------------------------------------------
- # Pre-patch 4: Prevent netdata uninstall from breaking the system: https://github.com/Fourdee/DietPi/issues/2336
- # Pre-patch 5: Prevent APT upgrade to faulty docker-ce version on RPi: https://github.com/Fourdee/DietPi/issues/2282
- if [[ $G_DIETPI_VERSION_SUB.$(sed -n 4p /DietPi/dietpi/.version) == '19.G_DIETPI_VERSION_RC=6' ]]; then
-
- echo -e '[ \e[1mINFO\e[0m ] Pre-patch 4 | Netdata: Fixing a critical issue, where uninstalling netdata would break the system'
- sed -i 's/userdel -rf netdata/userdel netdata/g' /DietPi/dietpi/dietpi-software
- (( $? )) && echo -e '[\e[31mFAILED\e[0m] Pre-patch 4 | An error occurred while applying the fix to: /DietPi/dietpi/dietpi-software
- - Please apply it manually. Replace the line:
- userdel -rf netdata with
- userdel netdata'
-
- if (( $(sed -n 1p /DietPi/dietpi/.hw_model) < 10 )); then
-
- echo -e '[ \e[1mINFO\e[0m ] Pre-patch 5 | Docker: Prevent install of a faulty "docker-ce" version in their APT repository'
-
- if ! grep -q '/etc/apt/preferences.d/dietpi-docker_fix' /DietPi/dietpi/dietpi-software; then
-
- sed -i "\|INSTALL_URL_ADDRESS='https://get.docker.com'|a\echo 'Package: docker-ce\nPin: version 5:18.09.0~3-0~raspbian-stretch\nPin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix" /DietPi/dietpi/dietpi-software
- (( $? )) && echo -e '[\e[31mFAILED\e[0m] Pre-patch 5 | An error occurred while applying the fix to: /DietPi/dietpi/dietpi-software
- - Please apply it manually. Add the following lines after INSTALL_URL_ADDRESS='\''https://get.docker.com'\'':
- echo '\''Package: docker-ce
- Pin: version 5:18.09.0~3-0~raspbian-stretch
- Pin-Priority: -1'\'' > /etc/apt/preferences.d/dietpi-docker_fix'
- fi
-
- if dpkg_out="$(dpkg-query -s 'docker-ce' 2>&1)"; then
-
- echo 'Package: docker-ce
-Pin: version 5:18.09.0~3-0~raspbian-stretch
-Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix
-
- if grep -q '5:18.09.0~3-0~raspbian-stretch' <<< "$dpkg_out"; then
-
- echo -e '[ \e[1mINFO\e[0m ] Pre-patch 5 | Docker: Downgrading your "docker-ce" package to the last working version'
- apt-get install -y -qq --allow-downgrades --allow-change-held-packages --allow-unauthenticated docker-ce=18.06.1~ce~3-0~raspbian || EXIT_CODE=5
- apt-get autoremove --purge -y || EXIT_CODE=5
- (( $EXIT_CODE == 5 )) && echo -e '[\e[31mFAILED\e[0m] Pre-patch 5 | An error has occurred while attempting to downgrade your docker-ce version.
- - Please try to manually downgrade via:
- G_AGI docker-ce=18.06.1~ce~3-0~raspbian'
-
- fi
-
- fi
-
- fi
-
- sed -i '/G_DIETPI_VERSION_RC=/c\G_DIETPI_VERSION_RC=7' /DietPi/dietpi/.version
-
- # Quit update after applying hotfix pre-patches 2-4, which will be replaced by regular code and patch_file update with v6.20
- echo 0 > /DietPi/dietpi/.update_stage
- rm /DietPi/dietpi/.update_available
- /DietPi/dietpi/dietpi-services start
- echo -e '\n[ \e[32mOK\e[0m ] DietPi-Update will now exit. No reboot is required, no further update steps are done.
- - To apply the new version string to your terminal session, please manually run:
- source /DietPi/dietpi/func/dietpi-globals\n'
- kill $PPID
- exit
-
- fi
#-------------------------------------------------------------------------------
# Finished
echo -e " \e[1m$G_PROGRAM_NAME\e[0m
@@ -154,4 +69,4 @@ Pin-Priority: -1' > /etc/apt/preferences.d/dietpi-docker_fix
#-------------------------------------------------------------------------------
exit $EXIT_CODE
#-------------------------------------------------------------------------------
-}
+}
\ No newline at end of file
diff --git a/dietpi/preboot b/dietpi/preboot
index fdd4c33682..6e39320bc7 100644
--- a/dietpi/preboot
+++ b/dietpi/preboot
@@ -26,61 +26,53 @@
RPi_Set_Clock_Speeds(){
- #RPi's
- if (( $G_HW_MODEL < 10 )); then
-
- #If no overclocking is set. set values to current (used in dietpi-config as reference for overclocking / current values)
- if grep -q '^#over_voltage=' /DietPi/config.txt &&
- grep -q '^#arm_freq=' /DietPi/config.txt &&
- grep -q '^#core_freq=' /DietPi/config.txt &&
- grep -q '^#sdram_freq=' /DietPi/config.txt; then
-
- #RPi v1 - Set safe clock
- if (( $G_HW_MODEL < 2 )); then
-
- sed -i '/over_voltage=/c\over_voltage=2' /DietPi/config.txt
- sed -i '/arm_freq=/c\arm_freq=900' /DietPi/config.txt
- sed -i '/core_freq=/c\#core_freq=250' /DietPi/config.txt
- sed -i '/sdram_freq=/c\#sdram_freq=400' /DietPi/config.txt
-
- #Zero
- if [[ ${G_HW_MODEL_DESCRIPTION,,} == *'zero'* ]]; then
-
- sed -i '/over_voltage=/c\#over_voltage=0' /DietPi/config.txt
- sed -i '/arm_freq=/c\#arm_freq=1000' /DietPi/config.txt
- sed -i '/core_freq=/c\#core_freq=400' /DietPi/config.txt
- sed -i '/sdram_freq=/c\#sdram_freq=450' /DietPi/config.txt
-
- fi
-
- #RPi v2
- elif (( $G_HW_MODEL == 2 )); then
-
- sed -i '/over_voltage=/c\#over_voltage=0' /DietPi/config.txt
- sed -i '/arm_freq=/c\#arm_freq=900' /DietPi/config.txt
- sed -i '/core_freq=/c\#core_freq=250' /DietPi/config.txt
- sed -i '/sdram_freq=/c\#sdram_freq=450' /DietPi/config.txt
-
- #RPi v3
- elif (( $G_HW_MODEL == 3 )); then
-
- sed -i '/over_voltage=/c\#over_voltage=0' /DietPi/config.txt
- sed -i '/core_freq=/c\#core_freq=400' /DietPi/config.txt
- sed -i "/temp_limit=/c\temp_limit=75" /DietPi/config.txt # https://github.com/Fourdee/DietPi/issues/356
-
- local arm_freq=1200
- local sdram_freq=450
- if [[ ${G_HW_MODEL_DESCRIPTION,,} == *'rpi 3 model b+'* ]]; then
-
- arm_freq=1400
- sdram_freq=500
-
- fi
-
- sed -i "/arm_freq=/c\#arm_freq=$arm_freq" /DietPi/config.txt
- sed -i "/sdram_freq=/c\#sdram_freq=$sdram_freq" /DietPi/config.txt
-
- fi
+ #If no overclocking is set. set values to current (used in dietpi-config as reference for overclocking / current values)
+ if ! grep -q '^[[:blank:]]*over_voltage=' /DietPi/config.txt &&
+ ! grep -q '^[[:blank:]]*arm_freq=' /DietPi/config.txt &&
+ ! grep -q '^[[:blank:]]*core_freq=' /DietPi/config.txt &&
+ ! grep -q '^[[:blank:]]*sdram_freq=' /DietPi/config.txt; then
+
+ #Zero
+ if [[ ${G_HW_MODEL_DESCRIPTION,,} == *'zero'* ]]; then
+
+ sed -i '/over_voltage=/c\#over_voltage=0' /DietPi/config.txt
+ sed -i '/arm_freq=/c\#arm_freq=1000' /DietPi/config.txt
+ sed -i '/core_freq=/c\#core_freq=400' /DietPi/config.txt
+ sed -i '/sdram_freq=/c\#sdram_freq=450' /DietPi/config.txt
+
+ #RPi v1 - Set safe clock
+ elif (( $G_HW_MODEL < 2 )); then
+
+ G_CONFIG_INJECT 'over_voltage=' 'over_voltage=2' /DietPi/config.txt
+ G_CONFIG_INJECT 'arm_freq=' 'arm_freq=900' /DietPi/config.txt
+ sed -i '/core_freq=/c\#core_freq=250' /DietPi/config.txt
+ sed -i '/sdram_freq=/c\#sdram_freq=400' /DietPi/config.txt
+
+ #RPi v2
+ elif (( $G_HW_MODEL == 2 )); then
+
+ sed -i '/over_voltage=/c\#over_voltage=0' /DietPi/config.txt
+ sed -i '/arm_freq=/c\#arm_freq=900' /DietPi/config.txt
+ sed -i '/core_freq=/c\#core_freq=250' /DietPi/config.txt
+ sed -i '/sdram_freq=/c\#sdram_freq=450' /DietPi/config.txt
+
+ #RPi v3 B+
+ elif [[ ${G_HW_MODEL_DESCRIPTION,,} == *'rpi 3 model b+'* ]]; then
+
+ sed -i '/over_voltage=/c\#over_voltage=0' /DietPi/config.txt
+ sed -i '/core_freq=/c\#core_freq=400' /DietPi/config.txt
+ G_CONFIG_INJECT '/temp_limit=' 'temp_limit=75' /DietPi/config.txt # https://github.com/Fourdee/DietPi/issues/356
+ sed -i '/arm_freq=/c\#arm_freq=1400' /DietPi/config.txt
+ sed -i '/sdram_freq=/c\#sdram_freq=500' /DietPi/config.txt
+
+ #RPi v3
+ elif (( $G_HW_MODEL == 3 )); then
+
+ sed -i '/over_voltage=/c\#over_voltage=0' /DietPi/config.txt
+ sed -i '/core_freq=/c\#core_freq=400' /DietPi/config.txt
+ G_CONFIG_INJECT '/temp_limit=' 'temp_limit=75' /DietPi/config.txt # https://github.com/Fourdee/DietPi/issues/356
+ sed -i '/arm_freq=/c\#arm_freq=1200' /DietPi/config.txt
+ sed -i '/sdram_freq=/c\#sdram_freq=450' /DietPi/config.txt
fi
@@ -101,9 +93,9 @@
if [[ $autoinstall_timezone != $( /dev/null
- dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key &> /dev/null
- dropbearkey -t ecdsa -f /etc/dropbear/dropbear_ecdsa_host_key &> /dev/null
- dropbearkey -t dss -f /etc/dropbear/dropbear_dss_host_key &> /dev/null
+ rm -f /etc/dropbear/*_host_key
+ # Distro specific package and on Jessie, ECDSA is not created automatically
+ if (( $G_DISTRO < 4 )); then
+
+ dpkg-reconfigure -f noninteractive dropbear
+ dropbearkey -t ecdsa -f /etc/dropbear/dropbear_ecdsa_host_key
+
+ else
+
+ dpkg-reconfigure -f noninteractive dropbear-run
+
+ fi
# - Recreate machine-id: https://github.com/Fourdee/DietPi/issues/2015
- rm /etc/machine-id &> /dev/null
- rm /var/lib/dbus/machine-id &> /dev/null
+ [[ -f /etc/machine-id ]] && rm /etc/machine-id
+ [[ -f /var/lib/dbus/machine-id ]] && rm /var/lib/dbus/machine-id
systemd-machine-id-setup
# - Network setup
@@ -200,7 +203,7 @@
local static_gateway="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_STATIC_GATEWAY=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
local static_dns="$(grep -m1 '^[[:blank:]]*AUTO_SETUP_NET_STATIC_DNS=' /DietPi/dietpi.txt | sed 's/^[^=]*=//')"
- # Wifi
+ # WiFi
if (( $wifi_enabled )); then
#Enable Wlan, disable Eth
@@ -243,7 +246,7 @@
fi
- # - IPv6
+ # IPv6
local enable_ipv6=$(grep -ci -m1 '^[[:blank:]]*CONFIG_ENABLE_IPV6=1' /DietPi/dietpi.txt)
/DietPi/dietpi/func/dietpi-set_hardware enableipv6 $enable_ipv6
(( $enable_ipv6 )) && /DietPi/dietpi/func/dietpi-set_hardware preferipv4 $(grep -ci -m1 '^[[:blank:]]*CONFIG_PREFER_IPV4=1' /DietPi/dietpi.txt)
@@ -260,25 +263,14 @@
#Apply LED triggers if set
G_THREAD_START /DietPi/dietpi/func/dietpi-led_control 1
- #RPi Specials
- # set volume to -0.1db | We have to do it here because sound card modules (dietpi-set_hardware) are not enabled on the fly, requires a reboot.
- # Disable RPi hdmi output if set in dietpi.txt
- if (( $G_HW_MODEL < 10 )); then
-
- which amixer &> /dev/null && amixer set PCM -- -010
- if grep -qi '^[[:blank:]]*CONFIG_HDMI_OUTPUT=0' /DietPi/dietpi.txt; then
-
- /opt/vc/bin/tvservice -o &> /dev/null
-
- fi
-
- fi
+ #RPi: Set volume to -0.1db | We have to do it here because sound card modules (dietpi-set_hardware) are not enabled on the fly, requires a reboot.
+ (( $G_HW_MODEL < 10 )) && command -v amixer &> /dev/null && amixer set PCM -- -010
#-----------------------------------------------------------------------------------
#First run prep
if (( $G_DIETPI_INSTALL_STAGE == -1 )); then
- # - Set RPi v1 safe overclocking profile (900mhz)
- RPi_Set_Clock_Speeds
+ # - Set RPi v1 safe overclocking profile (900MHz) and apply commented defaults based on RPi model
+ (( $G_HW_MODEL < 10 )) && RPi_Set_Clock_Speeds
# - End user automated script
if [[ -f /boot/Automation_Custom_PreScript.sh ]]; then
@@ -287,8 +279,7 @@
local fp_dietpiautomation_custom_prescript_log='/var/tmp/dietpi/logs/dietpi-automation_custom_prescript.log'
chmod +x /boot/Automation_Custom_PreScript.sh
- /boot/Automation_Custom_PreScript.sh | tee $fp_dietpiautomation_custom_prescript_log
- if (( $? == 0 )); then
+ if /boot/Automation_Custom_PreScript.sh | tee $fp_dietpiautomation_custom_prescript_log; then
G_DIETPI-NOTIFY 0 'Custom script'
diff --git a/dietpi/server_version-6 b/dietpi/server_version-6
index 306010f750..e41a9a3b4a 100644
--- a/dietpi/server_version-6
+++ b/dietpi/server_version-6
@@ -1,3 +1,3 @@
6
-19
-7
+20
+5
diff --git a/rootfs/etc/bashrc.d/dietpi-unsupported_terminal.sh b/rootfs/etc/bashrc.d/dietpi-unsupported_terminal.sh
new file mode 100644
index 0000000000..760f9ad9a1
--- /dev/null
+++ b/rootfs/etc/bashrc.d/dietpi-unsupported_terminal.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# Workaround for SSH client passing an unsupported $TERM string: https://github.com/Fourdee/DietPi/issues/2034
+if [[ $SSH_TTY ]] && ! toe -a | grep -q "^$TERM[[:blank:]]"; then
+
+ TERM_old="$TERM"
+ ncurses_term=''
+
+ if [[ $TERM =~ 256 ]]; then
+
+ export TERM='xterm-256color'
+
+ else
+
+ export TERM='xterm'
+
+ fi
+
+ G_WHIP_MENU_ARRAY=('0' 'Ignore for now, I will change the SSH clients terminal.')
+
+ if ! dpkg-query -s ncurses-term &> /dev/null; then
+
+ ncurses_term=' or install the "ncurses-term" APT packages, which enables a wider terminal support'
+ G_WHIP_MENU_ARRAY+=('1' 'Install "ncurses-term" now to enable a wider terminal support.')
+ G_WHIP_DEFAULT_ITEM=1
+
+ fi
+
+ G_PROGRAM_NAME='Unsupported SSH client terminal' G_WHIP_MENU "[WARNING] Your SSH client passed an unsupported terminal: TERM=$TERM_old\n
+As a workaround we fooled the server by setting: TERM=$TERM. This is not the cleanest solution, since commands might expect colours or formats, that are not supported by the actual terminal.\n
+Please change your SSH clients terminal, respectively the passed \$TERM string$ncurses_term." && (( $G_WHIP_RETURNED_VALUE )) && G_AGI ncurses-term
+
+ unset TERM_old
+ unset ncurses_term
+
+fi
diff --git a/rootfs/etc/cron.daily/dietpi b/rootfs/etc/cron.daily/dietpi
index 751698c100..532e7745fa 100644
--- a/rootfs/etc/cron.daily/dietpi
+++ b/rootfs/etc/cron.daily/dietpi
@@ -20,16 +20,26 @@
fi
#----------------------------------------------------------------
- #check for dietpi updates
+ #Check/Update DietPi
if grep -qi '^[[:blank:]]*CONFIG_CHECK_DIETPI_UPDATES=1' /DietPi/dietpi.txt; then
- /DietPi/dietpi/dietpi-update 2 &> /dev/null &
+ # - Check and update
+ if grep -qi '^[[:blank:]]*CONFIG_AUTO_DIETPI_UPDATES=1' /DietPi/dietpi.txt; then
+
+ /DietPi/dietpi/dietpi-update 1
+
+ # - Check only
+ else
+
+ /DietPi/dietpi/dietpi-update 2 &> /dev/null &
+
+ fi
fi
#----------------------------------------------------------------
#DietPi-Sync daily
if [[ -f /DietPi/dietpi/.dietpi-sync_settings ]] &&
- (( $(sed -n 5p /DietPi/dietpi/.dietpi-sync_settings) == 1 )); then
+ grep -qi 'SYNC_CRONDAILY=1' /DietPi/dietpi/.dietpi-sync_settings; then
/DietPi/dietpi/dietpi-sync 1 &> /dev/null &
diff --git a/rootfs/etc/cron.hourly/dietpi b/rootfs/etc/cron.hourly/dietpi
index 35655c8599..dd0101edeb 100644
--- a/rootfs/etc/cron.hourly/dietpi
+++ b/rootfs/etc/cron.hourly/dietpi
@@ -10,12 +10,12 @@
#
#////////////////////////////////////
- LOGGING_MODE=0
if [[ -f '/DietPi/dietpi/.installed' ]]; then
LOGGING_MODE=$(grep -m1 '^[[:blank:]]*INDEX_LOGGING_CURRENT=' /DietPi/dietpi/.installed | sed 's/^[^=]*=//')
fi
+ LOGGING_MODE=${LOGGING_MODE:-0}
#----------------------------------------------------------------
# Main Loop
diff --git a/rootfs/etc/network/if-up.d/dietpi-disable_offload b/rootfs/etc/network/if-up.d/dietpi-disable_offload
index 599bd2dfa6..91861b58a0 100644
--- a/rootfs/etc/network/if-up.d/dietpi-disable_offload
+++ b/rootfs/etc/network/if-up.d/dietpi-disable_offload
@@ -24,7 +24,7 @@
#///////////////////////////////////////////////////////////////////////////////////
# Globals
#///////////////////////////////////////////////////////////////////////////////////
- CMD=$(which ethtool)
+ CMD=$(command -v ethtool)
EXIT_CODE=1
#///////////////////////////////////////////////////////////////////////////////////
diff --git a/rootfs/etc/profile.d/dietpi-unsupported_terminal.sh b/rootfs/etc/profile.d/dietpi-unsupported_terminal.sh
deleted file mode 100644
index 1064d56829..0000000000
--- a/rootfs/etc/profile.d/dietpi-unsupported_terminal.sh
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/bash
-
-# Workaround for SSH client passing an unsupported $TERM string: https://github.com/Fourdee/DietPi/issues/2034
-if [[ $SSH_TTY ]] && ! toe -a | grep -q "^$TERM[[:blank:]]"; then
-
- TERM_old="$TERM"
- ncurses_term=''
-
- if [[ $TERM =~ 256 ]]; then
-
- export TERM='xterm-256color'
-
- else
-
- export TERM='xterm'
-
- fi
-
- G_WHIP_MENU_ARRAY=('0' 'Ignore for now, I will change the SSH clients terminal.')
-
- if ! dpkg-query -s ncurses-term &> /dev/null; then
-
- ncurses_term=' or install the "ncurses-term" packages, which enables a wider terminal support'
- G_WHIP_MENU_ARRAY+=('1' 'Install "ncurses-term" now to add a wider terminal support.')
-
- fi
-
- G_WHIP_DEFAULT_ITEM=1
- G_PROGRAM_NAME='Unsupported SSH client terminal' G_WHIP_MENU "[WARNING] The terminal passed by your SSH client (TERM=$TERM_old) is not supported by this DietPi server.\n
-To enable usage, we were fooling the server by setting \"TERM=$TERM\". This is not the cleanest solution, since commands might expect colours or formats, that are not supported by the actual terminal.\n
-Please change your SSH clients terminal (passed $TERM string)$ncurses_term." && (( $G_WHIP_RETURNED_VALUE )) && G_AGI ncurses-term
-
- unset TERM_old
- unset ncurses_term
-
-fi
diff --git a/rootfs/etc/systemd/system/dietpi-boot.service b/rootfs/etc/systemd/system/dietpi-boot.service
index 2e25ef4cbd..a0c8804dc7 100644
--- a/rootfs/etc/systemd/system/dietpi-boot.service
+++ b/rootfs/etc/systemd/system/dietpi-boot.service
@@ -1,14 +1,15 @@
[Unit]
Description=DietPi-Boot
-#Order 3
+# Order 3
Requires=dietpi-preboot.service
-After=dietpi-preboot.service network-online.target network.target networking.service
+After=dietpi-preboot.service network.target networking.service
+Before=getty@tty1.service getty.target
[Service]
Type=oneshot
RemainAfterExit=yes
StandardOutput=tty
-ExecStart=/bin/bash -c '/DietPi/dietpi/boot | tee /tmp/dietpi-boot.log'
+ExecStart=/bin/bash -c '/DietPi/dietpi/boot 2>&1 | tee /tmp/dietpi-boot.log'
[Install]
WantedBy=multi-user.target
diff --git a/rootfs/etc/systemd/system/dietpi-fs_partition_resize.service b/rootfs/etc/systemd/system/dietpi-fs_partition_resize.service
index cde5f633a6..572445179c 100644
--- a/rootfs/etc/systemd/system/dietpi-fs_partition_resize.service
+++ b/rootfs/etc/systemd/system/dietpi-fs_partition_resize.service
@@ -1,12 +1,17 @@
[Unit]
-Description=dietpi-fs_partition_resize
-Before=dietpi-ramdisk.service
+Description=DietPi-FS_partition_resize
+# Order 0
+DefaultDependencies=false
+Wants=local-fs-pre.target
+After=systemd-remount-fs.service -.mount
+Before=var-swap.swap swap.target local-fs-pre.target
[Service]
Type=oneshot
RemainAfterExit=no
-ExecStart=/bin/bash -c '/var/lib/dietpi/services/fs_partition_resize.sh | tee /var/tmp/dietpi/logs/fs_partition_resize.log'
StandardOutput=tty
+ExecStartPre=/bin/mkdir -p /var/tmp/dietpi/logs
+ExecStart=/bin/bash -c '/var/lib/dietpi/services/fs_partition_resize.sh 2>&1 | tee /var/tmp/dietpi/logs/fs_partition_resize.log'
[Install]
WantedBy=local-fs.target
diff --git a/rootfs/etc/systemd/system/dietpi-kill_ssh.service b/rootfs/etc/systemd/system/dietpi-kill_ssh.service
new file mode 100644
index 0000000000..e5a7070d14
--- /dev/null
+++ b/rootfs/etc/systemd/system/dietpi-kill_ssh.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=DietPi-Kill_SSH on shutdown
+DefaultDependencies=no
+
+[Service]
+Type=oneshot
+ExecStart=-/usr/bin/killall -qw dropbear sshd
+
+[Install]
+WantedBy=poweroff.target halt.target reboot.target
diff --git a/rootfs/etc/systemd/system/dietpi-postboot.service b/rootfs/etc/systemd/system/dietpi-postboot.service
index 74fdc8849d..30c7672188 100644
--- a/rootfs/etc/systemd/system/dietpi-postboot.service
+++ b/rootfs/etc/systemd/system/dietpi-postboot.service
@@ -1,15 +1,14 @@
[Unit]
Description=DietPi-PostBoot
-#Order 4
+# Order 4
Requires=dietpi-boot.service
-After=dietpi-boot.service
-Before=rc-local.service rc.local.service
+After=dietpi-boot.service multi-user.target
[Service]
Type=idle
RemainAfterExit=yes
-ExecStart=/bin/bash -c '/DietPi/dietpi/postboot'
StandardOutput=tty
+ExecStart=/DietPi/dietpi/postboot
[Install]
WantedBy=multi-user.target
diff --git a/rootfs/etc/systemd/system/dietpi-preboot.service b/rootfs/etc/systemd/system/dietpi-preboot.service
index df6fbcbbfe..7421b66bb6 100644
--- a/rootfs/etc/systemd/system/dietpi-preboot.service
+++ b/rootfs/etc/systemd/system/dietpi-preboot.service
@@ -1,15 +1,16 @@
[Unit]
Description=DietPi-PreBoot
-#Order 2
+# Order 2
Requires=dietpi-ramdisk.service
-Before=network-pre.target
+Wants=network-pre.target
After=dietpi-ramdisk.service dietpi-ramlog.service
+Before=network-pre.target dropbear.service ssh.service
[Service]
Type=oneshot
RemainAfterExit=yes
StandardOutput=tty
-ExecStart=/bin/bash -c '/DietPi/dietpi/preboot | tee /tmp/dietpi-preboot.log'
+ExecStart=/bin/bash -c '/DietPi/dietpi/preboot 2>&1 | tee /tmp/dietpi-preboot.log'
[Install]
WantedBy=local-fs.target
diff --git a/rootfs/etc/systemd/system/dietpi-ramdisk.service b/rootfs/etc/systemd/system/dietpi-ramdisk.service
index e6e1b9e3ad..5b16df6ae3 100644
--- a/rootfs/etc/systemd/system/dietpi-ramdisk.service
+++ b/rootfs/etc/systemd/system/dietpi-ramdisk.service
@@ -1,15 +1,13 @@
[Unit]
Description=DietPi-RAMdisk
-#Order 1
-After=local-fs.target boot.mount tmp.mount
-Before=network-pre.target rsyslog.service syslog.service
+# Order 1
+Before=syslog.service rsyslog.service
[Service]
Type=forking
RemainAfterExit=yes
-StandardOutput=tty
ExecStartPre=/bin/mkdir -p /var/tmp/dietpi/logs
-ExecStart=/bin/bash -c '/boot/dietpi/func/dietpi-ramdisk 0 &>> /tmp/dietpi-ramdisk.log'
+ExecStart=/bin/bash -c '/boot/dietpi/func/dietpi-ramdisk 0 &>> /var/tmp/dietpi/logs/dietpi-ramdisk.log'
ExecStop=/bin/bash -c '/DietPi/dietpi/func/dietpi-ramdisk 1 &>> /var/tmp/dietpi/logs/dietpi-ramdisk.log'
[Install]
diff --git a/rootfs/etc/systemd/system/dietpi-ramlog.service b/rootfs/etc/systemd/system/dietpi-ramlog.service
index f904799d58..2bb1baa519 100644
--- a/rootfs/etc/systemd/system/dietpi-ramlog.service
+++ b/rootfs/etc/systemd/system/dietpi-ramlog.service
@@ -1,15 +1,13 @@
[Unit]
Description=DietPi-RAMlog
-#Order 1
-After=local-fs.target boot.mount tmp.mount
-Before=network-pre.target rsyslog.service syslog.service
+# Order 1
+Before=syslog.service rsyslog.service
[Service]
Type=forking
RemainAfterExit=yes
-StandardOutput=tty
ExecStartPre=/bin/mkdir -p /var/tmp/dietpi/logs
-ExecStart=/bin/bash -c '/boot/dietpi/func/dietpi-ramlog 0 &>> /tmp/dietpi-ramlog.log'
+ExecStart=/bin/bash -c '/boot/dietpi/func/dietpi-ramlog 0 &>> /var/tmp/dietpi/logs/dietpi-ramlog.log'
ExecStop=/bin/bash -c '/DietPi/dietpi/func/dietpi-ramlog 1 &>> /var/tmp/dietpi/logs/dietpi-ramlog.log'
[Install]
diff --git a/rootfs/etc/systemd/system/dietpi-wifi-monitor.service b/rootfs/etc/systemd/system/dietpi-wifi-monitor.service
index 76ee620962..63abfe5403 100644
--- a/rootfs/etc/systemd/system/dietpi-wifi-monitor.service
+++ b/rootfs/etc/systemd/system/dietpi-wifi-monitor.service
@@ -1,10 +1,13 @@
+# Monitors loss of WiFi connection and automatically reconnects
[Unit]
-Description=Monitors loss of WiFi connection and automatically reconnects
-After=network.target network-online.target
+Description=DietPi-WiFi-Monitor
+Requires=dietpi-ramdisk.service
+After=dietpi-boot.service network-online.target network.target
[Service]
-Type=simple
-ExecStart=/bin/bash -c /var/lib/dietpi/services/dietpi-wifi-monitor.sh
+ExecStartPre=/DietPi/dietpi/func/obtain_network_details
+ExecStartPre=/bin/bash -c '[[ -e /sys/class/net/wlan$(sed -n 2p /DietPi/dietpi/.network) ]]'
+ExecStart=/var/lib/dietpi/services/dietpi-wifi-monitor.sh
[Install]
WantedBy=multi-user.target
diff --git a/rootfs/etc/systemd/system/kill-ssh-user-sessions-before-network.service b/rootfs/etc/systemd/system/kill-ssh-user-sessions-before-network.service
deleted file mode 100644
index e0be9a353a..0000000000
--- a/rootfs/etc/systemd/system/kill-ssh-user-sessions-before-network.service
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=Shutdown all SSH sessions before network
-DefaultDependencies=no
-Before=network.target shutdown.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStart=/bin/bash -c '/var/lib/dietpi/services/kill-ssh-user-sessions-before-network.sh'
-
-[Install]
-WantedBy=poweroff.target halt.target reboot.target
diff --git a/dietpi/conf/cava.conf b/rootfs/var/lib/dietpi/dietpi-software/conf/cava.conf
similarity index 100%
rename from dietpi/conf/cava.conf
rename to rootfs/var/lib/dietpi/dietpi-software/conf/cava.conf
diff --git a/rootfs/var/lib/dietpi/services/dietpi-wifi-monitor.sh b/rootfs/var/lib/dietpi/services/dietpi-wifi-monitor.sh
index 89da4b7ed9..c950605f1a 100644
--- a/rootfs/var/lib/dietpi/services/dietpi-wifi-monitor.sh
+++ b/rootfs/var/lib/dietpi/services/dietpi-wifi-monitor.sh
@@ -9,6 +9,9 @@
G_INIT
#Import DietPi-Globals ---------------------------------------------------------------
+ #Update network info
+ /DietPi/dietpi/func/obtain_network_details
+
URL_PING=''
ADAPTER="wlan$(sed -n 2p /DietPi/dietpi/.network)"
TICKRATE=10
@@ -16,23 +19,30 @@
#-------------------------------------------------------------------------------------
#Main
#-------------------------------------------------------------------------------------
+ # Check for valid WiFi adapter
+ [[ -e /sys/class/net/$ADAPTER ]] || { echo "ERROR: No valid WiFi adapter found on interface: $ADAPTER. Exiting..."; exit 1; }
+
+ echo "Checking connnection for: $ADAPTER via ping to default gateway every $TICKRATE seconds"
+
while :
do
# - Get current gateway for ping
- URL_PING="$(ip r s 0.0.0.0/0 dev $ADAPTER | awk '{print $3}')"
+ URL_PING=$(ip r s 0.0.0.0/0 dev $ADAPTER | mawk '{print $3}')
- echo "Checking connnection for: $ADAPTER via ping to $URL_PING"
- if ping -I $ADAPTER -c 1 $URL_PING; then
+ [[ $G_DEBUG == 1 ]] && echo "Checking connnection for: $ADAPTER via ping to $URL_PING"
+ if ping -qI $ADAPTER -c 1 $URL_PING &> /dev/null; then
- echo "Connection valid for: $ADAPTER"
+ [[ $G_DEBUG == 1 ]] && echo "Connection valid for: $ADAPTER"
else
- echo "Detected connection loss: $ADAPTER. Reconnecting"
- ifdown "$ADAPTER"
+ [[ -e /sys/class/net/$ADAPTER ]] || { echo "ERROR: WiFi adapter has been unplugged: $ADAPTER. Exiting..."; exit 1; }
+
+ echo "Detected connection loss: $ADAPTER. Reconnecting..."
+ ifdown $ADAPTER
sleep 1
- ifup "$ADAPTER"
+ ifup $ADAPTER
echo 'Completed'
fi
diff --git a/rootfs/var/lib/dietpi/services/fs_partition_resize.sh b/rootfs/var/lib/dietpi/services/fs_partition_resize.sh
index 3a494d81d6..6d29603350 100644
--- a/rootfs/var/lib/dietpi/services/fs_partition_resize.sh
+++ b/rootfs/var/lib/dietpi/services/fs_partition_resize.sh
@@ -12,17 +12,17 @@ sync
TARGET_DEV=$(findmnt / -o source -n)
if [[ $TARGET_DEV =~ /mmcblk || $TARGET_DEV =~ /nvme ]]; then
- TARGET_PARTITION=${TARGET_DEV##*p} # Last [0-9] after "p"
- TARGET_DRIVE=${TARGET_DEV%p[0-9]} # EG: /dev/mmcblk[0-9]
+ TARGET_PARTITION=${TARGET_DEV##*p} # mmcblk0p1 => 1
+ TARGET_DRIVE=${TARGET_DEV%p[0-9]} # mmcblk0p1 => mmcblk0
elif [[ $TARGET_DEV =~ /[sh]d[a-z] ]]; then
- TARGET_PARTITION=${TARGET_DEV##*[a-z]} # Last [0-9]
- TARGET_DRIVE=${TARGET_DEV%[0-9]} # EG: /dev/sda
+ TARGET_PARTITION=${TARGET_DEV##*[a-z]} # /dev/sda1 => 1
+ TARGET_DRIVE=${TARGET_DEV%[0-9]} # /dev/sda1 => /dev/sda
else
- echo "[FAILED] Unsupported drive naming scheme: $TARGET_DEV"
+ echo "[FAILED] Unsupported drive naming scheme: $TARGET_DEV. Aborting..."
exit 1
fi
@@ -30,16 +30,6 @@ fi
# Only redo partitions, if drive actually contains a partition table.
if [[ $TARGET_PARTITION == [0-9] ]]; then
- # - Check for valid device ID
- # Do not fail due to RPi has autodetection of hw_model
- if ! HW_MODEL=$( /dev/null; then
-
- killall -w sshd
-
-elif pgrep 'dropbear' &> /dev/null; then
-
- killall -w dropbear
-
-fi
-
-exit 0