diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 353ac085ca..1c88b44422 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,82 @@ +v6.0 (previously v160) +(28/01/18) + +Important Information: +All DietPi images have been re-created. Existing installations (v159 or lower), can no longer be updated, or supported. To continue support, users must install the latest v6.0 image. + - https://github.com/Fourdee/DietPi/issues/1385 + - All images are now Debian Stretch (excluding Odroid's) + - ARMbian based images are now mainline kernel 4.13+. + - Native PC (EFI): is now an ISO, with clonezilla bundled. Simplifies installation via Rufus write: https://github.com/Fourdee/DietPi/issues/1171#issuecomment-336522021 + - If you are happy with your existing installation of v159 (or lower), you are not required to install the v6.0 image, however, we cannot continue to provide support for v159 (or lower) installations. + +Minor notes: +The XMAS tree has now been taken down, stored away on github history for next year. Hope you all had a good one :D + +Changes / Improvements / Optimizations: +General | DietPi RPi kernel, now reverted to stock RPi kernel: https://github.com/Fourdee/DietPi/issues/1378 +General | We have completed much needed backbone work for DietPi, which will allow for improved expansion in source code. This includes the use of dietpi-globals. +DietPi-Globals | New script which optimizes most used DietPi commands and vars, throughout our scripts. Also exported to bash session, please type 'G_' then press 'TAB' to see a full list of options: https://github.com/Fourdee/DietPi/issues/1311 +General | FHS compliance completed. /etc/dietpi has moved to /var/lib/dietpi. RAMlog store has moved to /var/tmp/dietpi: https://github.com/Fourdee/DietPi/issues/1297#issuecomment-352241193 +General | We have refreshed our terminal messages look & feel, oriented on RPi boot messages, and with process animation: https://github.com/Fourdee/DietPi/pull/1377 +General | wget: Now set to prefer IPv4 by default (generally faster, can be changed by 'CONFIG_PREFER_IPVERSION' in dietpi.txt): https://github.com/Fourdee/DietPi/issues/1285#issuecomment-353230187 +General | APT: Now set to force IPv4 by default (generally faster, can be changed by 'CONFIG_PREFER_IPVERSION' in dietpi.txt): https://github.com/Fourdee/DietPi/issues/1285#issuecomment-353230187 +General | SparkySBC: CPU gov default changed to Performance, reports of increased stability. +General | Swapfile generation is now completed during 1st run of dietpi-software (previously boot stage): https://github.com/Fourdee/DietPi/issues/1270#issue-278797206 +General | DietPi-Funtime: Removed from DietPi. Although it looked pretty, it did absolutely nothing (except slow down a program) +DietPi-Automation | All dietpi.txt entries have been renamed and cleaned up. +DietPi-Automation | dietpi.txt: CONFIG_NTP_MODE will now be applied during 1st run of device: https://github.com/Fourdee/DietPi/issues/1379 +DietPi-Boot | Improved the method of initial FS_partition and FS_expansion during 1st run, via systemD services. 'fs_force_resize=' in dietpi.txt is no longer supported: https://github.com/Fourdee/DietPi/issues/1285#issuecomment-352159930 +DietPi-Banner | IP: Will now also list the active network adapter used (eg: eth0/wlan0) +DietPi-Config | Dion Audio LOCO V1/V2: Soundcards added for RPi. +DietPi-Config | Locale: en_GB.UTF-8 is now automatically installed, alongside user selected choice. Required for DietPi scripts to function. +DietPi-Drive_Manager | Added support for exFAT, many thanks @MichaIng : https://github.com/Fourdee/DietPi/pull/1312 +DietPi-Globals | Global variables and functions are now exported during login. Please see the sourcecode for more information: https://github.com/Fourdee/DietPi/issues/1311 +DietPi-Set_Hardware | Sparky SBC: enable aotg.aotg1_speed compatibility setting for USB 1.1, when USB-DAC configured: https://github.com/Fourdee/DietPi/issues/1301 +DietPi-Set_Software | "pool" directive is now used for NTPD: https://github.com/Fourdee/DietPi/pull/1404 +DietPi-Software | NAA Daemon: Updated to latest (3.5.2-36). Existing installs will be patched automatically: https://github.com/Fourdee/DietPi/issues/1305 +DietPi-Software | PHP-FPM: Increased from "$CPU_CORES_TOTAL" to "pm.max_children = $(( $CPU_CORES_TOTAL * 3 ))". This should avoid failed forking of PHP-FPM processes/requests : https://github.com/Fourdee/DietPi/issues/1298 +DietPi-Software | ownCloud/Nextcloud: Added option to choose data directory via dietpi.txt pre installation: https://github.com/Fourdee/DietPi/issues/1314#issuecomment-352782055 +DietPi-Software | ownCloud/Nextcloud: Switch to pretty URLs (without "index.php") on Apache +DietPi-Software | ownCloud/Nextcloud: Automated backup restoring on install and creation und uninstall to ownCloud/Nextcloud data directory +DietPi-Software | ownCloud: Switch to non-package/archive installation. This allows usage of preferred web based updater. +DietPi-Software | Nextcloud: Resolved OPcache admin panel warnings now also on Lighttpd +DietPi-Software | UrBackup: Installation updated to latest version 2.1.20. For new installations only: https://github.com/Fourdee/DietPi/issues/1335 +DietPi-Software | NodeRed: Corrected user which nodered runs under, now runs as its own user, created during install: https://github.com/Fourdee/DietPi/issues/1294#issuecomment-354314318 +DietPi-Software | SqueezeBox/LMS (Stretch): Installation resolved: https://github.com/Fourdee/DietPi/issues/1124 +DietPi-Software | MySQL: Completely remove MySQL from DietPi in favour of MariaDB: https://github.com/Fourdee/DietPi/issues/1397 +DietPi-Software | Ampache: MySQL DB and configs have been updated (adds correct userdata folder for music by default): https://github.com/Fourdee/DietPi/issues/1420 +run_ntpd | Added support for systemd-timesyncd completion/detection: https://github.com/Fourdee/DietPi/issues/1379 + +Bug Fixes: +General | Fixed two systemd error messages during shutdown and boot: https://github.com/Fourdee/DietPi/issues/1330 +DietPi-Automation | Resolved an issue where AUTO_SETUP_TIMEZONE was not being applied correctly, thanks @k-plan: https://github.com/Fourdee/DietPi/issues/1285#issuecomment-356310496 +DietPi-Automation | dietpi.txt: CONFIG_NTP_MIRROR will now be applied to systemd-timesyncd configuration: https://github.com/Fourdee/DietPi/issues/1379 +DietPi-Config | Resolved an issue with WiFi Country code, failing to set on some devices: https://github.com/Fourdee/DietPi/issues/838 +DietPi-Config | Resolved an issue where disabling IPv6 didn't have an effect on AMD64 devices: https://github.com/Fourdee/DietPi/issues/1343#issuecomment-359652751 +DietPi-Services | dietpi-wifi-monitor: Is no longer controlled, to prevent WiFi drop during software installs/updates etc: https://github.com/Fourdee/DietPi/issues/1288#issuecomment-350653480 +DietPi-Software | General: MySQL using software titles now have their own database user, instead of accessing as "root": https://github.com/Fourdee/DietPi/issues/1397#issuecomment-359655198 +DietPi-Software | qBittorrent: Resolved an issue with inability to log into web interface: https://github.com/Fourdee/DietPi/issues/1366 +DietPi-Software | Resolved an issue where our custom LD_LIBRARY_PATH would cause APT failures. LD_LIBRARY_PATH has now been reverted, apologies if this effected your system: https://github.com/Fourdee/DietPi/issues/1329 +DietPi-Software | Resolved an issue where APT installations would fail if services were masked. All known DietPi software services, will be enabled/unmasked, before installation: https://github.com/Fourdee/DietPi/issues/1320 +DietPi-Software | WiFi Hotspot (Stretch): Resolved an issue where hostapd would fail to run due to missing libssl1.0.0 lib, not available in repos: https://github.com/Fourdee/DietPi/issues/1299 +DietPi-Software | Shairport-sync (Stretch): Resolved an issue where this would fail to install, due to pre-req URLS becomming invalid: https://github.com/Fourdee/DietPi/issues/1303 +DietPi-Software | Plex Media Server: Resolved uninstall to include /var/lib/plexmediaserver in removal (which is not completed via apt purge). +DietPi-Software | MariaDB: Resolved an issue where MariaDB would fail to uninstall correctly: https://github.com/Fourdee/DietPi/pull/1280 +DietPi-Software | Aira2 (Stretch): Resolved installation, now used APT installation: https://github.com/Fourdee/DietPi/issues/1310 +DietPi-Software | Mosquitto: Resolved various issues with failed install, due to Mosq repo not being maintained (deb's missing from repo header list, requires non-stretch available packages). deb's are now hosted on dietpi.com: https://github.com/Fourdee/DietPi/issues/1306 +DietPi-Software | ownCloud/Nextcloud: Fixed an installation issue on Jessie with MariaDB: https://github.com/Fourdee/DietPi/pull/1319 +DietPi-Software | Google AIY: Updated install to gitbranch=voicekit. Many thanks to @mpember for the heads up: https://github.com/Fourdee/DietPi/issues/1065#issuecomment-354304388 +DietPi-Software | OpenJDK: Replaces OracleJDK: https://github.com/Fourdee/DietPi/issues/1401 +DietPi-Update | dietpi.txt is now checked for missing entries, and, will now be patched during the update: https://github.com/Fourdee/DietPi/issues/1292#issuecomment-350818969 +Sparky SBC | Kernel updated, which resolves issues with HQPlayer playback: https://www.computeraudiophile.com/forums/topic/32132-allo-sparky-usbridge/?do=findComment&comment=753100 + +Allo Web Interface v5: +Sparky SBC: Matrix Audio X-SPDIF 2, native DSD is now added to kernel, many thanks @sudeep: https://github.com/sparkysbc/Linux/pull/3 + +----------------------------------------------------------------------------------------------------------- + v159 -(10/11/17) +(10/12/17) Image Modifications: VMWare | Updated to Debian Stretch: https://github.com/Fourdee/DietPi/issues/1219 @@ -10,7 +87,7 @@ Changes / Improvements / Optimizations: General | Odroid XU3/4 images updated: Includes kernel support for EMMC 5.1 (thanks Meveric): https://github.com/Fourdee/DietPi/issues/1252 General | DietPi RPi kernel: Updated to 4.9.62. General | DietPi RPi kernel: Will no longer re-install, if the current version is already at latest. -General | Added farenheit readouts for cpu_info and dietpi-config. For those "over the pond" :D : http://dietpi.com/phpbb/viewtopic.php?f=12&t=2516&p=9772#p9772 +General | Added fahrenheit readouts for cpu_info and dietpi-config. For those "over the pond" :D : http://dietpi.com/phpbb/viewtopic.php?f=12&t=2516&p=9772#p9772 General | Sparky SBC: Kernel update to add support for USB 1.1 DACs, thanks @sudeep. This must be enabled manually, if using a USB 1.1 DAC, as this breaks Allo WiFi dongle. Edit "/DietPi/uEnv.txt" and change the value "aotg.aotg1_speed=1" (from "0"), then reboot. General | We now define a default LD_LIBRARY_PATH for all systems, exported from /etc/bash.bashrc: https://github.com/Fourdee/DietPi/issues/475#issuecomment-350380744 DietPi-Services | Run "dietpi-services help" to see a full list of updated commands: Added support for "enable" and "disable". "disable" will stop and disable the service and prevent it from running, "enable" will enable and start the service. EG: "dietpi-services disable cron", will prevent Cron from starting. Added support for start/stop/restart a single service (eg: dietpi-services stop apache2). This is basically a symlink to systemD: https://github.com/Fourdee/DietPi/issues/1114 @@ -18,12 +95,12 @@ DietPi-Config | WiFi: Now uses the wpa_supplicant.conf method to setup WiFi conn DietPi-Backup | "Full Backup" Mode is now the default for fresh DietPi installations. This is mainly due to MySQL data now being in the DietPi userdata directory. DietPi-Config | Tools > Benchmarks: Added ability to benchmark CPU performance based on bash + integer: https://github.com/Fourdee/DietPi/issues/1253#issuecomment-346881878 DietPi-Config | Time sync modes: NTP is now uninstalled when SystemD timedatectl is enabled. Reinstalled on demand. Timedatectl pool servers are now also set: https://github.com/Fourdee/DietPi/issues/1208#issuecomment-343762480 -DietPi-Software | First run setup, now logged to /etc/dietpi/logs/dietpi-firstrun-setup.log. -DietPi-Software | APT log: Moved to /etc/dietpi/logs/dietpi-software_apt.log, to prevent RAMlog clearing log during automated installations. +DietPi-Software | First run setup, now logged to /var/tmp/dietpi/logs/dietpi-firstrun-setup.log. +DietPi-Software | APT log: Moved to /var/tmp/dietpi/logs/dietpi-software_apt.log, to prevent RAMlog clearing log during automated installations. DietPi-Software | MPD (Stretch): Install updated to 0.20.11. Also supports native DSD playback (thanks to @sudeep and PJotr), when "Native" output freq/bit is set: https://github.com/Fourdee/DietPi/issues/1236 DietPi-Software | moOde: MPD now installed via pre-built binaries. Will reduce install time: https://github.com/Fourdee/DietPi/issues/1223#issuecomment-345265290 -DietPi-Software | Nextcloud: Correct database access issue for MariaDB + minor fixes: https://github.com/Fourdee/DietPi/pull/1242 -DietPi-Software | ownCloud: Installation fixed, respecting different distro repos: https://github.com/Fourdee/DietPi/pull/1243 +DietPi-Software | Nextcloud: Large installation rework, featuring redis file locking, system cron jobs, automatic maintenance, optimized webserver stack configs and others: https://github.com/Fourdee/DietPi/issues/1067 +DietPi-Software | ownCloud: Large installation rework, providing same state than Nextcloud. DietPi-Software | MPD (inc YMPD/O!MPD): Default data directory is now "/mnt", this will include all USB drives and network locations: https://github.com/Fourdee/DietPi/issues/1202 DietPi-Software | Mopidy: Default data directory is now "/mnt", this will include all USB drives and network locations. DietPi-Software | Syncthing: Installation updated to version 0.14.40, for new installations only. Removal of inotify (now included in main syncthing): https://github.com/Fourdee/DietPi/issues/1260 @@ -105,8 +182,8 @@ General | Ondemand is now the default CPU governor for all devices. Previously I General | Improved notifications for when DietPi is installing system with automated flags. General | DietPi RPi Kernel: Updated to 4.9.52 General | RPi Stretch: Updated, matching official release of 2017-09-07-raspbian-stretch-lite -General | DietPi-Automation: "AUTO_Global_Password=" in "dietpi.txt" will also be applied to the "dietpi" user account. Please note this will only take effect on v157 and higher DietPi images, due to "boot" script requiring an update: https://github.com/Fourdee/DietPi/issues/1134 -DietPi-Update | Added logging for updates > /etc/dietpi/logs/dietpi-update.log +General | DietPi-Automation: "AUTO_SETUP_GLOBAL_PASSWORD=" in "dietpi.txt" will also be applied to the "dietpi" user account. Please note this will only take effect on v157 and higher DietPi images, due to "boot" script requiring an update: https://github.com/Fourdee/DietPi/issues/1134 +DietPi-Update | Added logging for updates > /var/tmp/dietpi/logs/dietpi-update.log DietPi-LetsEncrypt | Added support for Nginx on Stretch. Many thanks to @Bridouz for contributing this: https://github.com/Fourdee/DietPi/pull/1166 DietPi-Software | Apache2 + NextCloud: Various optimizations. For new installations only. Many thanks to @MichaIng for this contribution: https://github.com/Fourdee/DietPi/issues/1067 DietPi-Software | Allo Web Interface: Hidden from software list for now, please use pre-made images: http://dietpi.com/phpbb/viewtopic.php?f=8&t=2317#p8868 @@ -168,9 +245,6 @@ New Image: Rock64 | Now available for beta testing: https://github.com/Fourdee/DietPi/issues/1102#issuecomment-325131437 Changes / Improvements / Optimizations: -General | RPi: Kernel updated to 4.9.40. Includes improved driver support for Allo Piano and DiGi One: https://github.com/raspberrypi/linux/pull/2149 -General | dietpi.txt: Added an dev option to force a resize + expansion on rootfs partition for next boot (fs_force_resize=1) -General | RT kernel for RPi is now available, can be installed with "/DietPi/dietpi/func/dietpi-set_hardware kernel dietpi_rpi_rt" General | Reworked the disabled modules for Sparky. Disables touchscreen and GPU modules (thanks @sudeep). General | Sparky Image updated to Stretch, includes kernel update for DSD256/512 support. DietPi-Config | Networking > WiFi: Added a feature which will monitor the Wifi connection and automatically reconnect, if the gateway is unavailable (eg: connection drop): https://github.com/Fourdee/DietPi/issues/1074 @@ -324,7 +398,7 @@ General | ASUS TB: Image has been updated, brings it up to Debian Stretch and la General | Stretch: Now installs Chromium via apt. General | DietPi RPi Kernel: Updated to 4.9: https://github.com/Fourdee/DietPi/issues/936 General | rpi_boardinfo: Has been removed from DietPi scripts. Now contained within dietpi-obtain_hw_model: https://github.com/Fourdee/DietPi/issues/936#issuecomment-301055299 -DietPi-Autostart | Added ability to select "custom", editing script located in /etc/dietpi/autostart.sh, to launch any command during boot: https://github.com/Fourdee/DietPi/issues/916 +DietPi-Autostart | Added ability to select "custom", editing script located in /var/lib/dietpi/dietpi-autostart/custom.sh, to launch any command during boot: https://github.com/Fourdee/DietPi/issues/916 DietPi-Config | Display Options: Added ability to enter MPEG2/VC1 keys for RPi: https://github.com/Fourdee/DietPi/issues/885 DietPi-Config | WiFi Hotspot: Added ability to toggle on/off state of hotspot: https://github.com/Fourdee/DietPi/issues/924 DietPi-Drive_Manager | Added support for setting Read Only/Read Write filesystems: https://github.com/Fourdee/DietPi/issues/229 @@ -338,7 +412,7 @@ DietPi-Software | Blynk Server: Updated to latest version (0.24) for new install DietPi-Software | UrBackupSrv: Updated to latest version (2.1.19) for new installations only. Thanks @mtdjr : https://github.com/Fourdee/DietPi/issues/948 Bug fixes: -General | RPi: HW_MODEL_INDEX detection has changed. Now uses revision codes pulled from /proc/cpuinfo. This is mainly to support 4.9 kernel which lacks correct BCM code we previously used: https://github.com/Fourdee/DietPi/issues/936 +General | RPi: G_HW_MODEL_INDEX detection has changed. Now uses revision codes pulled from /proc/cpuinfo. This is mainly to support 4.9 kernel which lacks correct BCM code we previously used: https://github.com/Fourdee/DietPi/issues/936 General | If NTPD has not been run, it will be launched automatically, before waiting for status completion: https://github.com/Fourdee/DietPi/issues/919 General | Resolved an issue with incorrect temp readouts on H3/H2+ and NanoPi M2/M3 boards. Many thanks to @hectorcamp for the report: https://github.com/Fourdee/DietPi/issues/909 General | RPi kernel is now overwritten without cleanup, to prevent failed unzip (0bytes free space) rendering system unbootable: https://github.com/Fourdee/DietPi/issues/905 @@ -367,7 +441,7 @@ DietPi-Config | Display Rotation: New options for RPi HDMI output and Touchscree DietPi-Config | Hostname change: Now prompts for immediate reboot. This is to avoid potential issues with software installations and non-updated hostname on system. Many thanks to @9H5G for the suggestion: https://github.com/Fourdee/DietPi/issues/880 DietPi-Config | Audio > Sound Card: Updated hifiberry-dac to include HiFiBerry MiniAMP, many thanks to ta11 for the info: https://twitter.com/ta11/status/852599202186227712 DietPi-Config | Swapfile: Added ability to select Auto size (1GB - total RAM = size). Auto is now the default. Mainly to prevent out of memory errors on recent influx of 256MB boards. -DietPi-Obtain_Hw_Model | Optimized/reduced count of total HW_ARCH (from 21 to 10). Will improve performance in DietPi-Software due to reduced array size. +DietPi-Obtain_Hw_Model | Optimized/reduced count of total G_HW_ARCH (from 21 to 10). Will improve performance in DietPi-Software due to reduced array size. DietPi-RAMlog | PiHole: PiHole FTL log file is now excluded from 1 hour clear (preserves current day logs): https://github.com/Fourdee/DietPi/issues/868 DietPi-Software | Amiberry SDL2: Now available for installation. SDL2 Amiberry is currently in dev/testing. can be enabled with dietpi-autostart and selecting SDL2 option. Roughly 2x FPS increase over SDL1: https://github.com/Fourdee/DietPi/issues/850 DietPi-Software | VirtualHere: Now available for installation. Allows you to access psychically attached USB devices, over the network: http://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=6709#p6709 @@ -379,7 +453,7 @@ DietPi-Software | AmiBerry: Renamed all references of uae4arm to AmiBerry: https DietPi-Software | NAA Daemon: Updated to latest version (3.5.1-35). Many thanks to volpone for the heads up: http://dietpi.com/phpbb/viewtopic.php?f=11&t=1832 General | DietPi RPi Kernel: Now supports 384KHz audio output. Tested with Allo BOSS DAC and JustBoom-DAC: https://github.com/Fourdee/DietPi/issues/900#issuecomment-297775790 General | ARMbian built images: Console boot verbosity increase. -General | DietPi user: Now created for testing "dietpi". We are aiming to phase out root with our DietPi user in the future, currently, this account is for testing/debugging only. Default password is "dietpi" if "AUTO_Global_Password=" is unchanged in dietpi.txt: https://github.com/Fourdee/DietPi/issues/796 +General | DietPi user: Now created for testing "dietpi". We are aiming to phase out root with our DietPi user in the future, currently, this account is for testing/debugging only. Default password is "dietpi" if "AUTO_SETUP_GLOBAL_PASSWORD=" is unchanged in dietpi.txt: https://github.com/Fourdee/DietPi/issues/796 General | RPi Jessie: Image updated to latest General | AmiBerry: Image updated to latest @@ -604,7 +678,7 @@ DietPi-Software | UrBackup Server: Updated to latest version (2.0.38). Applies t Bug fixes: DietPi-Automation | Resolved an issue where static IPs were not being applied during 1st run dietpi-update stage. This fix applies to v140 and higher images: https://github.com/Fourdee/DietPi/issues/660 DietPi-Software | Resolved an issue where the DietPi installed version of Chromium was being overwritten by Debian repo during dist-upgrade: https://github.com/Fourdee/DietPi/issues/658 -DietPi-Software | Resolved an issue where custom global password ('AUTO_Global_Password=') was not being used as MySQL login password, causing MySQL DB creations to fail: https://github.com/Fourdee/DietPi/issues/666 +DietPi-Software | Resolved an issue where custom global password ('AUTO_SETUP_GLOBAL_PASSWORD=') was not being used as MySQL login password, causing MySQL DB creations to fail: https://github.com/Fourdee/DietPi/issues/666 DietPi-Software | Resolved an issue where LMS failed to installed on Odroid C2: https://github.com/Fourdee/DietPi/issues/663 General | apt-transport-https: Is now installed by default on all devices. Required for https apt usage and resolves issues with apt simulation failing: https://github.com/Fourdee/DietPi/issues/669 @@ -630,7 +704,7 @@ Bug fixes: DietPi-Cloudshell | Resolved an issue where Cloudshell would fail to start, due to tput failing the service on some devices. Many thanks to @Fabian0587, @rooted and @Saturn7 for their valuable assistance with testing: https://github.com/Fourdee/DietPi/issues/649 DietPi-Software | Wordpress: Resolved an issue where php-mysql module was not installed in some instances. Many thanks to @prp2 for reporting this: http://dietpi.com/phpbb/viewtopic.php?f=11&t=1026&p=4434#p4407 DietPi-Software | Plex Media Server: Is now disabled for ARMv6 devices. This is due to available repos removing support/packages for ARMv6 devices: https://github.com/Fourdee/DietPi/issues/648 -DietPi-Software | 'AUTO_Global_Password=' in dietpi.txt: Is now also applied as the password for generated MySQL databases. +DietPi-Software | 'AUTO_SETUP_GLOBAL_PASSWORD=' in dietpi.txt: Is now also applied as the password for generated MySQL databases. DietPi-Services | RPImonitor: This service is now triggered. Many thanks to K-Plan for reporting this. General | C2: Resolved an issue where libc6 u6 is required, but u7 was installed: https://github.com/Fourdee/DietPi/issues/653 @@ -791,9 +865,9 @@ DietPi-Config | Added ability to tweak Ondemand sampling rates in the performanc DietPi-Drive_Manager | To support large filesystems, GPT is now the default paritition table type on format, (previously MBR). Many thanks to Zone22: https://github.com/Fourdee/DietPi/issues/531 DietPi-Drive_Manager | Current userdata location is now shown in the main menu. DietPi-Set_Cpu | If the target CPU gov is not available on the system, an alternative will be set and saved automatically. -DietPi-Automation | Added a global password var (AUTO_Global_Password=) in dietpi.txt, which will be applied to root login, and, during dietpi-software installations, for all software that use a password: https://github.com/Fourdee/DietPi/issues/533 +DietPi-Automation | Added a global password var (AUTO_SETUP_GLOBAL_PASSWORD=) in dietpi.txt, which will be applied to root login, and, during dietpi-software installations, for all software that use a password: https://github.com/Fourdee/DietPi/issues/533 DietPi-Automation | Added filesystem format type for USB drive format (AUTO_Dedicated_Usb_Drive_Format_Filesystem=) in dietpi.txt: https://github.com/Fourdee/DietPi/issues/537 -DietPi-Automation | Added ability to force ethernet link speeds on 1st run (Ethernet_Force_Speed=) in dietpi.txt: https://github.com/Fourdee/DietPi/issues/544#issuecomment-252068249 +DietPi-Automation | Added ability to force ethernet link speeds on 1st run (AUTO_SETUP_NET_ETH_FORCE_SPEED=) in dietpi.txt: https://github.com/Fourdee/DietPi/issues/544#issuecomment-252068249 General | Interactive is now the default CPU gov, provides improved response times: https://github.com/Fourdee/DietPi/issues/535 General | Ethtool is now installed by default. Mainly used to provide a workaround for known HW failure Pine A64 1Gbit boards: https://github.com/Fourdee/DietPi/issues/544#issuecomment-252068249 @@ -951,7 +1025,7 @@ v126 Changes / Improvements / Optimizations: DietPi-Software | Coding improvements to allow for command line inputs and automated installations. General | Updated my email address in all source code (daniel.knight[at]dietpi.com). -DietPi-Automation | Simplified automation code. One variable to enable automated installation "AUTO_Install_Enable=1" in dietpi.txt. This will now enable a completely automated installation, with no user inputs. This feature requires a v126 image or higher, v126+ images will be available at a later date. +DietPi-Automation | Simplified automation code. One variable to enable automated installation "AUTO_SETUP_AUTOMATED=1" in dietpi.txt. This will now enable a completely automated installation, with no user inputs. This feature requires a v126 image or higher, v126+ images will be available at a later date. Bug fixes: DietPi-Software | Gogs: Resolved an issue where missing binary ssh-keygen would cause gogs service to fail: https://github.com/Fourdee/DietPi/issues/442. OpenSSH needs to be installed. @@ -1206,7 +1280,7 @@ DietPi-Software | Resolved an issue where NODEJS was not being set to "installed DietPi-Software | Resolved an issue where NODEJS would not install on Odroid C2. We have compiled a ARM64.deb package and will be used in new installations: https://github.com/Fourdee/DietPi/issues/276#issuecomment-209900955 General | Resolved an issue where WiFi WPA connections were unable to connect on the Odroid C1. General | Resolved various issues with non-English system Locale when using English based parsing throughout DietPi scripts: https://github.com/Fourdee/DietPi/issues/291 -DietPi-Apt_Get_Update | Will now ignore waiting for (and killing) NTPD if ntpd_update_mode=0 (disabled) or ntpd_update_mode=4 (daemon): https://github.com/Fourdee/DietPi/issues/289 +DietPi-Apt_Get_Update | Will now ignore waiting for (and killing) NTPD if CONFIG_NTP_MODE=0 (disabled) or CONFIG_NTP_MODE=4 (daemon): https://github.com/Fourdee/DietPi/issues/289 ----------------------------------------------------------------------------------------------------------- @@ -1778,7 +1852,7 @@ DietPi-Config | Added Interactive CPU gov option (if available on device). Odroid C1/XU4 | Changed default CPU gov from ondemand to interactive. This resolves the issue with Odroid c1 ondemand not scaling (http://forum.odroid.com/viewtopic.php?f=117&t=12057), and, performs much better. Odroid XU4 | Fixed issue with missing curl pre-reqs. Curl is now installed by default (to be consistent with all DietPi images). DietPi-Ramlog | Now also saves filenames and generates those files on boot as blank files. Basically ensures log file permissions are set correctly during boot. -/DietPi/dietpi.txt cpu_max_frequency= | You can now limit the max cpu frequency (MHz) for all cores. | 0=disabled | Useful for lowering temp/power usage on your device. +/DietPi/dietpi.txt CONFIG_CPU_MAX_FREQ= | You can now limit the max cpu frequency (MHz) for all cores. | 0=disabled | Useful for lowering temp/power usage on your device. DietPi-BugReport | Will now also send /etc/init.d/* and ls /etc/rc*.d/* services startup orders. General | Rolled out -m1 to the majority of DietPi code. This should improve performance with DietPi scripts. @@ -1826,7 +1900,7 @@ Release Notes: DietPi-Software | Added DietPi optimized installation option for Pi-hole (DNS server that blocks adverts on your network). http://dietpi.com/phpbb/viewtopic.php?f=8&t=5&start=20#p174 Optimization | ipv6 is now fully disabled for RPi, honest. http://dietpi.com/phpbb/viewtopic.php?f=9&t=37&p=152#p152 Security | Dropbear will generate a unique SSH key during 1st run setup. Thanks to DietPirate (http://dietpi.com/phpbb/viewtopic.php?f=9&t=37#p156). -DietPi-Update | Added option to disable DietPi automatically checking for updates (dietpi.txt dietpi_check_for_updates=0-1) +DietPi-Update | Added option to disable DietPi automatically checking for updates (dietpi.txt CONFIG_CHECK_DIETPI_UPDATES=0-1) ----------------------------------------------------------------------------------------------------------- diff --git a/PREP_SYSTEM_FOR_DIETPI.sh b/PREP_SYSTEM_FOR_DIETPI.sh index 493c5d9cf4..a38ac48179 100644 --- a/PREP_SYSTEM_FOR_DIETPI.sh +++ b/PREP_SYSTEM_FOR_DIETPI.sh @@ -1,392 +1,993 @@ +#!/bin/bash +{ + #------------------------------------------------------------------------------------------------ + # Optimize current Debian installation and prep for DietPi installation. + #------------------------------------------------------------------------------------------------ + # REQUIREMENTS + # - Currently running Debian (ideally minimal, eg: Raspbian Lite-ish =)) ) + # - Active eth0 connection + #------------------------------------------------------------------------------------------------ -#------------------------------------------------------------------------------------------------ -# Setup a Debian installation, for DietPi. -#------------------------------------------------------------------------------------------------ -# NOTICE: Images created by non-DietPi staff, will NOT be officially supported by DietPi, unless authorized by DietPi. -# NOTICE: There is no offical support for using these script/notes. However, exceptions may be made. -#------------------------------------------------------------------------------------------------ -# Before starting, copy the following files and folders to /boot/ https://github.com/Fourdee/DietPi -# - /boot/dietpi.txt (file) -# - /boot/config.txt (file) -# - /boot/dietpi (folder) -#------------------------------------------------------------------------------------------------ -# Legend: -# - Items that are commented out should not be used. -# - Sections with '#???', are optional, depending on the device and its specs. (eg: does it need bluetooth?) -#------------------------------------------------------------------------------------------------ - -#This is not currently a executable script. Please manually run through the commands: -exit 0 #prevent continuation of this script. - - -#------------------------------------------------------------------------------------------------ -#Packages -#------------------------------------------------------------------------------------------------ - -#NOTE: -#Apt mirror will get overwritten by: /DietPi/dietpi/func/dietpi-set_software apt-mirror default : during finalize. - -#??? RPI -DISTRO='stretch' -cat << _EOF_ > /etc/apt/sources.list -deb https://www.mirrorservice.org/sites/archive.raspbian.org/raspbian $DISTRO main contrib non-free rpi -_EOF_ + #Use master branch, if unset + GIT_BRANCH=${GIT_BRANCH:=master} + echo -e "Git Branch: $GIT_BRANCH" -cat << _EOF_ > /etc/apt/sources.list.d/raspi.list -deb https://archive.raspberrypi.org/debian/ $DISTRO main ui -_EOF_ + #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 + cd "$HOME" + + #------------------------------------------------------------------------------------------------ + # Critical checks and pre-reqs, with exit, prior to initial run of script + #------------------------------------------------------------------------------------------------ + #Exit path for non-root logins. + if (( $UID != 0 )); then + + echo -e 'Error: Root privileges required. Please run the command with "sudo"\nIn case install the "sudo" package with root privileges: #apt-get install sudo\n' + exit 1 + + fi + + # - APT force IPv4 + echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99-dietpi-force-ipv4 + + #Check/install minimal APT Pre-Reqs + a_MIN_APT_PREREQS=( + + 'wget' + 'ca-certificates' + 'locales' + + ) + + # - Meveric special: https://github.com/Fourdee/DietPi/issues/1285#issuecomment-355759321 + rm /etc/apt/sources.list.d/deb-multimedia.list &> /dev/null + + apt-get clean + apt-get update + for (( i=0; i<${#a_MIN_APT_PREREQS[@]}; i++)) + do + + if (( ! $(dpkg --get-selections | grep -ci -m1 "^${a_MIN_APT_PREREQS[$i]}[[:space:]]") )); then + + apt-get install -y ${a_MIN_APT_PREREQS[$i]} + if (( $? != 0 )); then + + echo -e "Error: Unable to install ${a_MIN_APT_PREREQS[$i]}, please try to install it manually with\n - apt-get install -y ${a_MIN_APT_PREREQS[$i]}" + exit 1 + + fi + + fi + + done + + unset a_MIN_APT_PREREQS + + # - Wget prefer IPv4 + grep -q '^[[:blank:]]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]]*prefer-family =/c\prefer-family = IPv4' /etc/wgetrc || + grep -q '^[[:blank:]#;]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]#;]*prefer-family =/c\prefer-family = IPv4' /etc/wgetrc || + echo 'prefer-family = IPv4' >> /etc/wgetrc + + #Setup 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 + dpkg-reconfigure -f noninteractive locales + # dpkg-reconfigure includes: + # - "locale-gen": Generate locale(s) based on "/etc/locale.gen" or interactive selection. + # - "update-locale": Add $LANG to "/etc/default/locale" based on generated locale(s) or interactive default language selection. + if (( $? != 0 )); then + + echo -e 'Error: Locale generation failed. Aborting...\n' + exit 1 -#??? Everything else (excluding RPi!) -DISTRO='stretch' -cat << _EOF_ > /etc/apt/sources.list -deb http://ftp.debian.org/debian/ $DISTRO main contrib non-free -deb http://ftp.debian.org/debian/ $DISTRO-updates main contrib non-free -deb http://security.debian.org $DISTRO/updates main contrib non-free -deb http://ftp.debian.org/debian/ $DISTRO-backports main contrib non-free + fi + + cat << _EOF_ > /etc/profile.d/99-dietpi-force-locale.sh +# Force locale on remote access, especially via dropbear, where overwriting server locale by SSH client cannot be suppressed: +export LANG=en_GB.UTF-8 +export LC_ALL=en_GB.UTF-8 +export LANGUAGE=en_GB:en _EOF_ + chmod +x /etc/profile.d/99-dietpi-force-locale.sh + #Force en_GB Locale for rest of script. Prevents incorrect parsing with non-english locales. + LANG=en_GB.UTF-8 -#+Meveric images -rm /etc/apt/sources.list.d/deb-multimedia.list + #------------------------------------------------------------------------------------------------ + #Globals + #------------------------------------------------------------------------------------------------ + #Download DietPi-Globals + # - NB: we'll have to manually handle errors, until script is sucessfully loaded + wget https://raw.githubusercontent.com/Fourdee/DietPi/$GIT_BRANCH/dietpi/func/dietpi-globals -O dietpi-globals + if (( $? != 0 )); then -#Remove following All -apt-get clean -apt-get update -apt-get purge -y libpython* fonts-* xmms2-client-* pulseaudio* jq xxd iperf3 gdisk gpsd ppp libboost-iostreams* sgml-base xml-core usb-modeswitch* libpng* cpp-* cpp ntpdate bluez bluetooth rsync dialog dhcpcd5 lua5.1 netcat-* make makedev ncdu plymouth openresolv shared-mime-in* tcpd strace tasksel* wireless-* xdg-user-dirs triggerhappy python* v4l-utils traceroute xz-utils ucf xauth zlib1g-dev xml-core aptitude* avahi-daemon rsyslog logrotate man-db manpages vim vim-common vim-runtime vim-tiny mc mc-data + echo -e 'Error: Unable to download dietpi-globals. Aborting...\n' + exit 1 -#+Desktop images (Mostly desktop packages, but apply to non-desktop images also): -apt-get purge -y libpod-* libpeas-* isc-dhcp-server gnome-* fonts-dejavu* eject dnsmasq* dns-root-data colord-data libjasper* libjson* libwbclient* libwayland* golang-* libavahi* libtext* libweb* libpcsclite1 libxau6* libxc* dictionaries-* libgtk* miscfiles minicom lrzsz lxmenu-* x11-* zenity* yelp-* + fi -rm -R /usr/share/fonts/* -rm -R /usr/share/icons/* + # - load + chmod +x dietpi-globals + . ./dietpi-globals + if (( $? != 0 )); then -#+Misc -#??? BBB: https://github.com/Fourdee/DietPi/issues/931#issuecomment-345451529 -apt-get purge -y apache2 roboticscape ardupilot-* ti-* nodejs mjpg-streamer bonescript libapr1 -#??? + echo -e 'Error: Unable to load dietpi-globals. Aborting...\n' + exit 1 -apt-get purge -y memtester expect tcl-expect toilet toilet-fonts w-scan vlan weather-util* sysbench stress cmake cmake-data device-tree-co* fping hddtemp haveged hostapd i2c-tools iperf ir-keytable libasound2* libmtp* libusb-dev lirc lsof ncurses-term pkg-config unicode-data rfkill pv mtp-tools m4 screen alsa-utils autotools-dev bind9-host btrfs-tools bridge-utils cpufrequtils dvb-apps dtv-scan-table* evtest f3 figlet gcc gcc-4.8-* git git-man ifenslave + fi -#+ dev packages -# On ARMbian DEV branch images, manually do this as triggers '*-dev' image/uboot etc -apt-get purge -y '\-dev$' linux-headers* + export G_PROGRAM_NAME='DietPi-PREP_SYSTEM_FOR_DIETPI' + export G_DISTRO=0 # Export to dietpi-globals + export G_DISTRO_NAME='NULL' # Export to dietpi-globals + DISTRO_TARGET=0 + DISTRO_TARGET_NAME='' + if grep -q 'wheezy' /etc/os-release; then -#+ Meveric's repo | Renders patch for removal in apt -# apt-get purge setup-odroid # not compat with DietPi + G_DISTRO=2 + G_DISTRO_NAME='wheezy' -#??? RPI -apt-get purge -y rpi-update libraspberrypi-doc -#??? RPI (remove older version packages marked as manual): https://github.com/Fourdee/DietPi/issues/598#issuecomment-25919922 -apt-get purge gcc-4.6-base gcc-4.7-base gcc-4.8-base libsigc++-1.2-5c2 -#??? + elif grep -q 'jessie' /etc/os-release; then -apt-get autoremove --purge -y + G_DISTRO=3 + G_DISTRO_NAME='jessie' + elif grep -q 'stretch' /etc/os-release; then -#??? ROCK64, reinstall kernel packages: -apt-get install linux-rock64-package -#??? + G_DISTRO=4 + G_DISTRO_NAME='stretch' -#???: Optional Reinstall OpenSSH (for updating dietpi scripts etc). Gets removed during finalise. -apt-get install openssh-server -y -echo -e "PermitRootLogin yes" >> /etc/ssh/sshd_config -systemctl restart ssh -#??? + elif grep -q 'buster' /etc/os-release; then + G_DISTRO=5 + G_DISTRO_NAME='buster' -#install packages -apt-get dist-upgrade -y -echo -e "CONF_SWAPSIZE=0" > /etc/dphys-swapfile -apt-get install -y gnupg net-tools cron rfkill ca-certificates locales apt-transport-https ethtool p7zip-full hfsplus iw debconf-utils xz-utils fbset wpasupplicant resolvconf bc dbus bzip2 psmisc bash-completion cron whiptail sudo ntp ntfs-3g dosfstools parted hdparm usbutils zip htop wput wget fake-hwclock dphys-swapfile curl unzip console-setup console-data console-common keyboard-configuration wireless-tools wireless-regdb crda --no-install-recommends + else + echo -e 'Error: Unknown or unsupported distribution version. Aborting...\n' + exit 1 -#??? Grub/intel+amd microcode firmware x86_64 native -# MBR -apt-get install -y grub2 -# UEFI -apt-get install -y grub-common grub-efi-amd64 grub-efi-amd64-bin grub2-common -#??? + fi -#??? bluetooth if onboard device / RPI -apt-get install -y bluetooth bluez-firmware -#??? + #G_HW_MODEL # init from dietpi-globals + #G_HW_ARCH_DESCRIPTION # init from dietpi-globals + G_HW_ARCH_DESCRIPTION=$(uname -m) + if [ "$G_HW_ARCH_DESCRIPTION" = "armv6l" ]; then -#??? RPi - bluetooth/firmware for all RPi's -apt-get install -y pi-bluetooth libraspberrypi-bin -#??? + G_HW_ARCH=1 -#??? x86 images only: firmware -apt-get install -y firmware-linux-nonfree firmware-realtek firmware-ralink firmware-brcm80211 firmware-atheros --no-install-recommends -#??? + elif [ "$G_HW_ARCH_DESCRIPTION" = "armv7l" ]; then -#------------------------------------------------------------------------------------------------ -#DIETPI STUFF -#------------------------------------------------------------------------------------------------ -chmod +x -R /boot + G_HW_ARCH=2 -#Delete any non-root user (eg: pi) -userdel -f pi -userdel -f test #armbian -userdel -f odroid -userdel -f rock64 -userdel -f linaro #ASUS TB -userdel -f dietpi -userdel -f debian #BBB + elif [ "$G_HW_ARCH_DESCRIPTION" = "aarch64" ]; then -#Remove folders (now in finalise script) + G_HW_ARCH=3 -#+Remove files -#rm /etc/apt/sources.list.d/armbian.list -rm /etc/init.d/resize2fs -rm /etc/update-motd.d/* # ARMbian + elif [ "$G_HW_ARCH_DESCRIPTION" = "x86_64" ]; then -systemctl disable firstrun -rm /etc/init.d/firstrun # ARMbian + G_HW_ARCH=10 -# Disable ARMbian's log2ram: https://github.com/Fourdee/DietPi/issues/781 -systemctl disable log2ram.service -systemctl stop log2ram.service -rm /usr/local/sbin/log2ram -rm /etc/systemd/system/log2ram.service -systemctl daemon-reload -rm /etc/cron.hourly/log2ram + else -rm /etc/init.d/cpu_governor # Meveric -rm /etc/systemd/system/cpu_governor.service # Meveric + echo -e "Error: Unknown or unsupported CPU architecture $G_HW_ARCH_DESCRIPTION. Aborting..." + exit 1 -# Disable ARMbian's resize service (not automatically removed by ARMbian scripts...) -systemctl disable resize2fs -rm /etc/systemd/system/resize2fs.service + fi -# ARMbian-config -rm /etc/profile.d/check_first_login_reboot.sh + #URL connection test var holder + INTERNET_ADDRESS='' -#Set UID bit for sudo: https://github.com/Fourdee/DietPi/issues/794 -chmod 4755 /usr/bin/sudo + #Whiptail + WHIP_BACKTITLE='DietPi-Prep' + WHIP_TITLE=0 + WHIP_DESC=0 + WHIP_MENU_ARRAY=0 + WHIP_RETURN_VALUE=0 + WHIP_DEFAULT_ITEM=0 + WHIP_OPTION=0 + WHIP_CHOICE=0 + Run_Whiptail(){ -#Create DietPi common folders -mkdir /DietPi + WHIP_OPTION=$(whiptail --title "$WHIP_TITLE" --menu "$WHIP_DESC" --default-item "$WHIP_DEFAULT_ITEM" --backtitle "$WHIP_BACKTITLE" 24 85 12 "${WHIP_MENU_ARRAY[@]}" 3>&1 1>&2 2>&3) + WHIP_CHOICE=$? + if (( $WHIP_CHOICE == 0 )) && + [ -n "$WHIP_OPTION" ]; then -mkdir -p /mnt/dietpi_userdata + WHIP_RETURN_VALUE=$WHIP_OPTION -mkdir -p /mnt/samba -mkdir -p /mnt/ftp_client -mkdir -p /mnt/nfs_client -echo -e "Samba client can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking Options: NAS/Misc menu" > /mnt/samba/readme.txt -echo -e "FTP client mount can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking Options: NAS/Misc menu" > /mnt/ftp_client/readme.txt -echo -e "NFS client can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking Options: NAS/Misc menu" > /mnt/nfs_client/readme.txt + else -/boot/dietpi/dietpi-logclear 2 + G_DIETPI-NOTIFY 1 'No choices detected, aborting...' + exit 0 -#FSTAB -cp /boot/dietpi/conf/fstab /etc/fstab -systemctl daemon-reload -mount -a + fi -#Setup DietPi services -# DietPi-Ramdisk -cat << _EOF_ > /etc/systemd/system/dietpi-ramdisk.service -[Unit] -Description=DietPi-RAMdisk -After=local-fs.target + #delete [] + unset WHIP_MENU_ARRAY -[Service] -Type=forking -RemainAfterExit=yes -ExecStartPre=/bin/mkdir -p /etc/dietpi/logs -ExecStart=/bin/bash -c '/boot/dietpi/dietpi-ramdisk 0' -ExecStop=/bin/bash -c '/DietPi/dietpi/dietpi-ramdisk 1' + } -[Install] -WantedBy=local-fs.target -_EOF_ -systemctl enable dietpi-ramdisk.service -systemctl daemon-reload -systemctl start dietpi-ramdisk.service + #------------------------------------------------------------------------------------------------ + #------------------------------------------------------------------------------------------------ + #------------------------------------------------------------------------------------------------ + # MAIN LOOP + #------------------------------------------------------------------------------------------------ + #------------------------------------------------------------------------------------------------ + #------------------------------------------------------------------------------------------------ -# DietPi-Ramlog -cat << _EOF_ > /etc/systemd/system/dietpi-ramlog.service -[Unit] -Description=DietPi-RAMlog -Before=rsyslog.service syslog.service -After=local-fs.target + #------------------------------------------------------------------------------------------------ + echo -e '' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + G_DIETPI-NOTIFY 0 'Step 0: Detecting existing DietPi system:' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + #------------------------------------------------------------------------------------------------ + if (( $(systemctl is-active dietpi-ramdisk | grep -ci -m1 '^active') )); then -[Service] -Type=forking -RemainAfterExit=yes -ExecStart=/bin/bash -c '/boot/dietpi/dietpi-ramlog 0' -ExecStop=/bin/bash -c '/DietPi/dietpi/dietpi-ramlog 1' + G_DIETPI-NOTIFY 2 'DietPi system found, running pre-prep' -[Install] -WantedBy=local-fs.target -_EOF_ -systemctl enable dietpi-ramlog.service -systemctl daemon-reload -systemctl start dietpi-ramlog.service + # - Stop services + /DietPi/dietpi/dietpi-services stop -# Boot -cat << _EOF_ > /etc/systemd/system/dietpi-boot.service -[Unit] -Description=DietPi-Boot -After=network-online.target network.target networking.service dietpi-ramdisk.service dietpi-ramlog.service -Requires=dietpi-ramdisk.service + G_RUN_CMD systemctl stop dietpi-ramlog + G_RUN_CMD systemctl stop dietpi-ramdisk -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/bin/bash -c '/DietPi/dietpi/boot' -StandardOutput=tty + # - Delete any previous exsiting data + rm -R /DietPi/* + rm -R /boot/dietpi -[Install] -WantedBy=multi-user.target -_EOF_ -systemctl enable dietpi-boot.service -systemctl daemon-reload + rm -R /mnt/dietpi-backup &> /dev/null + rm -R /mnt/dietpi-sync &> /dev/null + rm -R /mnt/dietpi_userdata &> /dev/null + + rm -R /etc/dietpi &> /dev/null # Pre v160 + rm -R /var/lib/dietpi &> /dev/null + rm -R /var/tmp/dietpi &> /dev/null + + rm /root/DietPi-Automation.log &> /dev/null + rm /boot/Automation_Format_My_Usb_Drive &> /dev/null + + else + + G_DIETPI-NOTIFY 2 'Non-DietPi system' + + fi + + #------------------------------------------------------------------------------------------------ + echo -e '' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + G_DIETPI-NOTIFY 0 'Step 1: Initial prep to allow this script to function:' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + #------------------------------------------------------------------------------------------------ + G_DIETPI-NOTIFY 2 'Updating APT:' + + #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 whiptail + + #------------------------------------------------------------------------------------------------ + echo -e '' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + G_DIETPI-NOTIFY 0 'Step 2: Hardware selection:' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + #------------------------------------------------------------------------------------------------ + + WHIP_TITLE='Hardware selection:' + WHIP_DESC='Please select the current device this is being installed on:\n - NB: Select "Generic device" if not listed.' + WHIP_DEFAULT_ITEM=22 + WHIP_MENU_ARRAY=( + + '' '────Other──────────────────────────────' + '22' 'Generic device (unknown to DietPi)' + '' '────SBC────────────────────────────────' + '52' 'Asus Tinker Board' + '51' 'BananaPi Pro (Lemaker)' + '50' 'BananaPi M2+ (sinovoip)' + '71' 'Beagle Bone Black' + '66' 'NanoPi M1 Plus' + '65' 'NanoPi NEO 2' + '64' 'NanoPi NEO Air' + '63' 'NanoPi M1/T1' + '62' 'NanoPi M3/T3' + '61' 'NanoPi M2/T2' + '60' 'NanoPi Neo' + '13' 'Odroid U3' + '12' 'Odroid C2' + '11' 'Odroid XU3/4/HC1' + '10' 'Odroid C1' + '38' 'OrangePi PC 2' + '37' 'OrangePi Prime' + '36' 'OrangePi Win' + '35' 'OrangePi Zero Plus 2 (H3/H5)' + '34' 'OrangePi Plus' + '33' 'OrangePi Lite' + '32' 'OrangePi Zero (H2+)' + '31' 'OrangePi One' + '30' 'OrangePi PC' + '40' 'Pine A64' + '3' 'Raspberry Pi 3' + '2' 'Raspberry Pi 2' + '1' 'Raspberry Pi 1/Zero (512mb)' + '0' 'Raspberry Pi 1 (256mb)' + '43' 'Rock64' + '70' 'Sparky SBC' + '' '────PC─────────────────────────────────' + '21' 'x86_64 Native PC' + '20' 'x86_64 VMware/VirtualBox' -# Remove rc.local from /etc/init.d -update-rc.d -f rc.local remove -rm /etc/init.d/rc.local -rm /lib/systemd/system/rc-local.service + ) -cat << _EOF_ > /etc/systemd/system/rc-local.service -[Unit] -Description=/etc/rc.local Compatibility -After=dietpi-boot.service dietpi-ramdisk.service dietpi-ramlog.service -Requires=dietpi-boot.service dietpi-ramdisk.service + Run_Whiptail + G_HW_MODEL=$WHIP_RETURN_VALUE -[Service] -Type=idle -ExecStart=/etc/rc.local -StandardOutput=tty -RemainAfterExit=yes + 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" -[Install] -WantedBy=multi-user.target -_EOF_ -systemctl enable rc-local.service -systemctl daemon-reload + echo -e "$G_HW_MODEL" > /etc/.dietpi_hw_model_identifier -cat << _EOF_ > /etc/rc.local -#!/bin/bash -#Precaution: Wait for DietPi Ramdisk to finish -while [ ! -f /DietPi/.ramdisk ] -do + #------------------------------------------------------------------------------------------------ + echo -e '' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + G_DIETPI-NOTIFY 0 'Step 3: Distro selection:' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + #------------------------------------------------------------------------------------------------ - /DietPi/dietpi/func/dietpi-notify 2 "Waiting for DietPi-RAMDISK to finish mounting DietPi to RAM..." - sleep 1 + WHIP_TITLE='Distro selection:' + WHIP_DESC="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" + WHIP_DEFAULT_ITEM=$G_DISTRO + DISTRO_LIST_ARRAY=( + '3' 'Jessie (oldstable, just if you need to avoid upgrade to current release)' + '4' 'Stretch (current stable release, recommended)' + '5' 'Buster (testing only, not officially supported)' + ) -done + # - Enable/list available options based on criteria + # NB: Whiptail use 2 array indexs per whip displayed entry. + for ((i=0; i<$(( ${#DISTRO_LIST_ARRAY[@]} / 2 )); i++)) + do + temp_distro_available=1 + temp_distro_index=$(( $i + 3 )) + + # - Disable downgrades + if (( $temp_distro_index < $G_DISTRO )); then + + G_DIETPI-NOTIFY 2 "Disabled Distro downgrade: index $temp_distro_index" + temp_distro_available=0 + + fi + + # - Enable option + if (( $temp_distro_available )); then + + WHIP_MENU_ARRAY+=( "${DISTRO_LIST_ARRAY[$(( $i * 2 ))]}" "${DISTRO_LIST_ARRAY[$(( ($i * 2) + 1 ))]}" ) + + fi + + done + + #delete [] + unset DISTRO_LIST_ARRAY + + if [ -z ${WHIP_MENU_ARRAY+x} ]; then + + G_DIETPI-NOTIFY 1 'Error: No available Distros for this system. Aborting...' + exit 1 + + fi + + Run_Whiptail + DISTRO_TARGET=$WHIP_RETURN_VALUE + if (( $DISTRO_TARGET == 3 )); then + + DISTRO_TARGET_NAME='jessie' + + elif (( $DISTRO_TARGET == 4 )); then -echo -e "\$(cat /proc/uptime | awk '{print \$1}') Seconds" > /var/log/boottime -if (( \$(cat /DietPi/dietpi/.install_stage) == 1 )); then + DISTRO_TARGET_NAME='stretch' - /DietPi/dietpi/dietpi-services start + elif (( $DISTRO_TARGET == 5 )); then -fi -/DietPi/dietpi/dietpi-banner 0 -echo -e " Default Login:\n Username = root\n Password = dietpi\n" -exit 0 + DISTRO_TARGET_NAME='buster' + + fi + + + #------------------------------------------------------------------------------------------------ + echo -e '' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + G_DIETPI-NOTIFY 0 'Step 4: APT configuration:' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + #------------------------------------------------------------------------------------------------ + + G_DIETPI-NOTIFY 2 'Removing conflicting apt sources.list.d' + # 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 + #rm /etc/apt/sources.list.d/armbian.list + + G_DIETPI-NOTIFY 2 "Setting APT sources.list: $DISTRO_TARGET_NAME $DISTRO_TARGET" + + # - Set raspbian + if (( $G_HW_MODEL < 10 )); then + + cat << _EOF_ > /etc/apt/sources.list +deb https://www.mirrorservice.org/sites/archive.raspbian.org/raspbian $DISTRO_TARGET_NAME main contrib non-free rpi _EOF_ -chmod +x /etc/rc.local -systemctl daemon-reload -# Shutdown SSH/Dropbear before reboot -cat << _EOF_ > /etc/systemd/system/kill-ssh-user-sessions-before-network.service -[Unit] -Description=Shutdown all ssh sessions before network -DefaultDependencies=no -Before=network.target shutdown.target + cat << _EOF_ > /etc/apt/sources.list.d/raspi.list +deb https://archive.raspberrypi.org/debian/ $DISTRO_TARGET_NAME main ui +_EOF_ -[Service] -Type=oneshot -ExecStart=/bin/bash -c 'killall sshd &> /dev/null; killall dropbear &> /dev/null' + # Reset raspo.list to max available distro Stretch, which at least worked on first tests with Buster." + (( $DISTRO_TARGET > 4 )) && sed -i "s/$DISTRO_TARGET_NAME/stretch/" /etc/apt/sources.list.d/raspi.list -[Install] -WantedBy=poweroff.target halt.target reboot.target + # - Set debian + else + + cat << _EOF_ > /etc/apt/sources.list +deb https://deb.debian.org/debian/ $DISTRO_TARGET_NAME main contrib non-free +deb https://deb.debian.org/debian/ $DISTRO_TARGET_NAME-updates main contrib non-free +deb https://deb.debian.org/debian-security/ $DISTRO_TARGET_NAME/updates main contrib non-free +deb https://deb.debian.org/debian/ $DISTRO_TARGET_NAME-backports main contrib non-free _EOF_ -systemctl enable kill-ssh-user-sessions-before-network -systemctl daemon-reload + # Jessie, switch deb.debian.org to http: https://github.com/Fourdee/DietPi/issues/1285#issuecomment-351830101 + if (( $G_DISTRO < 4 )); then + + sed -i 's/https:/http:/g' /etc/apt/sources.list + + # Buster, remove backports: https://github.com/Fourdee/DietPi/issues/1285#issuecomment-351830101 + elif (( $DISTRO_TARGET > 4 )); then + + sed -i '/backports/d' /etc/apt/sources.list + + fi + + fi + + G_DIETPI-NOTIFY 2 "Updating APT for $DISTRO_TARGET_NAME:" + + G_RUN_CMD apt-get clean + + 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" -#Cron jobs -cp /DietPi/dietpi/conf/cron.daily_dietpi /etc/cron.daily/dietpi -chmod +x /etc/cron.daily/dietpi -cp /DietPi/dietpi/conf/cron.hourly_dietpi /etc/cron.hourly/dietpi -chmod +x /etc/cron.hourly/dietpi + G_RUN_CMD apt-mark auto $(apt-mark showmanual) -#Crontab -cat << _EOF_ > /etc/crontab -#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 + # - @MichaIng https://github.com/Fourdee/DietPi/pull/1266/files + G_DIETPI-NOTIFY 2 "Temporary disable automatic recommends/suggests installation and allow them to be autoremoved:" -# m h dom mon dow user command -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 ) + export G_ERROR_HANDLER_COMMAND='/etc/apt/apt.conf.d/99-dietpi-norecommends' + cat << _EOF_ > $G_ERROR_HANDLER_COMMAND +APT::Install-Recommends "false"; +APT::Install-Suggests "false"; +APT::AutoRemove::RecommendsImportant "false"; +APT::AutoRemove::SuggestsImportant "false"; _EOF_ + export G_ERROR_HANDLER_EXITCODE=$? + G_ERROR_HANDLER -#ntp -rm /etc/cron.daily/ntp &> /dev/null -rm /etc/init.d/ntp &> /dev/null + G_DIETPI-NOTIFY 2 "Forcing use of modified apt configs" -#Apt -# - Force use existing installed configs if available, else install new. Also disables end user prompt from dpkg -cat << _EOF_ > /etc/apt/apt.conf.d/local -Dpkg::Options { + export G_ERROR_HANDLER_COMMAND='/etc/apt/apt.conf.d/99-dietpi-forceconf' + cat << _EOF_ > $G_ERROR_HANDLER_COMMAND +Dpkg::options { "--force-confdef"; "--force-confold"; } _EOF_ + export G_ERROR_HANDLER_EXITCODE=$? + G_ERROR_HANDLER + + # - DietPi list of minimal required packages, which must be installed: + aPACKAGES_REQUIRED_INSTALL=( + + 'apt-transport-https' # Allows https sources in ATP + 'apt-utils' # Allows debconf to preconfigure APT packages before installing + 'bash-completion' # Auto completes a wide list of bash commands + 'bc' # Floating point calculation within bash + 'bzip2' # .bz2 wrapper + 'ca-certificates' # Adds known ca-certificates, necessary to practically access https sources + 'console-setup' # DietPi-Config keyboard configuration + 'cron' # background job scheduler + 'curl' # Web address testing, downloading, uploading etc. + 'dbus' # System message bus + 'debconf' # APT package configuration, e.g. 'debconf-set-selections' + 'dosfstools' # DietPi-Drive_Manager + fat (boot) drive file system check + 'dphys-swapfile' # Swap file management + 'ethtool' # Ethernet link checking + 'fake-hwclock' # Hardware clock emulation, to allow correct timestamps during boot before network time sync + 'fbset' # DietPi-Config display settings + 'gnupg' # apt-key add + 'hfsplus' # DietPi-Drive_Manager NTS (MacOS) file system support + 'htop' # System monitor + 'initramfs-tools' # RAM file system initialization + 'iputils-ping' # ping command + 'isc-dhcp-client' # DHCP client + 'locales' # Support locales, necessary for DietPi scripts, as we use enGB.UTF8 as default language + 'nano' # Simple text editor + 'net-tools' # DietPi-Boot: Network tools, ifconfig, route etc. + 'ntfs-3g' # DietPi-Drive_Manager NTPS (Windows) file system support + 'ntp' # Network time syncronization + 'p7zip-full' # .7z wrapper + 'parted' # DietPi-Boot + DietPi-Drive_Manager + 'psmisc' # DietPi-Boot + DietPi-Software: e.g. killall + 'resolvconf' # System name server updater + 'sudo' # DietPi-Software + general use + 'systemd-sysv' # Includes systemd and additional commands: poweroff, shutdown etc. + 'tzdata' # Time zone data for system clock, auto summer/winter time adjustment + 'unzip' # .zip unwrapper + 'usbutils' # DietPi-Software + DietPi-Bugreport: e.g. lsusb + 'wget' # download + 'whiptail' # DietPi dialogs + 'wput' # upload + 'zip' # .zip wrapper + + ) + + # - G_DISTRO specific required packages: + if (( $G_DISTRO < 4 )); then + + aPACKAGES_REQUIRED_INSTALL+=('dropbear') # DietPi default SSH-Client + + else + + aPACKAGES_REQUIRED_INSTALL+=('dropbear-run') # DietPi default SSH-Client (excluding initramfs integration, available since Stretch) + + fi + + # - G_HW_MODEL specific required repo key packages + # Repo keys: https://github.com/Fourdee/DietPi/issues/1285#issuecomment-358301273 + if (( $G_HW_MODEL >= 10 )); then + + G_AGI debian-archive-keyring + + else + + G_AGI raspbian-archive-keyring + + fi + + # - G_HW_MODEL specific required packages: + # VM: No network firmware necessary and hard drive power management stays at host system. + if (( $G_HW_MODEL != 20 )); then + + G_AGI firmware-realtek # Eth/WiFi/BT dongle firmware + aPACKAGES_REQUIRED_INSTALL+=('hdparm') # Drive power management adjustment + + fi + + # - Kernel required packages + # - G_HW_ARCH specific required Kernel packages + # As these are kernel, firmware or bootloader packages, we need to install them directly to allow autoremove of in case older kernel packages: + # https://github.com/Fourdee/DietPi/issues/1285#issuecomment-354602594 + # x86_64 + if (( $G_HW_ARCH == 10 )); then + + G_AGI linux-image-amd64 + # Usually no firmware should be necessary for VMs. If user manually passes though some USB device, he might need to install the firmware then. + (( $G_HW_MODEL != 20 )) && G_AGI firmware-linux-nonfree + grep 'vendor_id' /proc/cpuinfo | grep -qi 'intel' && G_AGI intel-microcode + grep 'vendor_id' /proc/cpuinfo | grep -qi 'amd' && G_AGI amd64-microcode + #aPACKAGES_REQUIRED_INSTALL+=('firmware-misc-nonfree') + #aPACKAGES_REQUIRED_INSTALL+=('dmidecode') + + # Grub EFI + if (( $(dpkg --get-selections | grep -ci -m1 '^grub-efi-amd64[[:space:]]') )) || + [ -d /boot/efi ]; then + + G_AGI grub-efi-amd64 + + # Grub BIOS + else + + G_AGI grub-pc + + fi + + # - G_HW_MODEL specific required Kernel packages + # RPi + 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/* + + G_AGI libraspberrypi-bin libraspberrypi0 raspberrypi-bootloader raspberrypi-kernel raspberrypi-sys-mods raspi-copies-and-fills --reinstall + + # Odroid C2 + elif (( $G_HW_MODEL == 12 )); then + + G_AGI linux-image-arm64-odroid-c2 + + # Odroid XU3/4/HC1 + 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}') + (( $(dpkg --get-selections | grep -ci -m1 '^linux-image') )) || G_AGI linux-image-armhf-odroid-xu3 + + # Odroid C1 + elif (( $G_HW_MODEL == 10 )); then + + G_AGI linux-image-armhf-odroid-c1 + + # Rock64 + elif (( $G_HW_MODEL == 43 )); then + + G_AGI linux-rock64-package + + # BBB + elif (( $G_HW_MODEL == 71 )); then + + G_AGI device-tree-compiler #Kern + + + # - Auto detect kernel/firmware package + else + + AUTO_DETECT_KERN_PKG=$(dpkg --get-selections | grep '^linux-image' | awk '{print $1}') + if [ -n "$AUTO_DETECT_KERN_PKG" ]; then + + G_AGI $AUTO_DETECT_KERN_PKG + + else + + G_DIETPI-NOTIFY 2 'Unable to find kernel packages for installation. Assuming non-APT/.deb kernel installation.' + + fi + + #ARMbian/others DTB + AUTO_DETECT_DTB_PKG=$(dpkg --get-selections | grep '^linux-dtb-' | awk '{print $1}') + if [ -n "$AUTO_DETECT_DTB_PKG" ]; then + + G_AGI $AUTO_DETECT_DTB_PKG + + fi + + # Check for existing firmware + # - ARMbian + # AUTO_DETECT_FIRMWARE_PKG=$(dpkg --get-selections | grep '^armbian-firmware' | awk '{print $1}') + # if [ -n "$AUTO_DETECT_FIRMWARE_PKG" ]; then + + # G_AGI $AUTO_DETECT_FIRMWARE_PKG + + # fi + # Unpacking armbian-firmware (5.35) ... + # dpkg: error processing archive /var/cache/apt/archives/armbian-firmware_5.35_all .deb (--unpack): + # trying to overwrite '/lib/firmware/rt2870.bin', which is also in package firmwa re-misc-nonfree 20161130-3 + # dpkg-deb: error: subprocess paste was killed by signal (Broken pipe) + + + fi + + G_DIETPI-NOTIFY 2 "WiFi selection" + + WHIP_TITLE='WiFi required?' + WHIP_DESC='Please select an option' + WHIP_DEFAULT_ITEM=1 + WHIP_MENU_ARRAY=( + + '0' "I don't require WiFi, do not install." + '1' 'I require WiFi functionality, keep/install related packages.' + + ) + + Run_Whiptail + if (( $WHIP_RETURN_VALUE == 1 )); then + + G_DIETPI-NOTIFY 2 "Marking WiFi as needed" + + aPACKAGES_REQUIRED_INSTALL+=('crda') # WiFi related + aPACKAGES_REQUIRED_INSTALL+=('firmware-atheros') # WiFi dongle firmware + aPACKAGES_REQUIRED_INSTALL+=('firmware-brcm80211') # WiFi dongle firmware + aPACKAGES_REQUIRED_INSTALL+=('firmware-ralink') # WiFi dongle firmware + aPACKAGES_REQUIRED_INSTALL+=('iw') # WiFi related + aPACKAGES_REQUIRED_INSTALL+=('rfkill') # WiFi related: Used by some onboard WiFi chipsets + aPACKAGES_REQUIRED_INSTALL+=('wireless-tools') # WiFi related + aPACKAGES_REQUIRED_INSTALL+=('wpasupplicant') # WiFi related + + fi + + 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 + + G_DIETPI-NOTIFY 2 "Marking required packages as manually installed:" + + G_RUN_CMD apt-mark manual $INSTALL_PACKAGES + + G_DIETPI-NOTIFY 2 "Purging APT with autoremoval:" + + G_AGA + + + #------------------------------------------------------------------------------------------------ + echo -e '' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + G_DIETPI-NOTIFY 0 'Step 5: APT installations:' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + #------------------------------------------------------------------------------------------------ + + G_DIETPI-NOTIFY 2 "Upgrading existing APT installed packages:" + + G_AGDUG + + # - 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_DIETPI-NOTIFY 2 "Disabling swapfile generation for dphys-swapfile during install" + + G_RUN_CMD echo -e "CONF_SWAPSIZE=0" > /etc/dphys-swapfile + + G_DIETPI-NOTIFY 2 "Installing core DietPi pre-req APT packages" + + G_AGI $INSTALL_PACKAGES + + # - @MichaIng https://github.com/Fourdee/DietPi/pull/1266/files + G_DIETPI-NOTIFY 2 "Returning installation of recommends back to default" + + G_RUN_CMD rm /etc/apt/apt.conf.d/99-dietpi-norecommends + + G_DIETPI-NOTIFY 2 "Purging APT with autoremoval (in case of DISTRO upgrade/downgrade):" + + G_AGA + + # Reenable HTTPS for deb.debian.org, if system was dist-upgraded to Stretch+ + if (( $G_DISTRO > 3 && $G_HW_MODEL > 9 )); then + + sed -i 's/http:/https:/g' /etc/apt/sources.list + + fi + + #------------------------------------------------------------------------------------------------ + echo -e '' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + G_DIETPI-NOTIFY 0 'Step 6: Downloading and installing DietPi sourcecode' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + #------------------------------------------------------------------------------------------------ + + INTERNET_ADDRESS="https://github.com/Fourdee/DietPi/archive/$GIT_BRANCH.zip" #NB: testing until this is stable in master + G_DIETPI-NOTIFY 2 "Checking connection to $INTERNET_ADDRESS" + G_CHECK_URL "$INTERNET_ADDRESS" + + G_RUN_CMD wget "$INTERNET_ADDRESS" -O package.zip + + G_DIETPI-NOTIFY 2 "Extracting DietPi sourcecode" + + G_RUN_CMD unzip -o package.zip + + rm package.zip + + G_DIETPI-NOTIFY 2 "Removing files not required" + + # Remove files we do not require, or want to overwrite in /boot + rm DietPi-*/CHANGELOG.txt + rm DietPi-*/PREP_SYSTEM_FOR_DIETPI.sh + rm DietPi-*/TESTING-BRANCH.md + rm DietPi-*/uEnv.txt # Pine 64, use existing on system. + + G_DIETPI-NOTIFY 2 "Creating /boot" + + G_RUN_CMD mkdir -p /boot + + G_DIETPI-NOTIFY 2 "Moving to /boot" + + # - HW specific boot.ini uEnv.txt + if (( $G_HW_MODEL == 10 )); then + + G_RUN_CMD mv DietPi-*/boot_c1.ini /boot/boot.ini + + elif (( $G_HW_MODEL == 11 )); then + + G_RUN_CMD mv DietPi-*/boot_xu4.ini /boot/boot.ini + + elif (( $G_HW_MODEL == 12 )); then + + G_RUN_CMD mv DietPi-*/boot_c2.ini /boot/boot.ini + + fi + rm DietPi-*/*.ini -#Disable automatic updates and management of apt cache. Prevents unexpected lock on Apt cache and therefore failed apt installations. -systemctl mask apt-daily.service -systemctl mask apt-daily-upgrade.timer + G_RUN_CMD cp -R DietPi-*/* /boot/ -#/etc/sysctl.conf | Check for a previous entry before adding this -echo -e "vm.swappiness=1" > /etc/sysctl.d/97-dietpi.conf + G_DIETPI-NOTIFY 2 "Cleaning up extracted files" -#login, -echo -e "\n/DietPi/dietpi/login" >> /root/.bashrc + G_RUN_CMD rm -R DietPi-* -#Network -rm -R /etc/network/interfaces # armbian symlink for bulky network-manager -cp /boot/dietpi/conf/network_interfaces /etc/network/interfaces -/DietPi/dietpi/func/obtain_network_details -# - enable allow-hotplug eth0 after copying. -sed -i "/allow-hotplug eth/c\allow-hotplug eth$(sed -n 1p /DietPi/dietpi/.network)" /etc/network/interfaces + G_DIETPI-NOTIFY 2 "Setting execute permissions for /boot/dietpi" + G_RUN_CMD chmod -R +x /boot/dietpi -#Reduce DHCP request retry count and timeouts: https://github.com/Fourdee/DietPi/issues/711 -sed -i '/^#timeout /d' /etc/dhcp/dhclient.conf -sed -i '/^#retry /d' /etc/dhcp/dhclient.conf -sed -i '/^timeout /d' /etc/dhcp/dhclient.conf -sed -i '/^retry /d' /etc/dhcp/dhclient.conf -cat << _EOF_ >> /etc/dhcp/dhclient.conf + #------------------------------------------------------------------------------------------------ + echo -e '' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + G_DIETPI-NOTIFY 0 "Step 7: Prep system for DietPi ENV:" + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + #------------------------------------------------------------------------------------------------ + + G_DIETPI-NOTIFY 2 "Deleting list of known users, not required by DietPi" + + userdel -f pi &> /dev/null + userdel -f test &> /dev/null #armbian + userdel -f odroid &> /dev/null + userdel -f rock64 &> /dev/null + userdel -f linaro &> /dev/null #ASUS TB + userdel -f dietpi &> /dev/null + userdel -f debian &> /dev/null #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 + + # - www + rm -R /var/www/* &> /dev/null + + # - sourcecode (linux-headers etc) + rm -R /usr/src/* &> /dev/null + + # - root + rm -R /root/.cache/* &> /dev/null + rm -R /root/.local/* &> /dev/null + rm -R /root/.config/* &> /dev/null + + # - 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 + + # - Previous debconfs + rm /var/cache/debconf/*-old &> /dev/null + + # - Fonts + rm -R /usr/share/fonts/* &> /dev/null + rm -R /usr/share/icons/* &> /dev/null + + rm /etc/init.d/resize2fs &> /dev/null + rm /etc/update-motd.d/* &> /dev/null # ARMbian + + systemctl disable firstrun &> /dev/null + rm /etc/init.d/firstrun &> /dev/null # ARMbian + + # - Disable ARMbian's log2ram: https://github.com/Fourdee/DietPi/issues/781 + systemctl disable log2ram.service &> /dev/null + systemctl stop log2ram.service &> /dev/null + rm /usr/local/sbin/log2ram &> /dev/null + rm /etc/systemd/system/log2ram.service &> /dev/null + systemctl daemon-reload &> /dev/null + rm /etc/cron.hourly/log2ram &> /dev/null + + rm /etc/init.d/cpu_governor &> /dev/null# Meveric + rm /etc/systemd/system/cpu_governor.service &> /dev/null# Meveric + + # - Disable ARMbian's resize service (not automatically removed by ARMbian scripts...) + systemctl disable resize2fs &> /dev/null + rm /etc/systemd/system/resize2fs.service &> /dev/null + + # - ARMbian-config + rm /etc/profile.d/check_first_login_reboot.sh &> /dev/null + + G_DIETPI-NOTIFY 2 "Creating DietPi core environment" + + G_RUN_CMD /boot/dietpi/func/dietpi-set_core_environment + + echo -e "Samba client can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking option: NAS/Misc menu" > /mnt/samba/readme.txt + echo -e "FTP client mount can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking option: NAS/Misc menu" > /mnt/ftp_client/readme.txt + echo -e "NFS client can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking option: NAS/Misc menu" > /mnt/nfs_client/readme.txt + + G_DIETPI-NOTIFY 2 "Deleting all log files /var/log" + + /boot/dietpi/dietpi-logclear 2 &> /dev/null # As this will report missing vars, however, its fine, does not break functionality. + + G_DIETPI-NOTIFY 2 "Generating DietPi /etc/fstab" + + G_RUN_CMD /boot/dietpi/dietpi-drive_manager 4 + + # - HW Specific: + # RPi requires PARTUUID for USB write: https://github.com/Fourdee/DietPi/issues/970 + if (( $G_HW_MODEL < 10 )); then + + PARTUUID_CURRENT=$(blkid /dev/mmcblk0p1 -s PARTUUID -o value) + UUID_CURRENT=$(blkid /dev/mmcblk0p1 -s UUID -o value) + sed -i "s#^UUID=$UUID_CURRENT#PARTUUID=$PARTUUID_CURRENT#g" /etc/fstab + + PARTUUID_CURRENT=$(blkid /dev/mmcblk0p2 -s PARTUUID -o value) + UUID_CURRENT=$(blkid /dev/mmcblk0p2 -s UUID -o value) + sed -i "s#^UUID=$UUID_CURRENT#PARTUUID=$PARTUUID_CURRENT#g" /etc/fstab + + systemctl daemon-reload + + fi + + G_DIETPI-NOTIFY 2 "Starting DietPi-RAMdisk service" + + G_RUN_CMD systemctl start dietpi-ramdisk.service + + G_DIETPI-NOTIFY 2 "Starting DietPi-RAMlog service" + + G_RUN_CMD systemctl start dietpi-ramlog.service + + G_DIETPI-NOTIFY 2 'Updating DietPi HW_INFO' + + /DietPi/dietpi/dietpi-obtain_hw_model + + G_DIETPI-NOTIFY 2 "Configuring Network:" + + rm -R /etc/network/interfaces &> /dev/null # armbian symlink for bulky network-manager + + G_RUN_CMD cp /boot/dietpi/conf/network_interfaces /etc/network/interfaces + + # - 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 + + # - Add pre-up lines for wifi on OrangePi Zero + if (( $G_HW_MODEL == 32 )); then + + sed -i '/iface wlan0 inet dhcp/apre-up modprobe xradio_wlan\npre-up iwconfig wlan0 power on' /etc/network/interfaces + + fi + + G_DIETPI-NOTIFY 2 "Tweaking DHCP timeout:" + + # - Reduce DHCP request retry count and timeouts: https://github.com/Fourdee/DietPi/issues/711 + sed -i '/^#timeout /d' /etc/dhcp/dhclient.conf + sed -i '/^#retry /d' /etc/dhcp/dhclient.conf + sed -i '/^timeout /d' /etc/dhcp/dhclient.conf + sed -i '/^retry /d' /etc/dhcp/dhclient.conf + cat << _EOF_ >> /etc/dhcp/dhclient.conf timeout 10; retry 4; _EOF_ -#Hosts -cat << _EOF_ > /etc/hosts + G_DIETPI-NOTIFY 2 "Configuring hosts:" + + export G_ERROR_HANDLER_COMMAND='/etc/hosts' + cat << _EOF_ > $G_ERROR_HANDLER_COMMAND 127.0.0.1 localhost 127.0.1.1 DietPi ::1 localhost ip6-localhost ip6-loopback ff02::1 ip6-allnodes ff02::2 ip6-allrouters _EOF_ + export G_ERROR_HANDLER_EXITCODE=$? + G_ERROR_HANDLER -cat << _EOF_ > /etc/hostname + export G_ERROR_HANDLER_COMMAND='/etc/hostname' + cat << _EOF_ > $G_ERROR_HANDLER_COMMAND DietPi _EOF_ + export G_ERROR_HANDLER_EXITCODE=$? + G_ERROR_HANDLER + + G_DIETPI-NOTIFY 2 "Configuring htop:" -#htop cfg -mkdir -p /root/.config/htop -cp /boot/dietpi/conf/htoprc /root/.config/htop/htoprc + mkdir -p /root/.config/htop + cp /DietPi/dietpi/conf/htoprc /root/.config/htop/htoprc -#hdparm -cat << _EOF_ >> /etc/hdparm.conf + G_DIETPI-NOTIFY 2 "Configuring hdparm:" + + export G_ERROR_HANDLER_COMMAND='/etc/hdparm.conf' + cat << _EOF_ >> $G_ERROR_HANDLER_COMMAND #DietPi external USB drive. Power management settings. /dev/sda { @@ -397,114 +998,86 @@ cat << _EOF_ >> /etc/hdparm.conf apm = 254 } _EOF_ + export G_ERROR_HANDLER_EXITCODE=$? + G_ERROR_HANDLER -cat << _EOF_ >> /etc/bash.bashrc -#LANG -export \$(cat /etc/default/locale | grep LANG=) - -#Define a default LD_LIBRARY_PATH for all systems -export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/opt/vc/lib - -#DietPi Additions -alias sudo='sudo ' # https://github.com/Fourdee/DietPi/issues/424 -alias dietpi-process_tool='/DietPi/dietpi/dietpi-process_tool' -alias dietpi-letsencrypt='/DietPi/dietpi/dietpi-letsencrypt' -alias dietpi-autostart='/DietPi/dietpi/dietpi-autostart' -alias dietpi-cron='/DietPi/dietpi/dietpi-cron' -alias dietpi-launcher='/DietPi/dietpi/dietpi-launcher' -alias dietpi-cleaner='/DietPi/dietpi/dietpi-cleaner' -alias dietpi-morsecode='/DietPi/dietpi/dietpi-morsecode' -alias dietpi-sync='/DietPi/dietpi/dietpi-sync' -alias dietpi-backup='/DietPi/dietpi/dietpi-backup' -alias dietpi-bugreport='/DietPi/dietpi/dietpi-bugreport' -alias dietpi-services='/DietPi/dietpi/dietpi-services' -alias dietpi-config='/DietPi/dietpi/dietpi-config' -alias dietpi-software='/DietPi/dietpi/dietpi-software' -alias dietpi-update='/DietPi/dietpi/dietpi-update' -alias dietpi-drive_manager='/DietPi/dietpi/dietpi-drive_manager' -alias emulationstation='/opt/retropie/supplementary/emulationstation/emulationstation' -alias opentyrian='/usr/local/games/opentyrian/run' - -alias cpu='/DietPi/dietpi/dietpi-cpuinfo' -alias dietpi-logclear='/DietPi/dietpi/dietpi-logclear' -treesize() -{ - du -k --max-depth=1 | sort -nr | awk ' - BEGIN { - split("KB,MB,GB,TB", Units, ","); - } - { - u = 1; - while (\$1 >= 1024) - { - \$1 = \$1 / 1024; - u += 1; - } - \$1 = sprintf("%.1f %s", \$1, Units[u]); - print \$0; - } - ' -} -_EOF_ + G_DIETPI-NOTIFY 2 "Configuring fakehwclock:" + + # - allow times in the past + sed -i "/FORCE=/c\FORCE=force" /etc/default/fake-hwclock + + G_DIETPI-NOTIFY 2 "Configuring serial consoles:" + + # - Disable serial console + /DietPi/dietpi/func/dietpi-set_hardware serialconsole disable + + G_DIETPI-NOTIFY 2 "Configuring ntpd:" + + systemctl disable systemd-timesyncd + rm /etc/init.d/ntp &> /dev/null + (( $G_DISTRO > 4 )) && systemctl mask ntp + + 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 + G_RUN_CMD dpkg-reconfigure -f noninteractive tzdata + G_DIETPI-NOTIFY 2 "Configuring regional settings (Keyboard):" -#fakehwclock - allow times in the past -sed -i "/FORCE=/c\FORCE=force" /etc/default/fake-hwclock + dpkg-reconfigure -f noninteractive keyboard-configuration #Keyboard must be plugged in for this to work! -#wifi dongles | move to dietpi-set_hardware wifi -# echo -e "options 8192cu rtw_power_mgnt=0" > /etc/modprobe.d/8192cu.conf -# echo -e "options 8188eu rtw_power_mgnt=0" > /etc/modprobe.d/8188eu.conf -# echo -e "options 8189es rtw_power_mgnt=0" > /etc/modprobe.d/8189es.conf + #G_DIETPI-NOTIFY 2 "Configuring regional settings (Locale):" + #Runs at start of script -#Set swapfile size -echo -e "CONF_SWAPSIZE=0" > /etc/dphys-swapfile + #G_HW_ARCH specific + G_DIETPI-NOTIFY 2 "Applying G_HW_ARCH specific tweaks:" -#nano /etc/systemd/logind.conf -#NAutoVTs=1 + if (( $G_HW_ARCH == 10 )); then -#nano /etc/default/console-setup -#Reduce gettys ACTIVE_CONSOLES="/dev/tty[1-2]" + # - i386 APT support + dpkg --add-architecture i386 + G_AGUP -systemctl disable getty@tty[2-6].service -#systemctl disable serial-getty@ttyS0.service + # - Disable nouveau: https://github.com/Fourdee/DietPi/issues/1244 // http://dietpi.com/phpbb/viewtopic.php?f=11&t=2462&p=9688#p9688 + cat << _EOF_ > /etc/modprobe.d/blacklist-nouveau.conf +blacklist nouveau +blacklist lbm-nouveau +options nouveau modeset=0 +alias nouveau off +alias lbm-nouveau off +_EOF_ + echo -e "options nouveau modeset=0" > /etc/modprobe.d/nouveau-kms.conf + update-initramfs -u -#NTPd default - Disable systemd's version -systemctl disable systemd-timesyncd + fi -#+ARMbian increase console verbose -sed -i '/verbosity=/c\verbosity=7' /boot/armbianEnv.txt + #G_HW_MODEL specific + G_DIETPI-NOTIFY 2 "Appling G_HW_MODEL specific tweaks:" + # - ARMbian OPi Zero 2: https://github.com/Fourdee/DietPi/issues/876#issuecomment-294350580 + if (( $G_HW_MODEL == 35 )); then -dpkg-reconfigure tzdata #Europe > London -dpkg-reconfigure keyboard-configuration #Keyboard must be plugged in for this to work! -dpkg-reconfigure locales # en_GB.UTF8 as default and only installed locale + echo -e "blacklist bmp085" > /etc/modprobe.d/bmp085.conf -#Pump default locale into sys env: https://github.com/Fourdee/DietPi/issues/825 -cat << _EOF_ > /etc/environment -LC_ALL=en_GB.UTF-8 -LANG=en_GB.UTF-8 + # - Sparky SBC ONLY: + elif (( $G_HW_MODEL == 70 )); then + + # Install latest kernel + wget https://raw.githubusercontent.com/sparky-sbc/sparky-test/master/dragon_fly_check/uImage -O /boot/uImage + wget https://raw.githubusercontent.com/sparky-sbc/sparky-test/master/dragon_fly_check/3.10.38.bz2 -O package.tar + tar xvf package.tar -C /lib/modules/ + rm package.tar + + cat << _EOF_ > /DietPi/uEnv.txt +uenvcmd=setenv os_type linux; +bootargs=earlyprintk clk_ignore_unused selinux=0 scandelay console=tty0 loglevel=1 real_rootflag=rw root=/dev/mmcblk0p2 rootwait init=/lib/systemd/systemd aotg.urb_fix=1 aotg.aotg1_speed=0 _EOF_ -#Prefer to use wlan/eth naming for networked devices (eg: stretch) -ln -sf /dev/null /etc/systemd/network/99-default.link -#??? x86_64 -# kernel cmd line with GRUB -# /etc/default/grub [replace] GRUB_CMDLINE_LINUX="net.ifnames=0" -# GRUB_TIMEOUT=0 -#??? - -#??? Native PC, add i386 support by default -dpkg --add-architecture i386 -apt-get update -#??? - -#??? ARMbian OPi Zero 2: https://github.com/Fourdee/DietPi/issues/876#issuecomment-294350580 -echo -e "blacklist bmp085" > /etc/modprobe.d/bmp085.conf -#??? - -#??? Sparky SBC ONLY: Blacklist GPU and touch screen modules: https://github.com/Fourdee/DietPi/issues/699#issuecomment-271362441 -cat << _EOF_ > /etc/modprobe.d/disable_sparkysbc_touchscreen.conf + # Blacklist GPU and touch screen modules: https://github.com/Fourdee/DietPi/issues/699#issuecomment-271362441 + cat << _EOF_ > /etc/modprobe.d/disable_sparkysbc_touchscreen.conf blacklist owl_camera blacklist gsensor_stk8313 blacklist ctp_ft5x06 @@ -513,72 +1086,314 @@ blacklist gsensor_bma222 blacklist gsensor_mir3da _EOF_ -cat << _EOF_ > /etc/modprobe.d/disable_sparkysbc_gpu.conf + cat << _EOF_ > /etc/modprobe.d/disable_sparkysbc_gpu.conf blacklist pvrsrvkm blacklist drm blacklist videobuf2_vmalloc blacklist bc_example _EOF_ -#??? -#??? RPI ONLY: Scroll lock fix for RPi by Midwan: https://github.com/Fourdee/DietPi/issues/474#issuecomment-243215674 -cat << _EOF_ > /etc/udev/rules.d/50-leds.rules + # Use performance gov for stability. + sed -i "/^CONFIG_CPU_GOVERNOR=/c\CONFIG_CPU_GOVERNOR=performance" /DietPi/dietpi.txt + /DietPi/dietpi/dietpi-cpu_set + + # - RPI: Scroll lock fix for RPi by Midwan: https://github.com/Fourdee/DietPi/issues/474#issuecomment-243215674 + elif (( $G_HW_MODEL < 10 )); then + + cat << _EOF_ > /etc/udev/rules.d/50-leds.rules ACTION=="add", SUBSYSTEM=="leds", ENV{DEVPATH}=="*/input*::scrolllock", ATTR{trigger}="kbd-scrollock" _EOF_ -#??? -#??? PINE (and possibily others): Cursor fix for FB -cat << _EOF_ >> "$HOME"/.bashrc + # - PINE64 (and possibily others): Cursor fix for FB + elif (( $G_HW_MODEL == 40 )); then + + cat << _EOF_ >> "$HOME"/.bashrc infocmp > terminfo.txt sed -i -e 's/?0c/?112c/g' -e 's/?8c/?48;0;64c/g' terminfo.txt tic terminfo.txt tput cnorm _EOF_ -#??? + # - XU4 FFMPEG fix. Prefer debian.org over Meveric for backports: https://github.com/Fourdee/DietPi/issues/1273 + elif (( $G_HW_MODEL == 11 )); then -#??? XU4 FFMPEG fix. Prefer debian.org over Meveric for backports: https://github.com/Fourdee/DietPi/issues/1273 -cat << _EOF_ > /etc/apt/preferences.d/backports + cat << _EOF_ > /etc/apt/preferences.d/backports Package: * Pin: release a=jessie-backports Pin: origin "fuzon.co.uk" Pin-Priority: 99 _EOF_ -#??? -#??? x86_64 -# Disable nouveau: https://github.com/Fourdee/DietPi/issues/1244 // http://dietpi.com/phpbb/viewtopic.php?f=11&t=2462&p=9688#p9688 -cat << _EOF_ > /etc/modprobe.d/blacklist-nouveau.conf -blacklist nouveau -blacklist lbm-nouveau -options nouveau modeset=0 -alias nouveau off -alias lbm-nouveau off + fi + + # - ARMbian increase console verbose + sed -i '/verbosity=/c\verbosity=7' /boot/armbianEnv.txt &> /dev/null + + + #------------------------------------------------------------------------------------------------ + echo -e '' + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + G_DIETPI-NOTIFY 0 "Step 8: Finalise system for first run of DietPi:" + G_DIETPI-NOTIFY 2 '-----------------------------------------------------------------------------------' + #------------------------------------------------------------------------------------------------ + + G_DIETPI-NOTIFY 2 'Configuring Dropbear:' + + # set to start on next boot + sed -i '/NO_START=1/c\NO_START=0' /etc/default/dropbear + + G_DIETPI-NOTIFY 2 'Configuring Services' + + /DietPi/dietpi/dietpi-services stop + /DietPi/dietpi/dietpi-services dietpi_controlled + + G_DIETPI-NOTIFY 2 'Running general cleanup of misc files' + + # - general folders + rm -R /tmp/* &> /dev/null + + # - Remove Bash History file + rm ~/.bash_history &> /dev/null + + # - Nano histroy file + rm ~/.nano_history &> /dev/null + + G_DIETPI-NOTIFY 2 'Disabling swapfile' + + /DietPi/dietpi/func/dietpi-set_dphys-swapfile 0 /var/swap + rm /var/swap &> /dev/null # still exists on some images... + + # BBB disable swapfile gen + if (( $G_HW_MODEL == 71 )); then + + sed -i '/AUTO_SETUP_SWAPFILE_SIZE=/c\AUTO_SETUP_SWAPFILE_SIZE=0' /DietPi/dietpi.txt + + fi + + 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 + + # - Set Pi cmdline.txt back to normal + [ -f /boot/cmdline.txt ] && sed -i "s/ rootdelay=10//g" /boot/cmdline.txt + + G_DIETPI-NOTIFY 2 'Generating default wpa_supplicant.conf' + + /DietPi/dietpi/func/dietpi-set_hardware wificreds set + + G_DIETPI-NOTIFY 2 'Disabling generic WiFi/BT by default' + + /DietPi/dietpi/func/dietpi-set_hardware bluetooth disable + /DietPi/dietpi/func/dietpi-set_hardware wifimodules disable + + G_DIETPI-NOTIFY 2 'Enabling onboard WiFi modules by default' + + /DietPi/dietpi/func/dietpi-set_hardware wifimodules onboard_enable + + #G_DIETPI-NOTIFY 2 'Configuring IP version preferences' + + #/DietPi/dietpi/func/dietpi-set_hardware preferipversion ipv4 #Already done at top of script, and now default in dietpi.txt + + G_DIETPI-NOTIFY 2 'Disabling soundcards by default' + + /DietPi/dietpi/func/dietpi-set_hardware soundcard none + # Alsa-utils is auto installed to reset soundcard settings on some ARM devices. uninstall it afterwards + G_AGP alsa-utils + G_AGA + + G_DIETPI-NOTIFY 2 'Setting default CPU gov' + + /DietPi/dietpi/dietpi-cpu_set + + G_DIETPI-NOTIFY 2 'Clearing log files' + + /DietPi/dietpi/dietpi-logclear 2 + + G_DIETPI-NOTIFY 2 'Deleting DietPi-RAMlog storage' + + rm -R /var/lib/dietpi/dietpi-ramlog/storage/* &> /dev/null + + G_DIETPI-NOTIFY 2 'Deleting NTP drift file' + + rm /var/lib/ntp/ntp.drift &> /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)' + + echo -1 > /DietPi/dietpi/.install_stage + + G_DIETPI-NOTIFY 2 'Remove server_version / patch_file (downloads fresh from dietpi-update)' + + rm /DietPi/dietpi/patch_file &> /dev/null + rm /DietPi/dietpi/server_version* &> /dev/null + + G_DIETPI-NOTIFY 2 'Clearing APT cache' + + G_RUN_CMD apt-get clean + rm -R /var/lib/apt/lists/* -vf #lists cache: remove partial folder also, automatically 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_DIETPI-NOTIFY 2 'Generating dietpi-fs_partition_resize for first boot' + + #??? BBB skip this??? + cat << _EOF_ > /etc/systemd/system/dietpi-fs_partition_resize.service +[Unit] +Description=dietpi-fs_partition_resize +Before=dietpi-ramdisk.service + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart=/bin/bash -c '/var/lib/dietpi/fs_partition_resize.sh | tee /var/tmp/dietpi/logs/fs_partition_resize.log' +StandardOutput=tty + +[Install] +WantedBy=local-fs.target +_EOF_ + systemctl daemon-reload + G_RUN_CMD systemctl enable dietpi-fs_partition_resize.service + + cat << _EOF_ > /var/lib/dietpi/fs_partition_resize.sh +#!/bin/bash + +systemctl disable dietpi-fs_partition_resize.service +systemctl enable dietpi-fs_expand.service +systemctl daemon-reload + +sync + +TARGET_PARTITION=0 +TARGET_DEV=\$(findmnt / -o source -n) + +# - MMCBLK[0-9]p[0-9] scrape +if [[ "\$TARGET_DEV" = *"mmcblk"* ]]; then + + TARGET_DEV=\$(findmnt / -o source -n | sed 's/p[0-9]\$//') + TARGET_PARTITION=\$(findmnt / -o source -n | sed 's/.*p//') + +# - Everything else scrape (eg: /dev/sdX[0-9]) +else + + TARGET_DEV=\$(findmnt / -o source -n | sed 's/[0-9]\$//') + TARGET_PARTITION=\$(findmnt / -o source -n | sed 's|/dev/sd.||') + +fi + +cat << _EOF_1 | fdisk \$TARGET_DEV +p +d +\$TARGET_PARTITION +n +p +\$TARGET_PARTITION +\$(parted \$TARGET_DEV -ms unit s p | grep ':ext4::;' | sed 's/:/ /g' | sed 's/s//g' | awk '{ print \$2 }') + +p +w + +_EOF_1 + +reboot + +_EOF_ + G_RUN_CMD chmod +x /var/lib/dietpi/fs_partition_resize.sh + + G_DIETPI-NOTIFY 2 'Generating dietpi-fs_partition_expand for subsequent boot' + + cat << _EOF_ > /etc/systemd/system/dietpi-fs_expand.service +[Unit] +Description=dietpi-fs_expand +Before=dietpi-ramdisk.service + +[Service] +Type=oneshot +RemainAfterExit=no +ExecStart=/bin/bash -c "resize2fs \$(findmnt / -o source -n) &> /var/tmp/dietpi/logs/fs_expand.log; systemctl disable dietpi-fs_expand.service; systemctl daemon-reload" +StandardOutput=tty + +[Install] +WantedBy=local-fs.target +_EOF_ + systemctl daemon-reload + + # #debug + # systemctl start dietpi-fs_partition_resize.service + # systemctl status dietpi-fs_partition_resize.service -l + # cat /var/tmp/dietpi/logs/fs_partition_resize.log + + G_DIETPI-NOTIFY 2 'Storing DietPi version ID' + + G_RUN_CMD wget https://raw.githubusercontent.com/Fourdee/DietPi/$GIT_BRANCH/dietpi/.version -O /DietPi/dietpi/.version + + # reduce sub_version by 1, allows us to create image, prior to release and patch if needed. + CORE_VERSION=$(sed -n 1p /DietPi/dietpi/.version) + SUB_VERSION=$(sed -n 2p /DietPi/dietpi/.version) + ((SUB_VERSION--)) + cat << _EOF_ > /DietPi/dietpi/.version +$CORE_VERSION +$SUB_VERSION _EOF_ -echo -e "options nouveau modeset=0" > /etc/modprobe.d/nouveau-kms.conf -update-initramfs -u -#??? + G_RUN_CMD cp /DietPi/dietpi/.version /var/lib/dietpi/.dietpi_image_version + + # - Native PC/EFI (assume x86_64 only possible) + if (( $(dpkg --get-selections | grep -ci -m1 '^grub-efi-amd64[[:space:]]') )) && + [ -d /boot/efi ]; then + + G_DIETPI-NOTIFY 2 'Recreating GRUB-EFI' + + G_RUN_CMD grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=arch_grub --recheck -#------------------------------------------------------------------------------------------------ -#A Unique HW_MODEL index will need to be assigned and coded into the DietPi sourcecode. -# If you are not creating a pull request for this, then: -# -# Email: -# Address='daniel.knight@dietpi.com' -# Subject title='Unique HW_MODEL Index Request [DEVICENAME]' | Where DEVICENAME could be 'Odroid C3' -#------------------------------------------------------------------------------------------------ + fi -#Once you have the updated sourcecode, update the file '/DietPi/dietpi/dietpi-obtain_hw_model' + G_DIETPI-NOTIFY 2 'Sync changes to disk. Please wait, this may take some time...' -#??? Does this device have a unique HW ID index and file? check /DietPi/dietpi/dietpi-obtain_hw_model -echo ID > /etc/.dietpi_hw_model_identifier + G_RUN_CMD systemctl stop dietpi-ramlog + G_RUN_CMD systemctl stop dietpi-ramdisk -#Finalise system -/DietPi/dietpi/finalise + sync + # fstrim -v / + # sync -#Power off system + G_DIETPI-NOTIFY 2 'Please check and delete all non-required folders in /root/.xxxxxx' + G_DIETPI-NOTIFY 2 'Please delete outdated modules' + ls -lha /lib/modules -#Read image + G_DIETPI-NOTIFY 0 "Completed, disk can now be saved to .img for later use, or, reboot system to start first run of DietPi:" -#Resize 2nd parition to mininum size +50MB + #Cleanup + rm dietpi-globals + rm PREP_SYSTEM_FOR_DIETPI.sh + + #Power off system + + #Read image + + #Resize rootfs parition to mininum size +50MB + +} diff --git a/TESTING-BRANCH.md b/TESTING-BRANCH.md index fc3dcbb802..ff88095d7e 100644 --- a/TESTING-BRANCH.md +++ b/TESTING-BRANCH.md @@ -3,5 +3,5 @@ 1. Write the DietPi image to SD card. 2. Open the file on the 1st partition ```/boot/dietpi.txt``` -3. Change ```gitbranch=master``` to ```gitbranch=testing``` (located at the bottom of file) +3. Change ```DEV_GITBRANCH=master``` to ```DEV_GITBRANCH=testing``` (located at the bottom of file) 4. Save the file, eject media and power on. \ No newline at end of file diff --git a/boot_xu4.ini b/boot_xu4.ini index 7ef4236360..080267f7f2 100644 --- a/boot_xu4.ini +++ b/boot_xu4.ini @@ -10,7 +10,7 @@ setenv macaddr "00:1e:06:61:7a:72" #------------------------------------------------------------------------------------------------------ # Basic Ubuntu Setup. Don't touch unless you know what you are doing. # -------------------------------- -setenv bootrootfs "console=tty1 root=UUID=a4f12232-1670-43f4-8eca-49bfbe4d01ee rootwait ro fsck.repair=yes" +setenv bootrootfs "console=tty1 root=UUID=e139ce78-9841-40fe-8823-96a304a09859e rootwait ro fsck.repair=yes" # --- Screen Configuration for HDMI --- # setenv videoconfig "drm_kms_helper.edid_firmware=edid/1920x1080.bin" diff --git a/dietpi.txt b/dietpi.txt index e81150a588..464d190ed2 100644 --- a/dietpi.txt +++ b/dietpi.txt @@ -1,224 +1,236 @@ #Modifications to /boot/* files, will not be saved when powered on. #Please ensure you edit from the DietPi-RamDisk location /DietPi/* +#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 -# 1st run settings +# DietPi-Automation # All settings below will be applied on the 1st boot of DietPi, ONCE. #------------------------------------------------------------------------------------------------------ -# >> Networking Options ----------------------------- -#If both Ethernet and Wifi are enabled, Wifi will take priority and Ethernet will be disabled. -# 1=enabled -Ethernet_Enabled=1 -Wifi_Enabled=0 - -#Enter your Wifi details below, if applicable (Case Sensitive). -Wifi_SSID=MySuperDooperWiFi -Wifi_KEY=0123456789 + +##### Networking Options ##### + +# If both Ethernet and Wifi are enabled, Wifi will take priority and Ethernet will be disabled. +# 1=enabled +AUTO_SETUP_NET_ETHERNET_ENABLED=1 +AUTO_SETUP_NET_WIFI_ENABLED=0 + +# Enter your Wifi details below, if applicable (Case Sensitive). +AUTO_SETUP_NET_WIFI_SSID=MySuperDooperWiFi +AUTO_SETUP_NET_WIFI_KEY=0123456789 # available | WPA-PSK / NONE | WEP=No longer supported -Wifi_KEYMGR=WPA-PSK - -#Enter your Static Network details below, if applicable. -Use_Static=0 -Static_IP=192.168.0.100 -Static_Mask=255.255.255.0 -Static_Gateway=192.168.0.1 -Static_DNS=8.8.8.8 - -#Hostname -Hostname=DietPi - -#Force ethernet speeds -#NB: This is mainly aimed towards Pine A64's which may have a HW issue that causes unstable 1Gbit link. -# 0=automatic speed | 10 = 10mbit, 100 = 100mbit etc -Ethernet_Force_Speed=0 - -# >> Misc Options ----------------------------------- -#Size of dphys-swapfile to generate (MB) -# 0=Disabled | 1=auto (1GB-RAM = size) | 2+=manual -Swapfile_Size=1 - -# >> Automation Options ----------------------------- -#NB: Following options are only executed on 1st run of DietPi. - -#Fully automate installation -# 1=Automated installation with no user inputs. -AUTO_Install_Enable=0 - -#Global Password to be applied for the system -# Affects user "root" and "dietpi" login passwords, and, all software installed by dietpi-software, that requires a password -# eg: MySQL, Transmission, Deluge etc. -# WARN: Passwords with the any of the following characters are not supported: \"$ -# WARN: Do NOT change this entry, after 1st run setup of DietPi has been completed. It is always scraped by dietpi-software. -AUTO_Global_Password=dietpi - -#DietPi-Software to automatically install. | requires AUTO_Install_Enable=1 +AUTO_SETUP_NET_WIFI_KEYMGR=WPA-PSK + +# Enter your Static Network details below, if applicable. +AUTO_SETUP_NET_USESTATIC=0 +AUTO_SETUP_NET_STATIC_IP=192.168.0.100 +AUTO_SETUP_NET_STATIC_MASK=255.255.255.0 +AUTO_SETUP_NET_STATIC_GATEWAY=192.168.0.1 +AUTO_SETUP_NET_STATIC_DNS=8.8.8.8 + +# Hostname +AUTO_SETUP_NET_HOSTNAME=DietPi + +# Force ethernet speeds +# NB: This is mainly aimed towards Pine A64's which may have a HW issue that causes unstable 1Gbit link. +# 0=automatic speed | 10 = 10mbit, 100 = 100mbit etc +AUTO_SETUP_NET_ETH_FORCE_SPEED=0 + +##### Misc Options ##### + +# Size of dphys-swapfile to generate (MB) +# 0=Disabled | 1=auto (2GB-RAM = size) | 2+=manual +AUTO_SETUP_SWAPFILE_SIZE=1 + +##### Software Automation Options ##### + +# Fully automate installation +# 1=Automated installation with no user inputs. +# It is HIGHLY recommended to also set CONFIG_BOOT_WAIT_FOR_NETWORK=2, to force infinite wait for network connection during boot, preventing no connection errors due to timeout. +AUTO_SETUP_AUTOMATED=0 + +# Global Password to be applied for the system +# Affects user "root" and "dietpi" login passwords, and, all software installed by dietpi-software, that requires a password +# eg: MySQL, Transmission, Deluge etc. +# WARN: Passwords with the any of the following characters are not supported: \"$ +# WARN: Do NOT change this entry after 1st run setup of DietPi has been completed. It is always scraped by dietpi-software. +AUTO_SETUP_GLOBAL_PASSWORD=dietpi + +# DietPi-Software to automatically install. | requires AUTO_SETUP_AUTOMATED=1 # For a list of software index's (ID's), run '/DietPi/dietpi/dietpi-software list' -# No limit on number entires, add as many as you need and uncomment the line. +# No limit on number entries, add as many as you need and uncomment the line. # DietPi will automatically install all pre-reqs (eg: ALSA/XSERVER for desktops etc) # - Examples: -#AUTO_DietpiSoftware_Install_ID=23 #will install Desktop LXDE -#AUTO_DietpiSoftware_Install_ID=74 #will install LAMP webserver stack -#AUTO_DietpiSoftware_Install_ID=44 #will install Bittorrent transmission - -#DietPi-Software Choice System -#SSH Server Selection: -# 0=none -# -1=dropbear -# -2=opensshserver -AUTO_DietpiSoftware_SSHServerIndex=-1 - -#File Server Selection: -# 0=none/manual -# -1=proftp -# -2=samba -AUTO_DietpiSoftware_FileServerIndex=0 - -#Logging Mode Selection: -# 0=none/manual -# -1=ramlog 1h clear -# -2=ramlog 1h save clear -# -3=logrotate + rsyslog -AUTO_DietpiSoftware_LoggingIndex=-1 - -#Webserver Preference Selection: -# NB: This will get ignored, if you have manually selected any WEBSERVER_Stacks. -# 0=Apache2 -# -1=Nginx -# -2=Lighttpd -AUTO_DietpiSoftware_WebserverIndex=-2 - -#DietPi-Autostart | Requires AUTO_Install_Enable=1 -# After installation is completed, which program should the system boot to? -# 0=Console 7=Console+auto root login | 1=Kodi 2=Desktops (LXDE/MATE etc) 5=DietPi-Cloudshell 6=Uae4ARM (Fastboot) 8=Uae4ARM (standard boot) 9=dxx-rebirth -AUTO_AutoStartTarget=0 - -#Language/Regional settings | Requires AUTO_Install_Enable=1 -# Timezone eg: Europe/London America/New_York | Full list (TZ*): https://en.wikipedia.org/wiki/List_of_tz_database_time_zones -AUTO_Timezone=Europe/London -# Locale eg: en_GB OR en_US etc. One entry ONLY. DietPi automatically applies .UTF-8 to your locale | Full list: cat /etc/locale.gen -AUTO_Locale=en_GB -# Keyboard Layout eg: gb us de fr -AUTO_KeyboardLayout=gb - -#Custom Script | Requires AUTO_Install_Enable=1 -# Allows you to automatically execute a custom script at the end of DietPi installation. -# Option 1 = Copy your script to /boot/Automation_Custom_Script.sh and it will be executed automatically. -# Option 2 = Host your script online, then use AUTO_CustomScriptURL=http://myweb.com/myscript.sh , it will be downloaded and executed automatically. | 0=disabled -AUTO_CustomScriptURL=0 +#AUTO_SETUP_INSTALL_SOFTWARE_ID=23 #will install Desktop LXDE +#AUTO_SETUP_INSTALL_SOFTWARE_ID=74 #will install LAMP webserver stack +#AUTO_SETUP_INSTALL_SOFTWARE_ID=44 #will install Bittorrent transmission + +# DietPi-Software Choice System +# SSH Server Selection: +# 0=none +# -1=dropbear +# -2=opensshserver +AUTO_SETUP_SSH_SERVER_INDEX=-1 + +# File Server Selection: +# 0=none/manual +# -1=proftp +# -2=samba +AUTO_SETUP_FILE_SERVER_INDEX=0 + +# Logging Mode Selection: +# 0=none/manual +# -1=ramlog 1h clear +# -2=ramlog 1h save clear +# -3=logrotate + rsyslog +AUTO_SETUP_LOGGING_INDEX=-1 + +# Webserver Preference Selection: +# NB: This will get ignored, if you have manually selected any WEBSERVER_Stack. +# 0=Apache2 +# -1=Nginx +# -2=Lighttpd +AUTO_SETUP_WEB_SERVER_INDEX=-2 + +# DietPi-Autostart | Requires AUTO_SETUP_AUTOMATED=1 +# After installation is completed, which program should the system boot to? +# 0=Console 7=Console+auto root login | 1=Kodi 2=Desktops (LXDE/MATE etc) 5=DietPi-Cloudshell 6=Uae4ARM (Fastboot) 8=Uae4ARM (standard boot) 9=dxx-rebirth +AUTO_SETUP_AUTOSTART_TARGET_INDEX=0 + +# Language/Regional settings | Requires AUTO_SETUP_AUTOMATED=1 +# Timezone eg: Europe/London America/New_York | Full list (TZ*): https://en.wikipedia.org/wiki/List_of_tz_database_time_zones +AUTO_SETUP_TIMEZONE=Europe/London +# Locale eg: en_GB.UTF-8 / en_US.UTF-8 etc. One entry ONLY. +AUTO_SETUP_LOCALE=en_GB.UTF-8 +# Keyboard Layout eg: gb us de fr +AUTO_SETUP_KEYBOARD_LAYOUT=gb + +# Custom Script | Requires AUTO_SETUP_AUTOMATED=1 +# Allows you to automatically execute a custom script at the end of DietPi installation. +# Option 1 = Copy your script to /boot/Automation_Custom_Script.sh and it will be executed automatically. +# Option 2 = Host your script online, then use AUTO_SETUP_CUSTOM_SCRIPT_EXEC=http://myweb.com/myscript.sh , it will be downloaded and executed automatically. | 0=disabled +AUTO_SETUP_CUSTOM_SCRIPT_EXEC=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) -rpi_hdmi_output=1 +CONFIG_HDMI_OUTPUT=1 #Cpu Governor | ondemand | powersave | performance | conservative -cpu_governor=ondemand -cpu_usage_throttle_up=50 +CONFIG_CPU_GOVERNOR=ondemand +CONFIG_CPU_USAGE_THROTTLE_UP=50 #Limit the max cpu frequency (Mhz) for all cores. | Disabled=disabled | Useful for lowering temp/power usage on your device. -cpu_max_frequency=Disabled +CONFIG_CPU_MAX_FREQ=Disabled #Limit the min cpu frequency (Mhz) for all cores. | Disabled=disabled | Useful for 1-wire correct support (eg. 480Mhz). -cpu_min_frequency=Disabled +CONFIG_CPU_MIN_FREQ=Disabled #Min value 10000 microseconds (10ms) -cpu_ondemand_sampling_rate=25000 +CONFIG_CPU_ONDEMAND_SAMPLE_RATE=25000 -#sampling rate * down factor / 1000 = Miliseconds (40 = 1000ms when sampling rate is 25000) -cpu_ondemand_sampling_down_factor=80 +#sampling rate * down factor / 1000 = Milliseconds (40 = 1000ms when sampling rate is 25000) +CONFIG_CPU_ONDEMAND_SAMPLE_DOWNFACTOR=80 #Samba Client Details (Used by DietPi-Config | Networking NAS | Samba Client) -SambaClient_ComputerName=computername -SambaClient_ShareName=sharename -SambaClient_Username=username -SambaClient_Password=password +# NB: Do not modify, you must use dietpi-config to configure/set options +CONFIG_SMBCLIENT_COMPUTERNAME=computername +CONFIG_SMBCLIENT_SHARENAME=sharename +CONFIG_SMBCLIENT_USERNAME=username +CONFIG_SMBCLIENT_PASSWORD=password #FTP Client Filesystem Mount (CurlFtpFs) (Used by DietPi-Config | Networking NAS | FTP Client) -curlftpfs_clientaddress=192.168.0.100 -curlftpfs_clientusername=username -curlftpfs_clientpassword=password +# NB: Do not modify, you must use dietpi-config to configure/set options +CONFIG_CURLFTPFS_ADDRESS=192.168.0.100 +CONFIG_CURLFTPFS_USERNAME=username +CONFIG_CURLFTPFS_PASSWORD=password #NFS Client Filesystem Mount (Used by DietPi-Config | Networking NAS | NFS Client) -nfsclient_ipaddress= +# NB: Do not modify, you must use dietpi-config to configure/set options +CONFIG_NFSCLIENT_ADDRESS= #Proxy settings | System-wide proxy settings. Use dietpi-config > networking options to apply. -proxy_enabled=0 -proxy_address=MyProxyServer.com -proxy_port=8080 -proxy_username= -proxy_password= +# NB: Do not modify, you must use dietpi-config to configure/set options +CONFIG_PROXY_ENABLED=0 +CONFIG_PROXY_ADDRESS=MyProxyServer.com +CONFIG_PROXY_PORT=8080 +CONFIG_PROXY_USERNAME= +CONFIG_PROXY_PASSWORD= #Delay boot until network is established: 0=disabled | 1=10 second wait max (default) | 2=infinite wait -boot_wait_for_network=1 +CONFIG_BOOT_WAIT_FOR_NETWORK=1 #DietPi check for updates (allows dietpi to check for updates on a daily basis and boot using a <1kb file download.) -dietpi_check_for_updates=1 +CONFIG_CHECK_DIETPI_UPDATES=1 #NTPD Update Mode: 0=disabled | 1=boot only | 2=boot + daily | 3=boot + hourly | 4=Daemon + Drift -ntpd_update_mode=2 - -#Wifi Hotspot -wifi_hotspot_ssid=DietPi-HotSpot -# - minimum of 8 characters -wifi_hotspot_key=dietpihotspot -wifi_hotspot_channel=3 +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 -wifi_country_code=GB +CONFIG_WIFI_COUNTRY_CODE=GB #Serial Console: Set to 1 if you require a serial console during 1st run of DietPi. -serial_console_enabled=0 +CONFIG_SERIAL_CONSOLE_ENABLE=0 #Soundcard -soundcard=none +CONFIG_SOUNDCARD=none #LCD Panel addon -lcdpanel=none +# NB: Do not modify, you must use dietpi-config to configure/set options +CONFIG_LCDPANEL=none -#Prefer IPversion (for: apt-get) | auto (let system decide) / ipv4 (force) / ipv6 (force) | eg: force IPv4 with prefer_ipversion=ipv4 -prefer_ipversion=auto +#Prefer IPversion (for: APT, wget) | auto (let system decide) / ipv4 (force) / ipv6 (prefer) | eg: force IPv4 with CONFIG_PREFER_IPVERSION=ipv4 +CONFIG_PREFER_IPVERSION=ipv4 #Apt mirrors which are applied to /etc/apt/sources.list | Values here will also be applied during 1st run setup # Raspbian = https://www.raspbian.org/RaspbianMirrors # Debian = https://www.debian.org/mirror/official#list -Apt_Raspbian_Mirror=https://www.mirrorservice.org/sites/archive.raspbian.org/raspbian -Apt_Debian_Mirror=http://ftp.debian.org/debian/ +CONFIG_APT_RASPBIAN_MIRROR=https://www.mirrorservice.org/sites/archive.raspbian.org/raspbian +CONFIG_APT_DEBIAN_MIRROR=https://deb.debian.org/debian/ #NTPD mirror, applied to /etc/ntp.conf # For a full list, please see http://www.pool.ntp.org # Please remove the initial interger and full stop from the value (removing 0.). eg: debian.pool.ntp.org -NTPD_Mirror=debian.pool.ntp.org +CONFIG_NTP_MIRROR=debian.pool.ntp.org #------------------------------------------------------------------------------------------------------ # D I E T - P I # DietPi-Software settings. #------------------------------------------------------------------------------------------------------ #Enter your EmonCMS.org write API key here. It will be applied automatically during EmonPi/Hub installation. -# - eg: dietpi_emonhub_apikey=b4dfmk2o203mmxx93a -dietpi_emonhub_apikey= +# eg: SOFTWARE_EMONHUB_APIKEY=b4dfmk2o203mmxx93a +SOFTWARE_EMONHUB_APIKEY= #VNC Server Options -dietpi_vncserver_width=1280 -dietpi_vncserver_height=720 -dietpi_vncserver_depth=16 -dietpi_vncserver_display=1 -dietpi_vncserver_shared_desktop=0 +SOFTWARE_VNCSERVER_WIDTH=1280 +SOFTWARE_VNCSERVER_HEIGHT=720 +SOFTWARE_VNCSERVER_DEPTH=16 +SOFTWARE_VNCSERVER_DISPLAY_INDEX=1 +SOFTWARE_VNCSERVER_SHARE_DESKTOP=0 + +#Optional username for ownCloud/Nextcloud admin account, default is 'admin'. Applied during installation. +SOFTWARE_OWNCLOUD_NEXTCLOUD_USERNAME=admin -#Optional username for nextcloud admin account, default is admin. Applied during installation. -dietpi_nextcloud_username=admin +#Optional data directory for ownCloud, default is '/mnt/dietpi_userdata/owncloud_data'. Applied during installation. +# This option is for advanced users. For full compatibility, please keep this options defaults, and, use dietpi-drive_manager to move the DietPi user data location. +SOFTWARE_OWNCLOUD_DATADIR=/mnt/dietpi_userdata/owncloud_data + +#Optional data directory for Nextcloud, default is '/mnt/dietpi_userdata/nextcloud_data'. Applied during installation. +# This option is for advanced users. For full compatibility, please keep this options defaults, and, use dietpi-drive_manager to move the DietPi user data location. +SOFTWARE_NEXTCLOUD_DATADIR=/mnt/dietpi_userdata/nextcloud_data + +#Wifi Hotspot +SOFTWARE_WIFI_HOTSPOT_SSID=DietPi-HotSpot +# minimum of 8 characters +SOFTWARE_WIFI_HOTSPOT_KEY=dietpihotspot +SOFTWARE_WIFI_HOTSPOT_CHANNEL=3 #------------------------------------------------------------------------------------------------------ # D I E T - P I # Dev settings #------------------------------------------------------------------------------------------------------ -gitbranch=master -gitforkowner=Fourdee - -#Forces a partition resize + expansion of rootfs on next boot. (0=disabled, 1=enabled) -fs_force_resize=0 - -# - Max size of rootfs resize (%) -rootfs_resize_limit=100 +DEV_GITBRANCH=master +DEV_GITOWNER=Fourdee diff --git a/dietpi/.version b/dietpi/.version index b00047941a..cdfade7aba 100644 --- a/dietpi/.version +++ b/dietpi/.version @@ -1 +1,2 @@ -159 \ No newline at end of file +6 +0 diff --git a/dietpi/boot b/dietpi/boot index d2117f8e92..eb9a90abd4 100644 --- a/dietpi/boot +++ b/dietpi/boot @@ -13,38 +13,21 @@ # - activates on boot from /etc/init.d/dietpi-service #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" + #Import DietPi-Globals --------------------------------------------------------------- + /DietPi/dietpi/dietpi-obtain_hw_model # Running for the 1st time + . /DietPi/dietpi/func/dietpi-globals + export G_PROGRAM_NAME='DietPi-Boot' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// #Globals #///////////////////////////////////////////////////////////////////////////////////// FP_LOGFILE='/var/log/dietpi-boot.log' - HW_MODEL=0 - DISTRO=0 - HW_CPUID=0 - - FS_FORCED_EXPANSION=$(cat /DietPi/dietpi.txt | grep -m1 '^fs_force_resize=' | sed 's/.*=//') - - # -3 = first boot / -2 = partition / -1 = filesystem / 0 = run dietpi-software at login / 1 = completed - DIETPI_INSTALL_STAGE=$(cat /DietPi/dietpi/.install_stage) - - Read_Hw_Model(){ - - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) - HW_CPUID=$(sed -n 9p /DietPi/dietpi/.hw_model) - - } - RPi_Set_Clock_Speeds(){ #RPi's - if (( $HW_MODEL < 10 )); then + 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 (( $(cat /DietPi/config.txt | grep -ci -m1 '^#over_voltage=') && @@ -53,7 +36,7 @@ $(cat /DietPi/config.txt | grep -ci -m1 '^#sdram_freq=') )); then #RPi v1 - Set safe clock - if (( $HW_MODEL < 2 )); then + 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 @@ -71,7 +54,7 @@ fi #RPi v2 - elif (( $HW_MODEL == 2 )); then + 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 @@ -79,7 +62,7 @@ sed -i '/sdram_freq=/c\#sdram_freq=450' /DietPi/config.txt #RPi v3 - elif (( $HW_MODEL == 3 )); then + elif (( $G_HW_MODEL == 3 )); then sed -i '/over_voltage=/c\#over_voltage=0' /DietPi/config.txt sed -i '/arm_freq=/c\#arm_freq=1200' /DietPi/config.txt @@ -94,63 +77,6 @@ fi } - FS_Partition(){ - - #Force filesystem sync - sync - - local rootfs_resize_limit=$(cat /DietPi/dietpi.txt | grep -m1 '^rootfs_resize_limit=' | sed 's/.*=//') - - local target_partition=$(findmnt / -o source -n | sed 's/.*p//') - local target_dev=$(findmnt / -o source -n) - - # - MMCBLK[0-9]p[0-9] scrape - if [[ "$target_dev" = *"mmcblk"* ]]; then - - target_dev=$(findmnt / -o source -n | sed 's/p[0-9]$//') - - # - Everything else scrape (eg: /dev/sdX[0-9]) - else - - target_dev=$(findmnt / -o source -n | sed 's/[0-9]$//') - - fi - - if (( $rootfs_resize_limit < 100 )); then - - parted -s $target_dev unit % resizepart $target_partition $rootfs_resize_limit% || parted $target_dev unit % resizepart $target_partition Yes $rootfs_resize_limit% - - else - - cat << _EOF_ | fdisk $target_dev -p -d -$target_partition -n -p -$target_partition -$(parted $target_dev -ms unit s p | grep ':ext4::;' | sed 's/:/ /g' | sed 's/s//g' | awk '{ print $2 }') - -p -w - -_EOF_ - - fi - - } - - FS_Expand(){ - - #Force filesystem sync - sync - - #Resize RootFS to new partition size - local target_dev=$(findmnt / -o source -n) - resize2fs $target_dev - - } - Apply_DietPi_FirstRun_Settings(){ #---------------------------------------------------------------- @@ -172,14 +98,14 @@ _EOF_ sed -i "s/wlan0/wlan$index_wlan/g" /etc/network/interfaces #Grab user requested settings from /dietpi.txt - local Ethernet_Enabled=$(cat /DietPi/dietpi.txt | grep -ci -m1 'Ethernet_Enabled=1') - local Wifi_Enabled=$(cat /DietPi/dietpi.txt | grep -ci -m1 'Wifi_Enabled=1') + local Ethernet_Enabled=$(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_SETUP_NET_ETHERNET_ENABLED=1') + local Wifi_Enabled=$(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_SETUP_NET_WIFI_ENABLED=1') - local Use_Static=$(cat /DietPi/dietpi.txt | grep -ci -m1 '^Use_Static=1') - local Static_IP=$(cat /DietPi/dietpi.txt | grep -m1 '^Static_IP' | sed 's/.*=//') - local Static_Mask=$(cat /DietPi/dietpi.txt | grep -m1 '^Static_Mask' | sed 's/.*=//') - local Static_Gateway=$(cat /DietPi/dietpi.txt | grep -m1 '^Static_Gateway' | sed 's/.*=//') - local Static_Dns=$(cat /DietPi/dietpi.txt | grep -m1 '^Static_DNS' | sed 's/.*=//') + local Use_Static=$(cat /DietPi/dietpi.txt | grep -ci -m1 '^AUTO_SETUP_NET_USESTATIC=1') + local Static_IP=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_NET_STATIC_IP=' | sed 's/.*=//') + local Static_Mask=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_NET_STATIC_MASK=' | sed 's/.*=//') + local Static_Gateway=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_NET_STATIC_GATEWAY=' | sed 's/.*=//') + local Static_Dns=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_NET_STATIC_DNS=' | sed 's/.*=//') # - Wifi if (( $Wifi_Enabled == 1 )); then @@ -245,7 +171,7 @@ _EOF_ fi #Apply forced eth speed if set in dietpi.txt - /DietPi/dietpi/func/dietpi-set_hardware eth-forcespeed $(cat /DietPi/dietpi.txt | grep -m1 '^Ethernet_Force_Speed=' | sed 's/.*=//' ) + /DietPi/dietpi/func/dietpi-set_hardware eth-forcespeed $(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_NET_ETH_FORCE_SPEED=' | sed 's/.*=//' ) #Wait for active connection, then update network details file Wait_For_Valid_Network_Connection @@ -258,7 +184,7 @@ _EOF_ local max_loops=1 # Wait mode, max time - local boot_wait_for_network=$(cat /DietPi/dietpi.txt | grep -m1 '^boot_wait_for_network=' | sed 's/.*=//') + local boot_wait_for_network=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_BOOT_WAIT_FOR_NETWORK=' | sed 's/.*=//') if (( $boot_wait_for_network == 1 )); then max_loops=10 @@ -271,18 +197,18 @@ _EOF_ if (( $loop_count >= $max_loops )); then - /DietPi/dietpi/func/dietpi-notify 1 "$(date) | Valid connection wait timed out." | tee -a "$FP_LOGFILE" + G_DIETPI-NOTIFY 1 "$(date) | Valid connection wait timed out." | tee -a "$FP_LOGFILE" break elif (( ! $(route | awk '{print $4}' | grep -ci -m1 'UG') )); then - /DietPi/dietpi/func/dietpi-notify 2 "$(date) | Waiting for valid connection, before continuing boot | Mode=$boot_wait_for_network" | tee -a "$FP_LOGFILE" + G_DIETPI-NOTIFY 2 "$(date) | Waiting for valid connection, before continuing boot | Mode=$boot_wait_for_network" | tee -a "$FP_LOGFILE" sleep 1 else # - Update network details (for IP in dietpi-banner etc..) - /DietPi/dietpi/func/dietpi-notify 0 "$(date) | Valid connection found." | tee -a "$FP_LOGFILE" + G_DIETPI-NOTIFY 0 "$(date) | Valid connection found." | tee -a "$FP_LOGFILE" /DietPi/dietpi/func/obtain_network_details # Mount all drives again (eg: network shares) @@ -304,20 +230,18 @@ _EOF_ Run_Init(){ + #---------------------------------------------------------------- + #WiFi Country | Additional fallback for (older kernel?) devices that fail with wpa_supplicant.conf https://github.com/Fourdee/DietPi/issues/838 + iw reg set $(grep -m1 '^CONFIG_WIFI_COUNTRY_CODE=' /DietPi/dietpi.txt | sed 's/.*=//') &> /dev/null & #---------------------------------------------------------------- #Update NTP /DietPi/dietpi/func/run_ntpd & #---------------------------------------------------------------- - #Write HW model and details to file - /DietPi/dietpi/dietpi-obtain_hw_model - #Read Hw model - Read_Hw_Model - #---------------------------------------------------------------- #Apply LED triggers if set /DietPi/dietpi/func/dietpi-led_control 1 & #---------------------------------------------------------------- #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. - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then amixer set PCM -- -010 &> /dev/null & @@ -327,8 +251,8 @@ _EOF_ /DietPi/dietpi/dietpi-cpu_set & #---------------------------------------------------------------- #Disable RPi hdmi output if set in dietpi.txt - if (( $HW_MODEL < 10 && - $(cat /DietPi/dietpi.txt | grep -ci -m1 '^rpi_hdmi_output=0'))); then + if (( $G_HW_MODEL < 10 && + $(cat /DietPi/dietpi.txt | grep -ci -m1 '^CONFIG_HDMI_OUTPUT=0'))); then #FBset value below allows for reduced memory bandwidth usage from VideoCore (eg: Faster RAM bandwidth/performance) fbset -xres 16 -yres 16 -vxres 16 -vyres 16 -depth 8 &> /dev/null @@ -358,7 +282,7 @@ _EOF_ #Workaround: Wlan currently fails to connect during boot, so, manually drop and reconnect: https://github.com/Fourdee/DietPi/issues/602#issuecomment-262806470 # OPi Zero 2 / Neo Air - if (( $HW_MODEL == 35 || $HW_MODEL == 64 )); then + if (( $G_HW_MODEL == 35 || $G_HW_MODEL == 64 )); then ifdown wlan0 ifup wlan0 @@ -375,33 +299,13 @@ _EOF_ # Init Run_Init - #---------------------------------------------------------------- - #Filesystem expansion only (eg: for pre-installed images) - if (( $FS_FORCED_EXPANSION == 1 )); then - - FS_Partition - - sed -i '/fs_force_resize=/c\fs_force_resize=2' /DietPi/dietpi.txt - - reboot - #---------------------------------------------------------------- #Normal Boot - elif (( $DIETPI_INSTALL_STAGE == 1 )); then - - if (( $FS_FORCED_EXPANSION == 2 )); then - - FS_Expand - - sed -i '/fs_force_resize=/c\fs_force_resize=0' /DietPi/dietpi.txt - - /DietPi/dietpi/func/dietpi-set_dphys-swapfile $(cat /DietPi/dietpi.txt | grep -m1 '^Swapfile_Size=' | sed 's/.*=//' ) - - fi + if (( $G_DIETPI_INSTALL_STAGE == 1 )); then Wait_For_Valid_Network_Connection - if (( $( cat /DietPi/dietpi.txt | grep -ci -m1 '^dietpi_check_for_updates=1') )); then + if (( $( cat /DietPi/dietpi.txt | grep -ci -m1 '^CONFIG_CHECK_DIETPI_UPDATES=1') )); then #Check for DietPi updates (+thread) echo -e "$(date) | +Thread: checking for DietPi-Updates" >> "$FP_LOGFILE" @@ -412,8 +316,8 @@ _EOF_ /DietPi/dietpi/dietpi-banner 1 #---------------------------------------------------------------- - #Filesystem prep, stage 1/2 - elif (( $DIETPI_INSTALL_STAGE == -3 )); then + #First run prep + elif (( $G_DIETPI_INSTALL_STAGE == -1 )); then # Set RPi v1 safe overclocking profile (900mhz) RPi_Set_Clock_Speeds @@ -421,44 +325,41 @@ _EOF_ /DietPi/dietpi/dietpi-banner 0 #Set hostname - /DietPi/dietpi/func/change_hostname "$(cat /DietPi/dietpi.txt | grep -m1 '^Hostname=' | sed 's/.*=//')" + /DietPi/dietpi/func/change_hostname "$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_NET_HOSTNAME=' | sed 's/.*=//')" #Automation # - Set auto login for next bootup - if (( $(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_Install_Enable=' | sed 's/.*=//') >= 1 )); then + if (( $(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_AUTOMATED=' | sed 's/.*=//') >= 1 )); then /DietPi/dietpi/dietpi-autostart 7 fi # - Enable serial console? - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^serial_console_enabled=1') )); then + if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^CONFIG_SERIAL_CONSOLE_ENABLE=1') )); then /DietPi/dietpi/func/dietpi-set_hardware serialconsole enable fi # - Set root password? - root_password=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_Global_Password=' | sed 's/.*=//') - if [ -n "$root_password" ]; then + ROOT_PASSWORD=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_GLOBAL_PASSWORD=' | sed 's/.*=//') + if [ -n "$ROOT_PASSWORD" ]; then - chpasswd <<< "root:$root_password" - chpasswd <<< "dietpi:$root_password" + chpasswd <<< "root:$ROOT_PASSWORD" + chpasswd <<< "dietpi:$ROOT_PASSWORD" fi # - Set apt mirror - local target_repo='Apt_Debian_Mirror' - if (( $HW_MODEL < 10 )); then + TARGET_REPO='CONFIG_APT_DEBIAN_MIRROR' + if (( $G_HW_MODEL < 10 )); then - target_repo='Apt_Raspbian_Mirror' + TARGET_REPO='CONFIG_APT_RASPBIAN_MIRROR' fi - /DietPi/dietpi/func/dietpi-set_software apt-mirror $(cat /DietPi/dietpi.txt | grep -m1 "^$target_repo=" | sed 's/.*=//') - - # - Set NTPD mirror - /DietPi/dietpi/func/dietpi-set_software ntpd-mirror $(cat /DietPi/dietpi.txt | grep -m1 '^NTPD_Mirror=' | sed 's/.*=//') + /DietPi/dietpi/func/dietpi-set_software apt-mirror $(grep -m1 "^$TARGET_REPO=" /DietPi/dietpi.txt | sed 's/.*=//') #Disable /tmp tmpfs if RAM <= 512MB: https://github.com/Fourdee/DietPi/issues/1027 if (( $(free -m | grep -m1 'Mem:' | awk '{print $2}') <= 512 )); then @@ -469,23 +370,6 @@ _EOF_ fi - FS_Partition - - echo -2 > /DietPi/dietpi/.install_stage - - reboot - - #---------------------------------------------------------------- - #Filesystem prep, stage 2/2 - elif (( $DIETPI_INSTALL_STAGE == -2 )); then - - #Expand rootFS - FS_Expand - echo -1 > /DietPi/dietpi/.install_stage - - #Enable/Create swapfile. - /DietPi/dietpi/func/dietpi-set_dphys-swapfile $(cat /DietPi/dietpi.txt | grep -m1 '^Swapfile_Size=' | sed 's/.*=//' ) - #Generate unique Dropbear host-key: rm /etc/dropbear/*key &> /dev/null dropbearkey -t rsa -f /etc/dropbear/dropbear_rsa_host_key &> /dev/null @@ -495,6 +379,9 @@ _EOF_ Workaround_WiFi + # - Set NTPD + /DietPi/dietpi/func/dietpi-set_software ntpd-mode $(grep -m1 '^CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/.*=//') + #Finished /DietPi/dietpi/dietpi-banner 0 echo -e " Default Login:\n Username = root\n Password = dietpi\n" diff --git a/dietpi/conf/brutefir.service b/dietpi/conf/brutefir.service index 8412ba07d9..5470aeefed 100644 --- a/dietpi/conf/brutefir.service +++ b/dietpi/conf/brutefir.service @@ -7,7 +7,7 @@ # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com # # Info: - # - Location /etc/dietpi/dietpi-software/services/brutefir + # - Location /var/lib/dietpi/dietpi-software/services/brutefir # - Called from /DietPi/dietpi/dietpi-services # #//////////////////////////////////// diff --git a/dietpi/conf/cron.daily_dietpi b/dietpi/conf/cron.daily_dietpi index c40614d36d..904435a165 100644 --- a/dietpi/conf/cron.daily_dietpi +++ b/dietpi/conf/cron.daily_dietpi @@ -10,7 +10,7 @@ # #//////////////////////////////////// - NTPD_UPDATE_MODE=$(cat /DietPi/dietpi.txt | grep -m1 '^ntpd_update_mode=' | sed 's/.*=//') + NTPD_UPDATE_MODE=$(grep -m1 '^CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/.*=//') #---------------------------------------------------------------- # Main Loop @@ -23,7 +23,7 @@ fi #---------------------------------------------------------------- #check for dietpi updates - if (( $(grep -ci -m1 'dietpi_check_for_updates=1' /DietPi/dietpi.txt) == 1 )); then + if (( $(grep -ci -m1 'CONFIG_CHECK_DIETPI_UPDATES=1' /DietPi/dietpi.txt) == 1 )); then /DietPi/dietpi/dietpi-update 2 &> /dev/null & fi #---------------------------------------------------------------- diff --git a/dietpi/conf/cron.hourly_dietpi b/dietpi/conf/cron.hourly_dietpi index 3ba603b68d..fd66d6b89f 100644 --- a/dietpi/conf/cron.hourly_dietpi +++ b/dietpi/conf/cron.hourly_dietpi @@ -17,7 +17,7 @@ fi - NTPD_UPDATE_MODE=$(cat /DietPi/dietpi.txt | grep -m1 '^ntpd_update_mode=' | sed 's/.*=//') + NTPD_UPDATE_MODE=$(grep -m1 '^CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/.*=//') #---------------------------------------------------------------- # Main Loop diff --git a/dietpi/conf/fstab b/dietpi/conf/fstab deleted file mode 100644 index 15bfabfa71..0000000000 --- a/dietpi/conf/fstab +++ /dev/null @@ -1,19 +0,0 @@ -#Internal Drives--------------------------------------------------- -proc /proc proc defaults 0 0 -/dev/mmcblk0p1 /boot auto defaults,noatime,discard 0 2 -/dev/mmcblk0p2 / auto defaults,noatime,discard 0 1 -tmpfs /tmp tmpfs defaults,noatime,nodev,nosuid,mode=1777 0 0 -tmpfs /var/log tmpfs defaults,size=20m,noatime,nodev,nosuid,mode=1777 0 0 -tmpfs /DietPi tmpfs defaults,size=10m,noatime,nodev,nosuid,mode=1777 0 0 - -#Samba Client------------------------------------------------------ -#/mnt/samba . Please use dietpi-config and the Networking Options: NAS menu to setup this mount - -#FTP Client Mount-------------------------------------------------- -#/mnt/ftp_client . Please use dietpi-config and the Networking Options: NAS menu to setup this mount - -#NFS Client Mount-------------------------------------------------- -#/mnt/nfs_client . Please use dietpi-config and the Networking Options: NAS menu to setup this mount - -#External Drives--------------------------------------------------- -#NB: Please use dietpi-drive_manager to setup and control your external drives. diff --git a/dietpi/conf/fstab_rock64 b/dietpi/conf/fstab_rock64 deleted file mode 100644 index 3982d78cda..0000000000 --- a/dietpi/conf/fstab_rock64 +++ /dev/null @@ -1,19 +0,0 @@ -#Internal Drives--------------------------------------------------- -proc /proc proc defaults 0 0 -PARTUUID=1ad0eca1-3f39-40c8-be44-c07adeeb5917 /boot/efi auto defaults,noatime,discard 0 2 -PARTUUID=c1cae5b3-08a0-4d9f-97fd-890fbac03de6 / auto defaults,noatime,discard 0 1 -tmpfs /tmp tmpfs defaults,noatime,nodev,nosuid,mode=1777 0 0 -tmpfs /var/log tmpfs defaults,size=20m,noatime,nodev,nosuid,mode=1777 0 0 -tmpfs /DietPi tmpfs defaults,size=10m,noatime,nodev,nosuid,mode=1777 0 0 - -#Samba Client------------------------------------------------------ -#/mnt/samba . Please use dietpi-config and the Networking Options: NAS menu to setup this mount - -#FTP Client Mount-------------------------------------------------- -#/mnt/ftp_client . Please use dietpi-config and the Networking Options: NAS menu to setup this mount - -#NFS Client Mount-------------------------------------------------- -#/mnt/nfs_client . Please use dietpi-config and the Networking Options: NAS menu to setup this mount - -#External Drives--------------------------------------------------- -#NB: Please use dietpi-drive_manager to setup and control your external drives. diff --git a/dietpi/conf/fstab_vm b/dietpi/conf/fstab_vm deleted file mode 100644 index b3c0a6e84b..0000000000 --- a/dietpi/conf/fstab_vm +++ /dev/null @@ -1,14 +0,0 @@ -#Internal Drives--------------------------------------------------- -UUID=044766be-96ca-491a-a93f-913b75a843bd / ext4 defaults,noatime,nodiratime,errors=remount-ro 0 1 -tmpfs /tmp tmpfs defaults,noatime,nodev,nosuid,mode=1777 0 0 -tmpfs /var/log tmpfs defaults,size=20m,noatime,nodev,nosuid,mode=1777 0 0 -tmpfs /DietPi tmpfs defaults,size=10m,noatime,nodev,nosuid,mode=1777 0 0 - -#Samba Client------------------------------------------------------ -#/mnt/samba . Please use dietpi-config and the networking menu to setup this mount - -#FTP Client Mount-------------------------------------------------- -#/mnt/ftp_client . Please use dietpi-config and the networking menu to setup this mount - -#External Drives--------------------------------------------------- -#NB: Please use dietpi-drive_manager to setup and control your external drives. diff --git a/dietpi/conf/fstab_x86_64-native b/dietpi/conf/fstab_x86_64-native deleted file mode 100644 index 9701a8fc18..0000000000 --- a/dietpi/conf/fstab_x86_64-native +++ /dev/null @@ -1,15 +0,0 @@ -#Internal Drives--------------------------------------------------- -UUID=497d51ff-a4c5-4ead-9195-329f4d97ac66 / ext4 noatime,nodiratime,errors=remount-ro 0 1 -UUID=c796bac5-7cf9-464f-aecd-788904a1b3da /boot ext4 noatime,nodiratime 0 2 -tmpfs /tmp tmpfs defaults,noatime,nodev,nosuid,mode=1777 0 0 -tmpfs /var/log tmpfs defaults,size=20m,noatime,nodev,nosuid,mode=1777 0 0 -tmpfs /DietPi tmpfs defaults,size=10m,noatime,nodev,nosuid,mode=1777 0 0 - -#Samba Client------------------------------------------------------ -#/mnt/samba . Please use dietpi-config and the networking menu to setup this mount - -#FTP Client Mount-------------------------------------------------- -#/mnt/ftp_client . Please use dietpi-config and the networking menu to setup this mount - -#External Drives--------------------------------------------------- -#NB: Please use dietpi-drive_manager to setup and control your external drives. diff --git a/dietpi/conf/fstab_x86_64-native_EFI b/dietpi/conf/fstab_x86_64-native_EFI deleted file mode 100644 index 9c2b5a7951..0000000000 --- a/dietpi/conf/fstab_x86_64-native_EFI +++ /dev/null @@ -1,19 +0,0 @@ -#Internal Drives--------------------------------------------------- -proc /proc proc defaults 0 0 -UUID=CA7A-8CED /boot/efi auto defaults,noatime,discard 0 2 -UUID=e1efd31c-5b47-4db1-b600-7954f833f9f5 / auto defaults,noatime,discard 0 1 -tmpfs /tmp tmpfs defaults,noatime,nodev,nosuid,mode=1777 0 0 -tmpfs /var/log tmpfs defaults,size=20m,noatime,nodev,nosuid,mode=1777 0 0 -tmpfs /DietPi tmpfs defaults,size=10m,noatime,nodev,nosuid,mode=1777 0 0 - -#Samba Client------------------------------------------------------ -#/mnt/samba . Please use dietpi-config and the Networking Options: NAS menu to setup this mount - -#FTP Client Mount-------------------------------------------------- -#/mnt/ftp_client . Please use dietpi-config and the Networking Options: NAS menu to setup this mount - -#NFS Client Mount-------------------------------------------------- -#/mnt/nfs_client . Please use dietpi-config and the Networking Options: NAS menu to setup this mount - -#External Drives--------------------------------------------------- -#NB: Please use dietpi-drive_manager to setup and control your external drives. diff --git a/dietpi/conf/lighttpd.nextcloud.conf b/dietpi/conf/lighttpd.nextcloud.conf new file mode 100644 index 0000000000..99e9f17b4c --- /dev/null +++ b/dietpi/conf/lighttpd.nextcloud.conf @@ -0,0 +1,6 @@ +# Solve OPcache settings warning on Nextcloud admin panel: +$HTTP["url"] =~ "^/nextcloud($|/)" { + setenv.add-environment += ( + "PHP_ADMIN_VALUE" => "opcache.memory_consumption=128", + ) +} diff --git a/dietpi/conf/raspimjpeg.service b/dietpi/conf/raspimjpeg.service index f55bab0f0c..2dfcdc0aa6 100644 --- a/dietpi/conf/raspimjpeg.service +++ b/dietpi/conf/raspimjpeg.service @@ -7,7 +7,7 @@ # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com # # Info: - # - Location /etc/dietpi/dietpi-software/services/raspimjpeg.service + # - Location /var/lib/dietpi/dietpi-software/services/raspimjpeg.service # - Allows service control for Raspimjpeg and PHP schedule, used by RPI Camera Web # - Called from /DietPi/dietpi/dietpi-services # diff --git a/dietpi/dietpi-autostart b/dietpi/dietpi-autostart index c9c1394e8d..af55182261 100644 --- a/dietpi/dietpi-autostart +++ b/dietpi/dietpi-autostart @@ -16,20 +16,19 @@ # - dietpi-autostart int (set value only) #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - #Grab Input (valid interger) INPUT=-1 if [[ $1 =~ ^-?[0-9]+$ ]]; then + INPUT=$1 + fi - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Autostart' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// # MENUS @@ -74,14 +73,14 @@ cat << _EOF_ > /etc/systemd/system/dietpi-autostart_custom.service [Unit] -Description=DietPi autostart (Custom /etc/dietpi/autostart.sh) +Description=DietPi autostart (Custom /var/lib/dietpi/dietpi-autostart/custom.sh) After=dietpi-boot.service dietpi-ramdisk.service dietpi-ramlog.service rc-local.service Requires=dietpi-boot.service dietpi-ramdisk.service [Service] Type=idle -ExecStartPre=/bin/bash /DietPi/dietpi/func/dietpi-notify 0 'Starting DietPi-Autostart (Custom) script' -ExecStart=/bin/bash -c /etc/dietpi/autostart.sh +ExecStartPre=/bin/bash echo -e 'Starting DietPi-Autostart (Custom) script' +ExecStart=/bin/bash -c /var/lib/dietpi/dietpi-autostart/custom.sh StandardOutput=tty RemainAfterExit=yes @@ -143,7 +142,7 @@ _EOF_ fi #Amiberry (RPi) lower framebuffer size to increase memory performance: https://github.com/Fourdee/DietPi/issues/474#issuecomment-243124631 - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then if (( $AUTO_START_INDEX == 6 || $AUTO_START_INDEX == 8 || $AUTO_START_INDEX == 12 || $AUTO_START_INDEX == 13 )); then @@ -176,7 +175,7 @@ _EOF_ '13' 'AmiBerry SDL2: Standard boot' '10' 'CAVA Spectrum' '11' 'Chromium: Without desktop' - '14' 'Custom: /etc/dietpi/autostart.sh' + '14' 'Custom: /var/lib/dietpi/dietpi-autostart/custom.sh' '2' 'Desktops: Automatic login (recommended)' '16' 'Desktops: LightDM login prompt' '5' 'DietPi-Cloudshell' @@ -208,9 +207,10 @@ _EOF_ if (( $OPTION == 14 )); then # create template - if [ ! -f /etc/dietpi/autostart.sh ]; then + if [ ! -f /var/lib/dietpi/dietpi-autostart/custom.sh ]; then - cat << _EOF_ > /etc/dietpi/autostart.sh + mkdir -p /var/lib/dietpi/dietpi-autostart + cat << _EOF_ > /var/lib/dietpi/dietpi-autostart/custom.sh #!/bin/bash #---Examples--- @@ -227,9 +227,11 @@ _EOF_ _EOF_ + chmod +x /var/lib/dietpi/dietpi-autostart/custom.sh + # Service - whiptail --title "Custom: /etc/dietpi/autostart.sh" --msgbox "A template script has been created:\n - /etc/dietpi/autostart.sh\n\nPlease edit this file and enter the required commands you wish to launch. DietPi will then execute this script during boot." --backtitle "$WHIP_BACKTITLE" 14 70 + whiptail --title "Custom: /var/lib/dietpi/dietpi-autostart/custom.sh" --msgbox "A template script has been created:\n - /var/lib/dietpi/dietpi-autostart/custom.sh\n\nPlease edit this file and enter the required commands you wish to launch. DietPi will then execute this script during boot." --backtitle "$WHIP_BACKTITLE" 14 70 fi @@ -246,7 +248,6 @@ _EOF_ } - #///////////////////////////////////////////////////////////////////////////////////// # Main Loop #///////////////////////////////////////////////////////////////////////////////////// diff --git a/dietpi/dietpi-backup b/dietpi/dietpi-backup index 99cf62bf5a..ec251f22af 100644 --- a/dietpi/dietpi-backup +++ b/dietpi/dietpi-backup @@ -22,34 +22,19 @@ # - /DietPi/dietpi/dietpi-backup 1 /mnt/MyDirectoryTarget = Backup #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Exit path for non-root logins. - if (( $UID != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit - - fi - - #RootFS RW check - /DietPi/dietpi/dietpi-drive_manager 3 - if (( $? != 0 )); then - - exit - - fi - - #Grab Input (valid interger) + #Grab Input INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then INPUT=$1 fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Backup' + #Import DietPi-Globals --------------------------------------------------------------- + #///////////////////////////////////////////////////////////////////////////////////// # MENUS #///////////////////////////////////////////////////////////////////////////////////// @@ -65,12 +50,16 @@ local backup_last_completed_system='System backup not found. Create one.' if [ -f "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_SYSTEM" ]; then + backup_last_completed_system=$(grep 'Completed' "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_SYSTEM" | tail -1) + fi local backup_last_completed_userdata='User data backup not found (requires "Full" backup mode)' if [ -f "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_USERDATA" ]; then + backup_last_completed_userdata=$(grep 'Completed' "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_USERDATA" | tail -1) + fi local text_backup_mode='System only' @@ -82,7 +71,7 @@ fi - WHIP_TITLE='- DietPi-Backup -' + WHIP_TITLE='DietPi-Backup' OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Current backup and restore location:\n - $FP_TARGET_BACKUP\n - $backup_last_completed_system\n - $backup_last_completed_userdata" --cancel-button "Exit" --default-item "$MENU_LASTITEM" --backtitle "$WHIP_BACKTITLE" 16 80 5 \ "Help" "What does DietPi-Backup do?" \ "Location" "Change where your backup will be saved and restored from." \ @@ -96,12 +85,16 @@ MENU_LASTITEM="$OPTION" case "$OPTION" in + Location) + TARGETMENUID=1 + ;; + "Backup mode") - OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Please select a backup mode:\n\n - System only\nOnly the system is backed up and restored, this does not include your DietPi user data (/mnt/dietpi_userdata).\n\n - Full:\nSystem and user data (/mnt/dietpi_userdata) is backed up and restored.\n\nMore information on what DietPi user data is:\nhttp://dietpi.com/phpbb/viewtopic.php?f=8&t=478#p2087" --cancel-button "Exit" --default-item "$BACKUP_MODE" --backtitle "$WHIP_BACKTITLE" 20 80 2 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Please select a backup mode:\n\n - System only\nOnly the system is backed up and restored, this does not include your DietPi user data ($G_FP_DIETPI_USERDATA).\n\n - Full:\nSystem and user data ($G_FP_DIETPI_USERDATA) is backed up and restored.\n\nMore information on what DietPi user data is:\nhttp://dietpi.com/phpbb/viewtopic.php?f=8&t=478#p2087" --cancel-button "Exit" --default-item "$BACKUP_MODE" --backtitle "$WHIP_BACKTITLE" 20 80 2 \ "0" "System only" \ "1" "Full (includes user data)" 3>&1 1>&2 2>&3) CHOICE=$? @@ -112,29 +105,45 @@ fi ;; + Help) + whiptail --title "DietPi-Backup Help" --msgbox "DietPi-Backup is a program that allows you to Backup and Restore your DietPi system.\n\nIf you have broken your system, or want to reset your system to an earlier date, this can all be done with DietPi-Backup.\n\nSimply choose a location where you want to save and restore your backups from, then, select Backup or Restore.\n\nMore information:\n - http://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=256#p255" --backtitle "$WHIP_BACKTITLE" 20 75 + ;; + Backup) + WHIP_TITLE=' Start backup? ' whiptail --title "$WHIP_TITLE" --yesno "Your $text_start_mode_desc will be backed up to:\n$FP_TARGET_BACKUP\n\nDo you wish to continue?" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 11 65 CHOICE=$? if (( $CHOICE == 0 )); then + Run_Backup + fi + ;; + Restore) + WHIP_TITLE=' Start restore? ' whiptail --title "$WHIP_TITLE" --yesno "Your $text_start_mode_desc will be restored from:\n$FP_TARGET_BACKUP\n\nDo you wish to continue?" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 11 65 CHOICE=$? if (( $CHOICE == 0 )); then + Run_Restore + fi + ;; + esac else + Menu_Exit + fi } @@ -147,7 +156,9 @@ #Exit if (( $CHOICE == 0 )); then + TARGETMENUID=-1 + fi } @@ -176,28 +187,36 @@ #Do we have any results? if (( $(cat "$fp_search_results" | wc -l) > 0 )); then + readarray search_results_list < "$fp_search_results" #Create List for Whiptail local search_results_whiptail=() for ((i=0; i<${#search_results_list[@]}; i++)) do + local last_backup_date=$( grep 'Completed' ${search_results_list[$i]} | tail -1 | sed 's/.*: //' ) # Date of last backup for this backup local backup_directory=$( echo -e ${search_results_list[$i]} | sed 's/\/'"$BACKUP_STATS_FILENAME_SYSTEM"'//g' ) # Backup directory (minus the backup file), that we can use for target backup directory. search_results_whiptail+=("$backup_directory" ": $last_backup_date") + done OPTION=$(whiptail --title "Backups found." --menu "Please select a previous backup to use:" --cancel-button "Back" --backtitle "$WHIP_BACKTITLE" 12 70 3 "${search_results_whiptail[@]}" 3>&1 1>&2 2>&3) CHOICE=$? if (( $CHOICE == 0 )); then + FP_TARGET_BACKUP="$OPTION" + fi #delete[] array unset search_results_list unset search_results_whiptail rm "$fp_search_results" &> /dev/null + else + whiptail --title "No results" --msgbox "No previous backups were found in /mnt/*" --backtitle "$WHIP_BACKTITLE" 10 60 + fi ;; @@ -225,14 +244,18 @@ esac else + #Return to main menu TARGETMENUID=0 + fi Check_Supported_Directory_Location # - Not supported, reset directory target to previous if (( $TARGET_DIRECTORY_SUPPORTED == 0 )); then + FP_TARGET_BACKUP="$current_directory" + fi } @@ -242,7 +265,9 @@ OPTION=$(whiptail --inputbox "Please enter the filepath to your directory. \neg: /mnt/dietpi-backup\n - Must be located inside /mnt/* \n - Must be symlink compatible filesystem (ext2/3/4)" 10 70 "$FP_TARGET_BACKUP" --title "Manual backup directory" --backtitle "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3) CHOICE=$? if (( $CHOICE == 0 )); then + FP_TARGET_BACKUP="$OPTION" + fi } @@ -252,53 +277,64 @@ #///////////////////////////////////////////////////////////////////////////////////// Error_Filesystem_Not_Supported(){ - /DietPi/dietpi/func/dietpi-notify 1 "Filesystem not supported in $FP_TARGET_BACKUP" + G_DIETPI-NOTIFY 1 "Filesystem not supported in $FP_TARGET_BACKUP" + + if (( $G_USER_INPUTS )); then - if (( $INPUT == 0 )); then whiptail --title "Error" --msgbox "$FP_TARGET_BACKUP Has a filesystem of: $TARGET_FILESYSTEM_TYPE, and is not supported.\n\nThe filesystem must be EXT2/3/4 for symlink compatibility." --backtitle "$WHIP_BACKTITLE" 11 70 + fi } Error_Not_Mnt_Directory(){ - /DietPi/dietpi/func/dietpi-notify 1 "Target directory is not inside /mnt ($FP_TARGET_BACKUP)" + G_DIETPI-NOTIFY 1 "Target directory is not inside /mnt ($FP_TARGET_BACKUP)" + + if (( $G_USER_INPUTS )); then - if (( $INPUT == 0 )); then whiptail --title "Directory not supported" --msgbox "$FP_TARGET_BACKUP\n\nYour current location is not supported.\nThe location must be inside the /mnt/* directory.\n - eg: /mnt/dietpi-backup" --backtitle "$WHIP_BACKTITLE" 11 70 + fi } Error_DietpiUserdata_Directory(){ - /DietPi/dietpi/func/dietpi-notify 1 "Target directory can not be contained within DietPi user data location ($FP_TARGET_BACKUP)" + G_DIETPI-NOTIFY 1 "Target directory can not be contained within DietPi user data location ($FP_TARGET_BACKUP)" + + if (( $G_USER_INPUTS )); then + + whiptail --title "Directory not supported" --msgbox "$FP_TARGET_BACKUP\n\nYour current location is not supported.\nTarget directory can not be contained within DietPi user data location ($G_FP_DIETPI_USERDATA)" --backtitle "$WHIP_BACKTITLE" 13 70 - if (( $INPUT == 0 )); then - whiptail --title "Directory not supported" --msgbox "$FP_TARGET_BACKUP\n\nYour current location is not supported.\nTarget directory can not be contained within DietPi user data location (/mnt/dietpi_userdata)" --backtitle "$WHIP_BACKTITLE" 13 70 fi } Error_Rsync_Already_Running(){ - /DietPi/dietpi/func/dietpi-notify 1 "Another Rsync process is already running." + G_DIETPI-NOTIFY 1 "Another Rsync process is already running." echo -e "$RSYNC_MODE_TEXT failed: $(date +"%d-%m-%Y_%H%M"). Rsync is already running." >> "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_SYSTEM" + #Menu - if (( $INPUT == 0 )); then + if (( $G_USER_INPUTS )); then + whiptail --title "$RSYNC_MODE_TEXT Error" --msgbox "A $RSYNC_MODE_TEXT could not be started as rsync is already running." --backtitle "$WHIP_BACKTITLE" 13 60 + fi } Error_Rsync_Failed(){ - /DietPi/dietpi/func/dietpi-notify 1 "$RSYNC_MODE_TEXT failed." + G_DIETPI-NOTIFY 1 "$RSYNC_MODE_TEXT failed." #Menu - if (( $INPUT == 0 )); then + if (( $G_USER_INPUTS )); then + whiptail --title "$RSYNC_MODE_TEXT failed" --msgbox "Your $RSYNC_MODE_TEXT has failed. Please see the Log file for more information:\n\n$LOGFILE" --backtitle "$WHIP_BACKTITLE" 12 60 + fi } @@ -315,8 +351,7 @@ #Backup Filepaths FP_SOURCE_SYSTEM='/' FP_TARGET_BACKUP='/mnt/dietpi-backup' - FP_SOURCE_USERDATA_GLOBAL='/mnt/dietpi_userdata' - FP_SOURCE_USERDATA_ACTUAL="$(readlink -f /mnt/dietpi_userdata)" + G_FP_DIETPI_USERDATA_ACTUAL="$(readlink -f /mnt/dietpi_userdata)" #file applied to successful backups (stored in "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_SYSTEM" BACKUP_STATS_FILENAME_SYSTEM='.dietpi-backup_system_stats' @@ -441,7 +476,7 @@ _EOF_ RSYNC_MODE_TEXT="Backup" - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Backup "$RSYNC_MODE_TEXT" + G_DIETPI-NOTIFY 3 DietPi-Backup "$RSYNC_MODE_TEXT" #Check valid FS Check_Supported_Directory_Location @@ -455,8 +490,10 @@ _EOF_ #Error: Unable to create target folder. if [ ! -d "$FP_TARGET_BACKUP" ]; then - if (( $INPUT == 0 )); then + if (( $G_USER_INPUTS )); then + whiptail --title "$RSYNC_MODE_TEXT failed." --msgbox "Unable to create $FP_TARGET_BACKUP" --backtitle "$WHIP_BACKTITLE" 10 60 + fi #Error: Rsync is already running @@ -475,7 +512,7 @@ _EOF_ Services_Stop - /DietPi/dietpi/func/dietpi-notify 2 "Backing up to: $FP_TARGET_BACKUP" + G_DIETPI-NOTIFY 2 "Backing up to: $FP_TARGET_BACKUP" BACKUP_RESTORE_FAILED=0 @@ -489,12 +526,12 @@ _EOF_ if (( $? == 0 )); then - /DietPi/dietpi/func/dietpi-notify 0 "$RSYNC_MODE_TEXT Completed.\n" + G_DIETPI-NOTIFY 0 "$RSYNC_MODE_TEXT Completed.\n" echo -e "$RSYNC_MODE_TEXT Completed : $(Print_Date)" >> "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_SYSTEM" else - /DietPi/dietpi/func/dietpi-notify 1 "$RSYNC_MODE_TEXT FAILED.\n" + G_DIETPI-NOTIFY 1 "$RSYNC_MODE_TEXT FAILED.\n" echo -e "$RSYNC_MODE_TEXT FAILED : $(Print_Date)" >> "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_SYSTEM" BACKUP_RESTORE_FAILED=1 break @@ -506,16 +543,16 @@ _EOF_ if (( $BACKUP_MODE == 1 )); then - rsync $RSYNC_RUN_OPTIONS_USERDATA_BACKUP "$FP_SOURCE_USERDATA_ACTUAL"/ "$FP_TARGET_BACKUP"/dietpi-backup_userdata/ + rsync $RSYNC_RUN_OPTIONS_USERDATA_BACKUP "$G_FP_DIETPI_USERDATA_ACTUAL"/ "$FP_TARGET_BACKUP"/dietpi-backup_userdata/ if (( $? == 0 )); then - /DietPi/dietpi/func/dietpi-notify 0 "$RSYNC_MODE_TEXT Completed.\n" + G_DIETPI-NOTIFY 0 "$RSYNC_MODE_TEXT Completed.\n" echo -e "$RSYNC_MODE_TEXT Completed : $(Print_Date)" >> "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_USERDATA" else - /DietPi/dietpi/func/dietpi-notify 1 "$RSYNC_MODE_TEXT FAILED.\n" + G_DIETPI-NOTIFY 1 "$RSYNC_MODE_TEXT FAILED.\n" echo -e "$RSYNC_MODE_TEXT FAILED : $(Print_Date)" >> "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_USERDATA" BACKUP_RESTORE_FAILED=1 break @@ -535,7 +572,7 @@ _EOF_ else - if (( $INPUT == 0 )); then + if (( $G_USER_INPUTS )); then RSYNC_MODE_TEXT='Backup' whiptail --title "$RSYNC_MODE_TEXT completed" --msgbox "Your $RSYNC_MODE_TEXT was saved to:\n$FP_TARGET_BACKUP\n\nLog file: $LOGFILE" --backtitle "$WHIP_BACKTITLE" 11 60 @@ -558,7 +595,7 @@ _EOF_ RSYNC_MODE_TEXT="Restore" - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Backup "$RSYNC_MODE_TEXT" + G_DIETPI-NOTIFY 3 DietPi-Backup "$RSYNC_MODE_TEXT" #Check valid FS Check_Supported_Directory_Location @@ -569,10 +606,12 @@ _EOF_ #Error: Backup not found if [ ! -f "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_SYSTEM" ]; then - /DietPi/dietpi/func/dietpi-notify 2 "No Backup was found in $FP_TARGET_BACKUP" - /DietPi/dietpi/func/dietpi-notify 1 "$RSYNC_MODE_TEXT Failed.\n" - if (( $INPUT == 0 )); then + G_DIETPI-NOTIFY 2 "No Backup was found in $FP_TARGET_BACKUP" + G_DIETPI-NOTIFY 1 "$RSYNC_MODE_TEXT Failed.\n" + if (( $G_USER_INPUTS )); then + whiptail --title "$RSYNC_MODE_TEXT failed" --msgbox "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_SYSTEM does not exist\n\nHave you created a backup?" --backtitle "$WHIP_BACKTITLE" 11 70 + fi #Error: Rsync is already running @@ -588,7 +627,7 @@ _EOF_ Services_Stop - /DietPi/dietpi/func/dietpi-notify 2 "Restoring from: $FP_TARGET_BACKUP" + G_DIETPI-NOTIFY 2 "Restoring from: $FP_TARGET_BACKUP" BACKUP_RESTORE_FAILED=0 @@ -601,12 +640,12 @@ _EOF_ rsync $RSYNC_RUN_OPTIONS_SYSTEM_BACKUP "$FP_TARGET_BACKUP"/dietpi-backup_system/ "$FP_SOURCE_SYSTEM" if (( $? == 0 )); then - /DietPi/dietpi/func/dietpi-notify 0 "$RSYNC_MODE_TEXT Completed.\n" + G_DIETPI-NOTIFY 0 "$RSYNC_MODE_TEXT Completed.\n" echo -e "$RSYNC_MODE_TEXT Completed : $(Print_Date)" >> "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_SYSTEM" else - /DietPi/dietpi/func/dietpi-notify 1 "$RSYNC_MODE_TEXT FAILED.\n" + G_DIETPI-NOTIFY 1 "$RSYNC_MODE_TEXT FAILED.\n" echo -e "$RSYNC_MODE_TEXT FAILED : $(Print_Date)" >> "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_SYSTEM" BACKUP_RESTORE_FAILED=1 break @@ -621,15 +660,15 @@ _EOF_ # - Only restore userdata if a backup exists if [ -f "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_USERDATA" ]; then - rsync $RSYNC_RUN_OPTIONS_USERDATA_BACKUP "$FP_TARGET_BACKUP"/dietpi-backup_userdata/ "$FP_SOURCE_USERDATA_ACTUAL"/ + rsync $RSYNC_RUN_OPTIONS_USERDATA_BACKUP "$FP_TARGET_BACKUP"/dietpi-backup_userdata/ "$G_FP_DIETPI_USERDATA_ACTUAL"/ if (( $? == 0 )); then - /DietPi/dietpi/func/dietpi-notify 0 "$RSYNC_MODE_TEXT Completed.\n" + G_DIETPI-NOTIFY 0 "$RSYNC_MODE_TEXT Completed.\n" echo -e "$RSYNC_MODE_TEXT Completed : $(Print_Date)" >> "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_USERDATA" else - /DietPi/dietpi/func/dietpi-notify 1 "$RSYNC_MODE_TEXT FAILED.\n" + G_DIETPI-NOTIFY 1 "$RSYNC_MODE_TEXT FAILED.\n" echo -e "$RSYNC_MODE_TEXT FAILED : $(Print_Date)" >> "$FP_TARGET_BACKUP/$BACKUP_STATS_FILENAME_USERDATA" BACKUP_RESTORE_FAILED=1 break @@ -638,7 +677,7 @@ _EOF_ else - /DietPi/dietpi/func/dietpi-notify 2 "$RSYNC_MODE_TEXT: No backup exists, skipping...\n" + G_DIETPI-NOTIFY 2 "$RSYNC_MODE_TEXT: No backup exists, skipping...\n" fi @@ -655,7 +694,7 @@ _EOF_ else - if (( $INPUT == 0 )); then + if (( $G_USER_INPUTS )); then RSYNC_MODE_TEXT='Restore' whiptail --title "$RSYNC_MODE_TEXT completed" --msgbox "$RSYNC_MODE_TEXT completed from:\n$FP_TARGET_BACKUP\n\nLog file: $LOGFILE\n\nA Reboot is required." --backtitle "$WHIP_BACKTITLE" 13 60 @@ -677,15 +716,7 @@ _EOF_ Check_Install_PreReqs(){ - #Rsync - if (( ! $(dpkg --get-selections | grep -ci -m1 '^rsync[[[:space:]]') )); then - - /DietPi/dietpi/func/dietpi-notify 2 "Installing Rsync, please wait....\n" - sleep 1 - - apt-get install rsync -y - - fi + G_AG_CHECK_INSTALL_PREREQ rsync } @@ -694,7 +725,7 @@ _EOF_ TARGET_DIRECTORY_SUPPORTED=0 #Disallow dietpi_userdata location, due to includes in that location - if [[ "$FP_TARGET_BACKUP" == "$FP_SOURCE_USERDATA_GLOBAL"* ]] || [[ "$FP_TARGET_BACKUP" == "$FP_SOURCE_USERDATA_ACTUAL"* ]] ; then + if [[ "$FP_TARGET_BACKUP" == "$G_FP_DIETPI_USERDATA"* ]] || [[ "$FP_TARGET_BACKUP" == "$G_FP_DIETPI_USERDATA_ACTUAL"* ]] ; then Error_DietpiUserdata_Directory @@ -704,32 +735,44 @@ _EOF_ #Generate the target directory if it doesnt exist. So we can check what filesystem it will be. local directory_generated=0 if [ ! -d "$FP_TARGET_BACKUP" ]; then + mkdir -p "$FP_TARGET_BACKUP" directory_generated=1 + fi TARGET_FILESYSTEM_TYPE="$( df -T $FP_TARGET_BACKUP | sed -n '2p' | awk '{print $2}')" for ((i=0; i<${#aSUPPORTED_FILESYSTEMS[@]}; i++)) do + if [ "$TARGET_FILESYSTEM_TYPE" = "${aSUPPORTED_FILESYSTEMS[$i]}" ]; then + TARGET_DIRECTORY_SUPPORTED=1 break + fi + done #Delete directory if tested if (( $directory_generated == 1 )); then + rm -R "$FP_TARGET_BACKUP" + fi #Not ext2/3/4 if (( $TARGET_DIRECTORY_SUPPORTED == 0 )); then + Error_Filesystem_Not_Supported + fi #Not inside /mnt else + Error_Not_Mnt_Directory + fi } @@ -770,8 +813,10 @@ _EOF_ Read_Settings_File # $2 Optional directory input. - if [ "$2" != "" ]; then + if [ -n "$2" ]; then + FP_TARGET_BACKUP=$2 + fi #----------------------------------------------------------------------------- @@ -794,9 +839,13 @@ _EOF_ clear if (( $TARGETMENUID == 0 )); then + Menu_Main + elif (( $TARGETMENUID == 1 )); then + Menu_Set_Directory + fi done @@ -812,6 +861,6 @@ _EOF_ #delete[] array unset aSUPPORTED_FILESYSTEMS #----------------------------------------------------------------------------------- - exit + exit 0 #----------------------------------------------------------------------------------- } diff --git a/dietpi/dietpi-banner b/dietpi/dietpi-banner index d92b591bfd..ed1f92162f 100644 --- a/dietpi/dietpi-banner +++ b/dietpi/dietpi-banner @@ -17,71 +17,70 @@ # - dietpi-banner 1 = top section and credits + clear #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then INPUT=$1 fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + export G_PROGRAM_NAME='DietPi-Banner' + #Import DietPi-Globals --------------------------------------------------------------- + #///////////////////////////////////////////////////////////////////////////////////// #Globals #///////////////////////////////////////////////////////////////////////////////////// - DIETPI_VERSION=$(cat /DietPi/dietpi/.version) - HW_MODEL_DESCRIPTION=$(sed -n 2p /DietPi/dietpi/.hw_model) + DIETPI_VERSION="$(sed -n 1p /DietPi/dietpi/.version).$(sed -n 2p /DietPi/dietpi/.version)" IMAGE_ADDITIONAL_CREDITS=$(sed -n 8p /DietPi/dietpi/.hw_model) IP_ADDRESS=$(sed -n 4p /DietPi/dietpi/.network) + IP_ADAPTER=$(sed -n 3p /DietPi/dietpi/.network) Update_Ip_Address(){ /DietPi/dietpi/func/obtain_network_details IP_ADDRESS=$(sed -n 4p /DietPi/dietpi/.network) + IP_ADAPTER=$(sed -n 3p /DietPi/dietpi/.network) + + } + + UPDATE_AVAILABLE=0 + UPDATE_AVAILABLE_VERSION='' #-1 = image required, other value=latest version + + Obtain_Update_Available(){ + + #Update Available + if [ -f /DietPi/dietpi/.update_available ]; then + + UPDATE_AVAILABLE=1 + UPDATE_AVAILABLE_VERSION=$(cat /DietPi/dietpi/.update_available) + + fi } Hardware_Model_Print(){ - echo -e " \e[39;49;1mV$DIETPI_VERSION\e[0m \e[90m| $HW_MODEL_DESCRIPTION\e[0m\n \e[38;5;154m───────────────────────────────────────\e[0m" + echo -e " \e[39;49;1mv$DIETPI_VERSION\e[0m \e[90m| $G_HW_MODEL_DESCRIPTION\e[0m\n \e[38;5;154m───────────────────────────────────────\e[0m" } IPAddress_Print(){ - #Try to obtain IP if missing + #Try to re-obtain IP if missing if [ ! -n "$IP_ADDRESS" ]; then Update_Ip_Address fi - echo -e " \e[39;49;1mIP Address\e[0m \e[90m| $IP_ADDRESS\e[0m\n \e[38;5;154m───────────────────────────────────────\e[0m" - - } - - Xmas_Print(){ - - echo -e " \e[31m^\e[0m - \e[31m*\e[0m\e[38;5;154m#\e[31m*\e[0m - \e[31m*\e[0m\e[38;5;154m###\e[31m*\e[0m \e[90m Lightweight Xmas Justice Tips:\e[0m - \e[31m*\e[0m\e[38;5;154m#####\e[31m*\e[0m \e[90m - Be good, Amazon do sell coal.\e[0m - \e[31m*\e[0m\e[38;5;154m#######\e[31m*\e[0m \e[90m - Cherish every moment, even the awkward family gatherings ;)\e[0m - \e[31m*\e[0m\e[38;5;154m#########\e[31m*\e[0m \e[90m - 'Ho Ho Ho, Green Giant' swaps his job! \e[0m - \e[31m*\e[0m\e[38;5;154mMerry Xmas\e[31m*\e[0m - \e[31m*\e[0m\e[38;5;154m#############\e[31m*\e[0m \e[90m All the best from everyone at DietPi =)) \e[0m - \e[100m \e[0m -" + echo -e " \e[39;49;1mIP $IP_ADAPTER\e[0m \e[90m| $IP_ADDRESS\e[0m\n \e[38;5;154m───────────────────────────────────────\e[0m" } #///////////////////////////////////////////////////////////////////////////////////// #Top section additional Text. Update available / MOTD etc #///////////////////////////////////////////////////////////////////////////////////// - TEXT_TOP="" - UPDATE_AVAILABLE=0 + TEXT_TOP='' #///////////////////////////////////////////////////////////////////////////////////// # Banner Print @@ -89,14 +88,16 @@ Banner_TopText_Extras(){ #Update Available - if [ -f /DietPi/dietpi/.update_available ]; then + if (( $UPDATE_AVAILABLE )); then - UPDATE_AVAILABLE=$(cat /DietPi/dietpi/.update_available) + if [ "$UPDATE_AVAILABLE_VERSION" = '-1' ]; then - if (( $UPDATE_AVAILABLE > 0 )); then - TEXT_TOP="\e[90m|\e[0m \e[91m\e[33;49;1mUpdate available\e[0m" - elif (( $UPDATE_AVAILABLE == -1 )); then TEXT_TOP="\e[90m|\e[0m \e[91m\e[33;49;1mImage available\e[0m" + + else + + TEXT_TOP="\e[90m|\e[0m \e[91m\e[33;49;1mUpdate available\e[0m" + fi #Use TEXT_TOP for storing helpful info @@ -122,7 +123,8 @@ } Credits_Print(){ - echo -e "" + + echo -e '' echo -e "\e[90m Created by : Daniel Knight\e[0m" echo -e "\e[90m Web : http://DietPi.com\e[0m" echo -e "\e[90m Twitter : http://twitter.com/dietpi_\e[0m" @@ -130,39 +132,56 @@ if [ -n "$IMAGE_ADDITIONAL_CREDITS" ]; then - echo -e "" + echo -e '' echo -e "\e[90m Device image possible thanks to: $IMAGE_ADDITIONAL_CREDITS\e[0m" fi echo -e "\e[90m DietPi's web hosting is powered by: MyVirtualServer.com\e[0m" - echo -e "" + echo -e '' echo -e "\e[1m dietpi-launcher\e[0m = All the DietPi programs in one place." echo -e "\e[1m dietpi-config\e[0m = Feature rich configuration tool for your device." echo -e "\e[1m dietpi-software\e[0m = Select optimized software for installation." - #Update available - if (( $UPDATE_AVAILABLE > 0 )); then - echo -e "\e[1m dietpi-update\e[0m = \e[91mRun now to update DietPi (from V$DIETPI_VERSION to V$UPDATE_AVAILABLE).\e[0m" - elif (( $UPDATE_AVAILABLE == -1 )); then - echo -e "\n\e[91m An updated DietPi image is available, please goto:\e[0m\n http://dietpi.com/phpbb/viewtopic.php?f=8&t=9#p9\n" + + #Update available? + if (( $UPDATE_AVAILABLE )); then + + if [ "$UPDATE_AVAILABLE_VERSION" = '-1' ]; then + + echo -e "\n\e[91m An updated DietPi image is available, please goto:\e[0m\n http://dietpi.com/download\n" + + else + + echo -e "\e[1m dietpi-update\e[0m = \e[91mRun now to update DietPi (from v$DIETPI_VERSION to v$UPDATE_AVAILABLE_VERSION).\e[0m" + + fi + fi + echo -e "\e[1m htop\e[0m = Resource monitor." echo -e "\e[1m cpu\e[0m = Shows CPU information and stats." - echo -e "" + echo -e '' + } #///////////////////////////////////////////////////////////////////////////////////// # Main Loop #///////////////////////////////////////////////////////////////////////////////////// if (( $INPUT == 0 )); then + + Obtain_Update_Available Banner_TopText_Extras Banner_Dietpi elif (( $INPUT == 1 )); then + + Obtain_Update_Available Banner_TopText_Extras Banner_Dietpi Credits_Print - Xmas_Print + fi #----------------------------------------------------------------------------------- + exit 0 + #----------------------------------------------------------------------------------- diff --git a/dietpi/dietpi-bugreport b/dietpi/dietpi-bugreport index 1d4af6fc6d..e63b59f00f 100644 --- a/dietpi/dietpi-bugreport +++ b/dietpi/dietpi-bugreport @@ -13,11 +13,12 @@ # - Generates MACADDRESS_BUGNUMBER.zip and uploads to dietpi.com #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Bugreport' + #Import DietPi-Globals --------------------------------------------------------------- # - byte UPLOAD_FILESIZE_LIMIT=83886080 @@ -45,7 +46,7 @@ Generate_Template_Doc(){ -cat << _EOF_ > "$FILE_BUGREPORT_TEXT" + cat << _EOF_ > "$FILE_BUGREPORT_TEXT" ---------------------------------------------------------------- DietPi : Bug Report #Date @@ -122,8 +123,13 @@ _EOF_ # - DietPi scripts / logs "/DietPi/*" - "/boot/*" - "/etc/dietpi/logs/*" + "/boot/dietpi.txt" + "/boot/config.txt" + "/boot/dietpi/*" + "/var/tmp/dietpi/logs/*" + + # - /var/lib/dietpi + "/var/lib/dietpi/*" # - confs "/etc/X11/xorg.conf" @@ -136,6 +142,8 @@ _EOF_ "/etc/sysctl.conf" "/etc/sysctl.d/*" + "/root/.bashrc" + # - Services "/etc/init.d/*" "/etc/systemd/*" @@ -206,28 +214,39 @@ _EOF_ cd "$FILEPATH_TEMP" #---------------------------------------------------------------- #Check if we have a working internet connection beforehand - /DietPi/dietpi/func/check_connection "$FTP_ADDR" + G_CHECK_URL "$FTP_ADDR" if (( $? == 0 )); then + INTERNET_AVAILABLE=1 + fi # - Prompt user if they wish to continue. Offline mode. No Network. if (( $INTERNET_AVAILABLE == 0 )); then + clear + whiptail --title "Offline" --yesno "Error: Unable to connect to $FTP_ADDR\n- Make sure a network device is installed.\n- Check your network connection is functional.\n- $FTP_ADDR may be offline.\n\n Would you like to generate an offline bug report?\n - /DietPi/bugreport.zip" --yes-button "Ok" --no-button "Exit" --defaultno --backtitle "DietPi Bug Report" 14 70 CHOICE=$? if (( $CHOICE == 0 )); then + ONLINE_BUG_REPORT=0 CREATE_BUG_REPORT=1 + fi + # - Prompt user if they wish to continue. Online Upload. else + whiptail --title "Send DietPi Bug Report?" --yesno "DietPi will generate and upload a bug report for your system.\n\nThis file will contain:\n- Your description of the bug/issue.\n- DietPi settings.\n- Log files.\n- Config files specific to DietPi.\n\nDo you wish to continue?" --yes-button "Ok" --no-button "Exit" --defaultno --backtitle "DietPi Bug Report" 15 70 CHOICE=$? if (( $CHOICE == 0 )); then + ONLINE_BUG_REPORT=1 CREATE_BUG_REPORT=1 + fi + fi #---------------------------------------------------------------- @@ -248,7 +267,9 @@ _EOF_ #---------------------------------------------------------------- #Load .bug_id if [ -f "$FILE_BUG_NUMBER" ]; then + UNIQUE_ID_BUGNUMBER=$(cat "$FILE_BUG_NUMBER") + fi #---------------------------------------------------------------- @@ -269,7 +290,7 @@ _EOF_ else #Check upload location is online - /DietPi/dietpi/func/check_connection "$FTP_ADDR" + G_CHECK_URL "$FTP_ADDR" if (( $? == 0 )); then #Limit filesize to 10MB @@ -283,14 +304,16 @@ _EOF_ # - upload to server else - /DietPi/dietpi/func/dietpi-notify 2 "Uploading bug report, please wait..." + G_DIETPI-NOTIFY 2 "Uploading bug report, please wait..." wput --timeout=10th-4 --tries=1 --waitretry=2 -B -u "$FILE_GENERATED_ZIP" ftp://"$FTP_USER":"$FTP_PASS"@"$FTP_ADDR" BUG_REPORT_COMPLETED=1 fi else + BUG_REPORT_COMPLETED=-1 + fi fi @@ -302,10 +325,13 @@ _EOF_ #Inform user if (( $ONLINE_BUG_REPORT == 0 )); then + whiptail --title "Bug Report Created" --msgbox "Your offline bug report has been generated:\n - /DietPi/bugreport.zip\n\nContact DietPi for support using one of the below:\n- Github Issue : https://github.com/Fourdee/DietPi/issues\n- RPi Forum : https://goo.gl/QzyTVm\n- Odroid Forum : http://goo.gl/26owYc\n- DietPi Forum : http://dietpi.com/phpbb/viewforum.php?f=9" --backtitle "DietPi Bug Report" 16 70 /DietPi/dietpi/dietpi-banner 1 echo -e "\n Bug report generated. /DietPi/bugreport.zip \n " + else + #inform user of their unique ID that can be used to track issue whiptail --title "Bug Report Sent" --msgbox "Your bug report has been sent.\nPlease make note of your reference code below. This will need to be used when contacting DietPi for support.\n\n Reference CODE: $UNIQUE_ID_HW-$UNIQUE_ID_BUGNUMBER \n\nContact DietPi for support using one of the below:\n- Github Issue : https://github.com/Fourdee/DietPi/issues\n- RPi Forum : https://goo.gl/QzyTVm\n- Odroid Forum : http://goo.gl/26owYc\n- DietPi Forum : http://dietpi.com/phpbb/viewforum.php?f=9" --backtitle "DietPi Bug Report" 18 70 @@ -321,16 +347,22 @@ _EOF_ #Failed to upload - Connection error elif (( $BUG_REPORT_COMPLETED == -1 )); then + whiptail --title "Upload failed" --msgbox "Error: Unable to upload Bug report.\n\nConnection to $FTP_ADDR has failed:\n- Check your network connection is functional.\n- Please try again later." --backtitle "DietPi Bug Report" 12 70 /DietPi/dietpi/dietpi-banner 1 + #Failed to upload - Filesize too big elif (( $BUG_REPORT_COMPLETED == -2 )); then + whiptail --title "Bug report upload failed" --msgbox "Error: Bug report file exceeds size limit\n - Max size = $(( $UPLOAD_FILESIZE_LIMIT / 1024 / 1024 ))MB\n - Bug report size = $(( $UPLOAD_FILESIZE / 1024 / 1024 ))MB\n\nThis bug report has NOT been sent." --backtitle "DietPi Bug Report" 12 60 /DietPi/dietpi/dietpi-banner 1 + #Aborted elif (( $CREATE_BUG_REPORT == 0 )); then + /DietPi/dietpi/dietpi-banner 1 echo -e "\nBug report aborted by user.\n" + fi #---------------------------------------------------------------- @@ -339,6 +371,7 @@ _EOF_ rm -R "$FILEPATH_TEMP" &> /dev/null #----------------------------------------------------------------------------------- - exit + exit 0 #----------------------------------------------------------------------------------- + } diff --git a/dietpi/dietpi-cleaner b/dietpi/dietpi-cleaner index cc4808ee8a..a7e721170b 100644 --- a/dietpi/dietpi-cleaner +++ b/dietpi/dietpi-cleaner @@ -16,26 +16,19 @@ # /DietPi/dietpi/dietpi-cleaner 2 = Run All cleaners (no menu). #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Exit path for non-root logins. - if (( $UID != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit - - fi - #Grab Input (valid interger) INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then INPUT=$1 fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Cleaner' + #Import DietPi-Globals --------------------------------------------------------------- + #///////////////////////////////////////////////////////////////////////////////////// # Globals #///////////////////////////////////////////////////////////////////////////////////// @@ -477,7 +470,7 @@ apt-get clean rm /var/lib/apt/lists/* -vf - apt-get update + G_AGUP fi diff --git a/dietpi/dietpi-cloudshell b/dietpi/dietpi-cloudshell index ec7dc5e4ad..dea9273398 100644 --- a/dietpi/dietpi-cloudshell +++ b/dietpi/dietpi-cloudshell @@ -17,28 +17,17 @@ # dietpi-cloudshell 2 = Run + Skip intro #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Exit path for non-root logins. - if (( $UID != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit - - fi - #Grab Input (valid interger) INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then INPUT=$1 fi - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) - CPU_CORES=$(nproc --all) + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Cloudshell' + #Import DietPi-Globals --------------------------------------------------------------- #Version DIETPI_CLOUDSHELL_VERSION=9 @@ -333,7 +322,7 @@ CPU_TOTALPROCESSES=$(( $(ps --ppid 2 -p 2 --deselect | wc -l) - 2 )) # - ps process and descriptions. CPU_GOV=$(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor) - CPU_TEMP=$(/DietPi/dietpi/dietpi-cpuinfo 1) + CPU_TEMP=$(G_OBTAIN_CPU_TEMP) if [[ $CPU_TEMP =~ ^-?[0-9]+$ ]]; then @@ -367,7 +356,7 @@ CPU_FREQ_2="N/A" #Unique additional freq readout for Odroid XU4 (octo, 2nd quad set) - if (( $HW_MODEL == 11 )); then + if (( $G_HW_MODEL == 11 )); then CPU_FREQ_2=$(( $(cat /sys/devices/system/cpu/cpu4/cpufreq/scaling_cur_freq) / 1000 )) @@ -386,7 +375,7 @@ done < $FP_TEMP #ps returns usage of each core, so we devide the total by #n cores - CPU_USAGE=$(echo "scale=0;$CPU_USAGE / $CPU_CORES" | bc -l ) + CPU_USAGE=$(echo "scale=0;$CPU_USAGE / $G_HW_CPU_CORES" | bc -l ) # TOP (accurate) # Fails to output in low screen res (https://github.com/Fourdee/DietPi/issues/203#issuecomment-189711968) @@ -471,7 +460,7 @@ #kill - /DietPi/dietpi/func/dietpi-notify 1 "DF failed, unable to obtain drive data" + G_DIETPI-NOTIFY 1 "DF failed, unable to obtain drive data" sleep 2 kill $pid @@ -545,13 +534,13 @@ #DietPi DIETPI_VERSION_CURRENT=0 DIETPI_UPDATE_AVAILABLE=0 - DIETPI_WEBSITE="dietpi.com" + DIETPI_WEBSITE='dietpi.com' DIETPI_TWITTER="@dietpi_" DIETPI_HW_DESCRIPTION="N/A" Obtain_DIETPIINFO(){ #DietPi version - DIETPI_VERSION_CURRENT="${aCOLOUR[2]}$(cat /DietPi/dietpi/.version)$C_RESET" + DIETPI_VERSION_CURRENT="${aCOLOUR[2]}$(sed -n 1p /DietPi/dietpi/.version).$(sed -n 2p /DietPi/dietpi/.version)$C_RESET" #Current HW DIETPI_HW_DESCRIPTION=$(sed -n 2p /DietPi/dietpi/.hw_model) @@ -561,22 +550,25 @@ if [ -f /DietPi/dietpi/.update_available ]; then #Set current version to red - DIETPI_VERSION_CURRENT="${aCOLOUR[1]}$(cat /DietPi/dietpi/.version)$C_RESET" + DIETPI_VERSION_CURRENT="${aCOLOUR[1]}$(sed -n 1p /DietPi/dietpi/.version).$(sed -n 2p /DietPi/dietpi/.version)$C_RESET" local update_version=$(cat /DietPi/dietpi/.update_available) - if (( $update_version > 0 )); then - DIETPI_UPDATE_AVAILABLE="${aCOLOUR[2]}$update_version$C_RESET" + if [ "$update_version" = '-1' ]; then - elif (( $update_version == -1 )); then DIETPI_UPDATE_AVAILABLE="${aCOLOUR[2]}New Image$C_RESET" + + else + + DIETPI_UPDATE_AVAILABLE="${aCOLOUR[2]}$update_version$C_RESET" + fi - fi + fi } #Network Details - NETWORK_DETAILS_ADAPTER="eth0" + NETWORK_DETAILS_ADAPTER='eth0' NETWORK_DETAILS_IP_INT=0 NETWORK_DETAILS_MAC_ADDRESS=0 NETWORK_DETAILS_SIGNAL_STRENGTH=0 @@ -945,7 +937,7 @@ echo -e "$C_RESET${aCOLOUR[$USER_COLOUR_INDEX]} Governor ${aCOLOUR[$USER_COLOUR_INDEX]}:$C_RESET $CPU_GOV" #XU3/4 unique octo quad sets - if (( $HW_MODEL == 11 )); then + if (( $G_HW_MODEL == 11 )); then echo -e "$C_RESET${aCOLOUR[$USER_COLOUR_INDEX]} Freq 0-3 ${aCOLOUR[$USER_COLOUR_INDEX]}:$C_RESET $CPU_FREQ_1 mhz" echo -e "$C_RESET${aCOLOUR[$USER_COLOUR_INDEX]} Freq 4-7 ${aCOLOUR[$USER_COLOUR_INDEX]}:$C_RESET $CPU_FREQ_2 mhz" @@ -1186,7 +1178,7 @@ _EOF_ #-------------------------------------------------------------------------------- #VM disable CPU scene - if (( $HW_MODEL == 20 )); then + if (( $G_HW_MODEL == 20 )); then aEnabledScenes[0]=0 fi diff --git a/dietpi/dietpi-config b/dietpi/dietpi-config index fc331b03de..5e54bdc7e8 100644 --- a/dietpi/dietpi-config +++ b/dietpi/dietpi-config @@ -17,57 +17,36 @@ # - iEXITONBACK - 1=Exit DietPi-Config when going back to previous menu (applied to TARGETMENUINDEX 8 only!!) #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Exit path for non-root logins. - if (( $UID != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit - + #Grab Inputs + # - target MENU INDEX (valid interger) + if [[ $1 =~ ^-?[0-9]+$ ]]; then + TARGETMENUID=$1 fi - - #RootFS RW check - /DietPi/dietpi/dietpi-drive_manager 3 - if (( $? != 0 )); then - - exit - + # - Exit DietPi-Config when going back to previous menu? + if [[ $2 =~ ^-?[0-9]+$ ]]; then + EXITONBACK=$2 + TEXT_MENU_BACK="Exit" fi - #///////////////////////////////////////////////////////////////////////////////////// - #Obtain Install Stage Index (File always exists - is set with finalized) - #///////////////////////////////////////////////////////////////////////////////////// - # -3 = first boot / -2 = partition / -1 = filesystem / 0 = run dietpi-software at login / 1 = completed - DIETPI_INSTALL_STAGE=$(cat /DietPi/dietpi/.install_stage) + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Config' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// #Obtain Hardware Details #///////////////////////////////////////////////////////////////////////////////////// - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) - HW_MODEL_DESCRIPTION=$(sed -n 2p /DietPi/dietpi/.hw_model) - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) - HW_CPUID=$(sed -n 9p /DietPi/dietpi/.hw_model) HW_ONBOARD_WIFI=$(sed -n 10p /DietPi/dietpi/.hw_model) - FP_CPU_SCALING_GOV='/sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors' - #///////////////////////////////////////////////////////////////////////////////////// - #Obtain Install Stage Index - #///////////////////////////////////////////////////////////////////////////////////// - # see /DietPi/dietpi/boot for info - DIETPI_INSTALL_STAGE=$(cat /DietPi/dietpi/.install_stage) - #///////////////////////////////////////////////////////////////////////////////////// #Obtain Installed software #///////////////////////////////////////////////////////////////////////////////////// Load_Installed_Software(){ - if [[ -f /DietPi/dietpi/.installed ]]; then + if [ -f /DietPi/dietpi/.installed ]; then . /DietPi/dietpi/.installed fi @@ -79,7 +58,7 @@ HW_MSG_NOTSUPPORTED="Not Supported" Info_HW_OptionNotSupported(){ - WHIP_QUESTION="This option is not available for $HW_MODEL_DESCRIPTION" + WHIP_QUESTION="This option is not available for $G_HW_MODEL_DESCRIPTION" whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 8 65 } @@ -96,17 +75,6 @@ TEXT_MENU_BACK="Back" - #Grab target MENU INDEX (valid interger) - if [[ $1 =~ ^-?[0-9]+$ ]]; then - TARGETMENUID=$1 - fi - - #Exit DietPi-Config when going back to previous menu? - if [[ $2 =~ ^-?[0-9]+$ ]]; then - EXITONBACK=$2 - TEXT_MENU_BACK="Exit" - fi - WHIP_BACKTITLE='DietPi-Config' WHIP_TITLE='DietPi-Config' WHIP_QUESTION='DietPi-Config' @@ -128,7 +96,7 @@ Menu_Main(){ WHIP_TITLE='DietPi-Config' - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION" --cancel-button "Exit" --backtitle "$WHIP_BACKTITLE" 18 50 10 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION" --cancel-button "Exit" --backtitle "$WHIP_BACKTITLE" 18 50 10 \ "1" "Display Options" \ "2" "Audio Options" \ "3" "Performance Options" \ @@ -147,7 +115,7 @@ TARGETMENUID=1 - if (( $HW_MODEL == 20 )); then + if (( $G_HW_MODEL == 20 )); then TARGETMENUID=0 Info_HW_OptionNotSupported @@ -158,7 +126,7 @@ TARGETMENUID=14 - if (( $HW_MODEL == 20 )); then + if (( $G_HW_MODEL == 20 )); then TARGETMENUID=0 Info_HW_OptionNotSupported @@ -169,7 +137,7 @@ TARGETMENUID=4 - if (( $HW_MODEL == 20 )); then + if (( $G_HW_MODEL == 20 )); then TARGETMENUID=0 Info_HW_OptionNotSupported @@ -259,7 +227,7 @@ local input=$1 - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then local framebuffer_x=$(cat /DietPi/config.txt | grep -m1 'framebuffer'_width= | sed 's/.*=//') local framebuffer_y=$(cat /DietPi/config.txt | grep -m1 'framebuffer'_height= | sed 's/.*=//') @@ -305,7 +273,7 @@ local whiptail_menu_array=() - if (( $HW_MODEL == 21 )); then + if (( $G_HW_MODEL == 21 )); then whiptail_menu_array+=("1" "Display Driver") @@ -314,7 +282,7 @@ whiptail_menu_array+=("1" "Change Resolution") whiptail_menu_array+=("2" "GPU/RAM Memory Split") - local lcdpanel_text=$(cat /DietPi/dietpi.txt | grep -m1 '^lcdpanel=' | sed 's/.*=//') + local lcdpanel_text=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_LCDPANEL=' | sed 's/.*=//') whiptail_menu_array+=("3" "LCD Panel addon: $lcdpanel_text") fi @@ -322,7 +290,7 @@ whiptail_menu_array+=("14" "LED Control") #RPi only - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then # - Get Current Settings local overscan_enabled=$(cat /DietPi/config.txt | grep -ci -m1 'disable_overscan=0') @@ -395,7 +363,7 @@ fi #Odroid Remote - if (( $HW_MODEL >= 10 && $HW_MODEL <= 12 )); then + if (( $G_HW_MODEL >= 10 && $G_HW_MODEL <= 12 )); then local odroid_remote_text='Disabled' local odroid_remote_enabled=0 @@ -447,23 +415,23 @@ elif (( $OPTION == 3 )); then - if (( $HW_MODEL < 10 || - $HW_MODEL == 10 || - $HW_MODEL == 11 || - $HW_MODEL == 12 )); then + if (( $G_HW_MODEL < 10 || + $G_HW_MODEL == 10 || + $G_HW_MODEL == 11 || + $G_HW_MODEL == 12 )); then local whiptail_menu_array=() whiptail_menu_array+=("none" "Uninstall all panels") whiptail_menu_array+=("waveshare32" "320x240 panel with touch input") - if (( $HW_MODEL == 11 )); then + if (( $G_HW_MODEL == 11 )); then whiptail_menu_array+=("odroid-cloudshell" "320x240 panel") fi - if (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then + if (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )); then whiptail_menu_array+=("odroid-lcd35" "480x320 panel with touch input") @@ -493,7 +461,7 @@ elif (( $OPTION == 2 )); then - if (( $HW_MODEL < 10 || $HW_MODEL == 10 || $HW_MODEL == 12 )); then + if (( $G_HW_MODEL < 10 || $G_HW_MODEL == 10 || $G_HW_MODEL == 12 )); then WHIP_QUESTION='GPU/RAM Memory splits are pre-configured and applied during DietPi-Software setup. \n \nThe split value is optimized based on your software installs, however, feel free to tweak them.' whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 12 60 @@ -511,7 +479,7 @@ elif (( $OPTION == 6 )); then #RPI only - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then if (( $overscan_enabled )); then @@ -544,7 +512,7 @@ elif (( $OPTION == 7 )); then #RPI only - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then #Enabled if [ "$hdmi_boost_disabled" = 0 ]; then @@ -586,7 +554,7 @@ elif (( $OPTION == 8 )); then #RPI only - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then if (( ! $rpi_camera_module_enabled )); then @@ -612,7 +580,7 @@ elif (( $OPTION == 9 )); then #RPI only - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then if (( ! $rpi_camera_led_enabled )); then @@ -818,7 +786,7 @@ TARGETMENUID=1 #Native PC - if (( $HW_MODEL == 21 )); then + if (( $G_HW_MODEL == 21 )); then local whiptail_menu_array=() @@ -875,7 +843,7 @@ fi #RPI - elif (( $HW_MODEL < 10 )); then + elif (( $G_HW_MODEL < 10 )); then #Get Current Values local framebuffer_x=$(cat /DietPi/config.txt | grep -m1 'framebuffer'_width= | sed 's/.*=//') @@ -890,14 +858,14 @@ fi #check for headless - if (($(cat /DietPi/dietpi.txt | grep -ci -m1 'rpi_hdmi_output=0') == 1)); then + if (($(cat /DietPi/dietpi.txt | grep -ci -m1 'CONFIG_HDMI_OUTPUT=0') == 1)); then display_output_text="Headless" fi WHIP_TITLE='DietPi - Resolution' - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n Current: $display_output_text" --cancel-button "$TEXT_MENU_BACK" 19 60 9 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n Current: $display_output_text" --cancel-button "$TEXT_MENU_BACK" 19 60 9 \ 'OpenGL' '1920 x 1080' \ '1080p' '1920 x 1080' \ '720p' '1280 x 720' \ @@ -922,7 +890,7 @@ TARGETMENUID=2 # - Always enable HDMI output by default - sed -i "/rpi_hdmi_output=/c\rpi_hdmi_output=1" /DietPi/dietpi.txt + sed -i "/CONFIG_HDMI_OUTPUT=/c\CONFIG_HDMI_OUTPUT=1" /DietPi/dietpi.txt # - Always disable composite by default sed -i '/sdtv_mode=/c\#sdtv_mode=0' /DietPi/config.txt @@ -983,7 +951,7 @@ ;; Headless) whiptail --title "$WHIP_TITLE" --msgbox " 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" --backtitle "$WHIP_BACKTITLE" 14 75 - sed -i "/rpi_hdmi_output=/c\rpi_hdmi_output=0" /DietPi/dietpi.txt + sed -i "/CONFIG_HDMI_OUTPUT=/c\CONFIG_HDMI_OUTPUT=0" /DietPi/dietpi.txt ;; esac @@ -993,13 +961,13 @@ fi #Odroid C1 - elif (( $HW_MODEL == 10 )); then + elif (( $G_HW_MODEL == 10 )); then #Get Current Values local current_resolution=$(cat /DietPi/boot.ini | grep -m1 'setenv m "' | awk -F '"' '{print $2}') WHIP_TITLE='DietPi - Resolution' - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n Current: $current_resolution" --cancel-button "$TEXT_MENU_BACK" 16 60 6 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n Current: $current_resolution" --cancel-button "$TEXT_MENU_BACK" 16 60 6 \ "1080p" "1920 x 1080" \ "720p" "1280 x 720" \ "480p" "720 x 480" \ @@ -1041,7 +1009,7 @@ fi #Odroid xu3/4 - elif (( $HW_MODEL == 11 )); then + elif (( $G_HW_MODEL == 11 )); then #Get Current Values local current_resolution="" @@ -1054,7 +1022,7 @@ fi WHIP_TITLE='DietPi - Resolution' - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n Current: $current_resolution" --cancel-button "$TEXT_MENU_BACK" 14 60 4 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n Current: $current_resolution" --cancel-button "$TEXT_MENU_BACK" 14 60 4 \ "1080p" "1920 x 1080" \ "720p" "1280 x 720" \ "480p" "720 x 480" \ @@ -1092,7 +1060,7 @@ fi #Odroid C2 - elif (( $HW_MODEL == 12 )); then + 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 /') @@ -1100,7 +1068,7 @@ WHIP_TITLE='DietPi - Resolution' - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n Current: $current_resolution" --default-item "$current_resolution" --cancel-button "$TEXT_MENU_BACK" 18 60 9 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n Current: $current_resolution" --default-item "$current_resolution" --cancel-button "$TEXT_MENU_BACK" 18 60 9 \ "2160p 60hz" "4K (Recommended)" \ "2160p 50hz" "4K" \ "2160p 30hz" "4K" \ @@ -1148,13 +1116,13 @@ fi #Pine a64 - elif (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then + elif (( $G_HW_MODEL == 40 )); then #Get Current Values local current_resolution=$(cat /DietPi/uEnv.txt | grep -m1 'optargs=disp.screen0_output_mode=' | sed 's/.*=//') WHIP_TITLE='DietPi - Resolution' - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n Current: $current_resolution" --default-item "$current_resolution" --cancel-button "$TEXT_MENU_BACK" 18 55 9 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n Current: $current_resolution" --default-item "$current_resolution" --cancel-button "$TEXT_MENU_BACK" 18 55 9 \ "720p50" "" \ "720p60" "720p" \ "1080i50" "" \ @@ -1203,7 +1171,7 @@ whiptail_menu_array+=("Swapfile size" ": $swap_text") #NTPD - local ntpd_mode_current=$(cat /DietPi/dietpi.txt | grep -m1 '^ntpd_update_mode=' | sed 's/.*=//') + local ntpd_mode_current=$(grep -m1 '^CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/.*=//') local ntpd_mode_text="" if (( $ntpd_mode_current == 0 )); then ntpd_mode_text="Disabled" @@ -1218,7 +1186,7 @@ fi whiptail_menu_array+=("Time sync mode" ": $ntpd_mode_text") - serialconsole_state=$(cat /DietPi/dietpi.txt | grep -m1 '^serial_console_enabled=' | sed 's/.*=//') + serialconsole_state=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_SERIAL_CONSOLE_ENABLE=' | sed 's/.*=//') serialconsole_text='Disabled' if (( $serialconsole_state == 1 )); then serialconsole_text='Enabled' @@ -1233,17 +1201,17 @@ bluetooth_state_text='Disabled' fi # - No bluetooth for VM - if (( $HW_MODEL != 20 )); then + if (( $G_HW_MODEL != 20 )); then whiptail_menu_array+=("Bluetooth" ": $bluetooth_state_text") fi # - No serial console for VM - if (( $HW_MODEL != 20 )); then + if (( $G_HW_MODEL != 20 )); then whiptail_menu_array+=("Serial console" ": $serialconsole_text") fi #RPi Specific - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then local rpi_i2c_enabled=$(cat /DietPi/config.txt | grep -ci -m1 'dtparam=i2c_arm=on') local rpi_i2c_text='Disabled' @@ -1258,7 +1226,7 @@ rpi_usbmaxcurrent_text='Enabled' fi - if (( $HW_MODEL == 3 )); then + 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='Disabled' @@ -1339,64 +1307,44 @@ elif [ "$OPTION" = "Update firmware" ]; then #RPI - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then - WHIP_QUESTION=" Would you like to update the firmware on your Pi? \n - This will run rpi-update" - whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 12 60 + WHIP_QUESTION="Would you like to update the firmware/kernel for $G_HW_MODEL_DESCRIPTION?\n - This will run G_RPI_UPDATE" + whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 14 70 CHOICE=$? if (( $CHOICE == 0 )); then - #Check its installed. Install if not. - if (( $(dpkg -l | grep -ci -m1 'rpi-update') == 0 )); then - - echo -e "\n DietPi: Installing rpi-update, please wait...\n" - apt-get install -y rpi-update - - fi - - rpi-update + G_RPI_UPDATE REBOOT_REQUIRED=1 fi - #Odroid - elif (( $HW_MODEL >= 10 )) && (( $HW_MODEL < 20 )); then + #PineA64 + elif (( $G_HW_MODEL == 40 )); then - WHIP_QUESTION=" Would you like to update the firmware on your $HW_MODEL_DESCRIPTION? \n - This will run apt-get dist-upgrade\n\nNB: When asked if you wish to overwrite the current kernel, press Tab and then enter (to confirm)." - whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 14 60 + WHIP_QUESTION="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." + whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 14 70 CHOICE=$? if (( $CHOICE == 0 )); then - apt-get dist-upgrade -y + /usr/local/sbin/pine64_update_uboot.sh + /usr/local/sbin/pine64_update_kernel.sh fi - #OrangePi - elif (( $HW_MODEL >= 30 )) && (( $HW_MODEL < 40 )); then + #G_AGDUG based (not all devices support this) + else - WHIP_QUESTION=" Would you like to update the firmware on your $HW_MODEL_DESCRIPTION? \n - This will run apt-get dist-upgrade\n\nNB: When asked if you wish to overwrite the current kernel, press Tab and then enter (to confirm)." - whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 14 60 + WHIP_QUESTION="Would you like to update the firmware/kernel for $G_HW_MODEL_DESCRIPTION?\n - This will run G_AGDUG\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)." + whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 16 70 CHOICE=$? if (( $CHOICE == 0 )); then - apt-get dist-upgrade -y - - fi + G_AGUP + G_AGDUG - #PineA64 - elif (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then - WHIP_QUESTION=" Would you like to update the firmware on your $HW_MODEL_DESCRIPTION? \n - This will run longsleep's update scripts to update the U-Boot and kernel." - whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 12 60 - CHOICE=$? - if (( $CHOICE == 0 )); then - /usr/local/sbin/pine64_update_uboot.sh - /usr/local/sbin/pine64_update_kernel.sh fi - else - - Info_HW_OptionNotSupported - fi #Return to This Menu @@ -1529,7 +1477,7 @@ TARGETMENUID=0 #All devices - local current_cpu_governor=$(grep -m1 '^cpu_governor=' /DietPi/dietpi.txt | sed 's/.*=//') + local current_cpu_governor=$(grep -m1 '^CONFIG_CPU_GOVERNOR=' /DietPi/dietpi.txt | sed 's/.*=//') local frequency_min_cpu_governor=1 local fp_frequency_min_cpu_governor='/sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq' @@ -1547,7 +1495,7 @@ fi - local arm_temp=$(/DietPi/dietpi/dietpi-cpuinfo 1) + local arm_temp=$(G_OBTAIN_CPU_TEMP) local arm_temp_f='Unknown' if [[ $arm_temp =~ ^-?[0-9]+$ ]]; then @@ -1565,7 +1513,7 @@ local whiptail_menu_array=() #Overclocking - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then whiptail_menu_array+=("Overclocking" "Set Profile") fi @@ -1577,7 +1525,7 @@ [ "$current_cpu_governor" = "conservative" ] || [ "$current_cpu_governor" = "interactive" ]; then - local current_cpu_throttle_up=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_usage_throttle_up' | sed 's/.*=//') + local current_cpu_throttle_up=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_USAGE_THROTTLE_UP=' | sed 's/.*=//') whiptail_menu_array+=("CPU Throttle Up" ": $current_cpu_throttle_up%") fi @@ -1586,10 +1534,10 @@ #Ondemand extras if [ "$current_cpu_governor" = ondemand ]; then - local current_cpu_sample_rate=$(( $(cat /DietPi/dietpi.txt | grep -m1 '^cpu_ondemand_sampling_rate=' | sed 's/.*=//') / 1000 )) #convert to ms + local current_cpu_sample_rate=$(( $(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_ONDEMAND_SAMPLE_RATE=' | sed 's/.*=//') / 1000 )) #convert to ms whiptail_menu_array+=("Ondemand Sample Rate" ": $current_cpu_sample_rate ms") - local current_cpu_down_factor=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_ondemand_sampling_down_factor=' | sed 's/.*=//') + local current_cpu_down_factor=$(grep -m1 '^CONFIG_CPU_ONDEMAND_SAMPLE_DOWNFACTOR=' /DietPi/dietpi.txt | sed 's/.*=//') local current_cpu_down_factor_ms=$(( $current_cpu_down_factor * $current_cpu_sample_rate )) whiptail_menu_array+=("Ondemand Down Factor" ": $current_cpu_down_factor ($current_cpu_down_factor_ms ms)") @@ -1597,7 +1545,7 @@ # User Scaling Max Freq limit. - local user_frequency_max_current=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_max_frequency=' | sed 's/.*=//') + local user_frequency_max_current=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_MAX_FREQ=' | sed 's/.*=//') local user_frequency_max_text="$user_frequency_max_current MHz" if (( ! $user_frequency_max_current )); then user_frequency_max_text="Disabled" @@ -1606,7 +1554,7 @@ whiptail_menu_array+=("CPU Max Freq Limit" ": $user_frequency_max_text") # User Scaling Min Freq limit. - local user_frequency_min_current=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_min_frequency=' | sed 's/.*=//') + local user_frequency_min_current=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_MIN_FREQ=' | sed 's/.*=//') local user_frequency_min_text="$user_frequency_min_current MHz" if (( ! $user_frequency_min_current )); then user_frequency_min_text="Disabled" @@ -1615,7 +1563,7 @@ whiptail_menu_array+=("CPU Min Freq Limit" ": $user_frequency_min_text") #RPi extras - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then local current_arm_temp_limit=$(cat /DietPi/config.txt | grep -m1 'temp_limit' | sed 's/.*=//') local current_initial_turbo=$(cat /DietPi/config.txt | grep -m1 'initial_turbo' | sed 's/.*=//') @@ -1641,7 +1589,7 @@ fi WHIP_TITLE='DietPi - Performance Options' - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n ARM Temp: $arm_temp : $arm_temp_f\n RAM: $memory_total MB | Used: $memory_usage MB | Free: $memory_free MB" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 18 60 8 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n ARM Temp: $arm_temp : $arm_temp_f\n RAM: $memory_total MB | Used: $memory_usage MB | Free: $memory_free MB" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 18 60 8 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) CHOICE=$? @@ -1662,7 +1610,7 @@ if [[ $OPTION =~ ^-?[0-9]+$ ]] && (($OPTION <= $MAX_VALUE)) && (($OPTION >= $MIN_VALUE)); then - sed -i "/cpu_ondemand_sampling_down_factor=/c\cpu_ondemand_sampling_down_factor=$OPTION" /DietPi/dietpi.txt + sed -i "/CONFIG_CPU_ONDEMAND_SAMPLE_DOWNFACTOR=/c\CONFIG_CPU_ONDEMAND_SAMPLE_DOWNFACTOR=$OPTION" /DietPi/dietpi.txt #Apply changes /DietPi/dietpi/dietpi-cpu_set @@ -1708,7 +1656,7 @@ if [[ $OPTION =~ ^-?[0-9]+$ ]] && (($OPTION <= $MAX_VALUE)) && (($OPTION >= $MIN_VALUE)); then - sed -i "/cpu_ondemand_sampling_rate=/c\cpu_ondemand_sampling_rate=$(($OPTION * 1000))" /DietPi/dietpi.txt + sed -i "/CONFIG_CPU_ONDEMAND_SAMPLE_RATE=/c\CONFIG_CPU_ONDEMAND_SAMPLE_RATE=$(($OPTION * 1000))" /DietPi/dietpi.txt #Apply changes /DietPi/dietpi/dietpi-cpu_set @@ -1802,12 +1750,12 @@ # Set max > return to default if [ "$OPTION" = "Disabled" ]; then - sed -i "/cpu_max_frequency=/c\cpu_max_frequency=$max_clock" /DietPi/dietpi.txt + sed -i "/CONFIG_CPU_MAX_FREQ=/c\CONFIG_CPU_MAX_FREQ=$max_clock" /DietPi/dietpi.txt /DietPi/dietpi/dietpi-cpu_set fi - sed -i "/cpu_max_frequency=/c\cpu_max_frequency=$OPTION" /DietPi/dietpi.txt + sed -i "/CONFIG_CPU_MAX_FREQ=/c\CONFIG_CPU_MAX_FREQ=$OPTION" /DietPi/dietpi.txt /DietPi/dietpi/dietpi-cpu_set fi @@ -1859,12 +1807,12 @@ # Set min > return to default if [ "$OPTION" = "Disabled" ]; then - sed -i "/cpu_min_frequency=/c\cpu_min_frequency=$min_clock" /DietPi/dietpi.txt + sed -i "/CONFIG_CPU_MIN_FREQ=/c\CONFIG_CPU_MIN_FREQ=$min_clock" /DietPi/dietpi.txt /DietPi/dietpi/dietpi-cpu_set fi - sed -i "/cpu_min_frequency=/c\cpu_min_frequency=$OPTION" /DietPi/dietpi.txt + sed -i "/CONFIG_CPU_MIN_FREQ=/c\CONFIG_CPU_MIN_FREQ=$OPTION" /DietPi/dietpi.txt /DietPi/dietpi/dietpi-cpu_set fi @@ -1898,9 +1846,7 @@ local Description="Change CPU Governor:" local whiptail_menu_array=() - # - C1 | disable ondemand: https://github.com/Fourdee/DietPi/issues/248 - if (( $(cat "$FP_CPU_SCALING_GOV" | grep -ci -m1 'ondemand') == 1 )) && - (( $HW_MODEL != 10 )); then + if (( $(cat "$FP_CPU_SCALING_GOV" | grep -ci -m1 'ondemand') == 1 )); then whiptail_menu_array+=("ondemand" "Scales CPU frequency between $frequency_min_cpu_governor MHz and $frequency_max_cpu_governor MHz.") Description+="\nOndemand | Dynamic CPU frequency based on usage (recommended)." @@ -1943,7 +1889,7 @@ if (( $CHOICE == 0 )); then - sed -i "/cpu_governor=/c\cpu_governor=$OPTION" /DietPi/dietpi.txt + sed -i "/CONFIG_CPU_GOVERNOR=/c\CONFIG_CPU_GOVERNOR=$OPTION" /DietPi/dietpi.txt /DietPi/dietpi/dietpi-cpu_set fi @@ -1964,7 +1910,7 @@ if [[ $OPTION =~ ^-?[0-9]+$ ]] && (($OPTION <= $MAX_VALUE)) && (($OPTION >= $MIN_VALUE)); then - sed -i "/cpu_usage_throttle_up=/c\cpu_usage_throttle_up=$OPTION" /DietPi/dietpi.txt + sed -i "/CONFIG_CPU_USAGE_THROTTLE_UP=/c\CONFIG_CPU_USAGE_THROTTLE_UP=$OPTION" /DietPi/dietpi.txt #Apply changes /DietPi/dietpi/dietpi-cpu_set @@ -2148,22 +2094,22 @@ local ram_mem_current=0 local ram_mem_total=0 - if (( $HW_MODEL == 0 )); then + if (( $G_HW_MODEL == 0 )); then gpu_mem_current=$(grep -m1 'gpu_mem_256=' /DietPi/config.txt | sed 's/.*=//') ram_mem_current=$((256-gpu_mem_current)) ram_mem_total=256 - elif (( $HW_MODEL == 1 )); then + elif (( $G_HW_MODEL == 1 )); then gpu_mem_current=$(grep -m1 'gpu_mem_512=' /DietPi/config.txt | sed 's/.*=//') ram_mem_current=$((512-gpu_mem_current)) ram_mem_total=512 - elif (( $HW_MODEL == 2 )) || (( $HW_MODEL == 3 )); then + elif (( $G_HW_MODEL == 2 )) || (( $G_HW_MODEL == 3 )); then gpu_mem_current=$(grep -m1 'gpu_mem_1024=' /DietPi/config.txt | sed 's/.*=//') ram_mem_current=$((1024-gpu_mem_current)) ram_mem_total=1024 - elif (( $HW_MODEL == 10 )); then + elif (( $G_HW_MODEL == 10 )); then ram_mem_current=$(free -m | grep -m1 'Mem:' | awk '{print $2}') gpu_mem_current=$((1024-ram_mem_current)) - elif (( $HW_MODEL == 12 )); then + elif (( $G_HW_MODEL == 12 )); then ram_mem_current=$(free -m | grep -m1 'Mem:' | awk '{print $2}') gpu_mem_current=$((2048-ram_mem_current)) fi @@ -2171,7 +2117,7 @@ WHIP_TITLE='DietPi - GPU/RAM Split' #RPi's - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then #Create array for storing menu selectable options. local -a option_name=( @@ -2189,12 +2135,12 @@ 128 ) - if (( $HW_MODEL == 0 )); then + if (( $G_HW_MODEL == 0 )); then echo -e "As above, array is defaulted to RPi1 - 256mb" &> /dev/null - elif (( $HW_MODEL == 1 )); then + elif (( $G_HW_MODEL == 1 )); then available_gpu_values[2]=128 available_gpu_values[3]=192 - elif (( $HW_MODEL == 2 )) || (( $HW_MODEL == 3 )); then + 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 @@ -2207,7 +2153,7 @@ option_output_text+=("${option_name[$i]}" "${available_gpu_values[$i]} MB GPU | $((ram_mem_total - ${available_gpu_values[$i]})) MB RAM") done - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n Current: $gpu_mem_current MB GPU | $ram_mem_current MB RAM" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 14 75 4 "${option_output_text[@]}" 3>&1 1>&2 2>&3) + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n Current: $gpu_mem_current MB GPU | $ram_mem_current MB RAM" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 14 75 4 "${option_output_text[@]}" 3>&1 1>&2 2>&3) CHOICE=$? if (( $CHOICE == 0 )); then @@ -2235,7 +2181,7 @@ unset available_gpu_values #Odroid C1 - elif (( $HW_MODEL == 10 )); then + elif (( $G_HW_MODEL == 10 )); then #Odroid HDMI/headless extra data local display_output_enabled=$(cat /DietPi/boot.ini | grep -ci -m1 '^setenv hdmioutput "1"') @@ -2250,7 +2196,7 @@ display_vpu_text="Disabled" fi - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n Current : HDMI: $display_output_text | VPU: $display_vpu_text \n Memory : $gpu_mem_current MB GPU | $ram_mem_current MB RAM \n NB: GPU/RAM figures require a reboot after a change is made." --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 15 70 3 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n Current : HDMI: $display_output_text | VPU: $display_vpu_text \n Memory : $gpu_mem_current MB GPU | $ram_mem_current MB RAM \n NB: GPU/RAM figures require a reboot after a change is made." --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 15 70 3 \ "Headless" "HDMI: Disabled | VPU: Disabled" \ "Server" "HDMI: Enabled | VPU: Disabled" \ "Desktop" "HDMI: Enabled | VPU: Enabled" 3>&1 1>&2 2>&3) @@ -2280,7 +2226,7 @@ esac #C2 - elif (( $HW_MODEL == 12 )); then + 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"') @@ -2290,7 +2236,7 @@ display_output_text="Disabled" fi - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n Current : HDMI: $display_output_text | VPU: $display_output_text \n Memory : $gpu_mem_current MB GPU | $ram_mem_current MB RAM \n NB: GPU/RAM figures require a reboot after a change is made." --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 14 70 2 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n Current : HDMI: $display_output_text | VPU: $display_output_text \n Memory : $gpu_mem_current MB GPU | $ram_mem_current MB RAM \n NB: GPU/RAM figures require a reboot after a change is made." --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 14 70 2 \ "Headless" "HDMI: Disabled | VPU: Disabled | +300MB RAM" \ "Default" "HDMI: Enabled | VPU: Enabled | -300MB RAM" 3>&1 1>&2 2>&3) @@ -2327,39 +2273,40 @@ case "$OPTION" in Locale) - REBOOT_REQUIRED=1 - # - Warn user that DietPi requires en_GB to be installed, to ensure all DietPi script parsing is correct. - whiptail --title "DietPi Locale" --msgbox "DietPi requires en_GB.UTF-8 to be installed. This ensures all DietPi scripts can scrape correctly.\n\nPlease do NOT remove en_GB.UTF-8 from the system, when selecting your Locale." --backtitle "$WHIP_BACKTITLE" 12 65 + REBOOT_REQUIRED=1 dpkg-reconfigure locales - #Pump current system locale into env: https://github.com/Fourdee/DietPi/issues/825 - local locale_current=$(cat /etc/default/locale | grep -m1 '^LANG=' | sed 's/.*=//') + local locale_new=$(grep -m1 '^LANG=' /etc/default/locale | sed 's/.*=//') # Sanity, No result, revert back to default - if [ -z "$locale_current" ]; then + if [ -z "$locale_new" ]; then - locale_current='en_GB.UTF-8' + locale_new='en_GB.UTF-8' fi - cat << _EOF_ > /etc/environment -LC_ALL=$locale_current -LANG=$locale_current -_EOF_ + # - Re-apply locale + auto install en_GB.UTF-8 alongside + /DietPi/dietpi/func/dietpi-set_software locale "$locale_new" #Return to this menu TARGETMENUID=7 + ;; + Timezone) + REBOOT_REQUIRED=1 dpkg-reconfigure tzdata #Return to this menu TARGETMENUID=7 + ;; + Keyboard) + REBOOT_REQUIRED=1 #Keyboard must be plugged in for this to bring up the menu.. @@ -2369,8 +2316,11 @@ _EOF_ #Return to this menu TARGETMENUID=7 + ;; + esac + } ETH_IP_STATIC="0.0.0.0" @@ -2439,17 +2389,6 @@ _EOF_ #Stop all services (required for hotspot) /DietPi/dietpi/dietpi-services stop - #Release all DHCP leases (too slow, quicker to allow router to decide leases) - #dhclient -r - - #Drop Connections - /DietPi/dietpi/func/dietpi-notify 2 "Dropping connections, please wait..." - ifdown eth$ETH_INDEX &> /dev/null - ifdown wlan$WIFI_INDEX &> /dev/null - - #Kill dhclient - killall dhclient &> /dev/null - # Enable/Disable wifi modules # - enable if (( $WIFI_DISABLED == 0 )); then @@ -2463,8 +2402,19 @@ _EOF_ 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_INDEX &> /dev/null + ifdown wlan$WIFI_INDEX &> /dev/null + + #Kill dhclient + killall dhclient &> /dev/null + #Restart Networking - /DietPi/dietpi/func/dietpi-notify 2 'Restarting networking services, please wait...' + G_DIETPI-NOTIFY 2 'Restarting networking services, please wait...' systemctl daemon-reload systemctl restart networking @@ -2579,13 +2529,13 @@ _EOF_ if (( $WIFI_HOTSPOT == 0 )); then # - Update globals - sed -i "/^Wifi_SSID=/c\Wifi_SSID=$WIFI_SSID" /DietPi/dietpi.txt - sed -i "/^Wifi_KEY=/c\Wifi_KEY=$WIFI_KEY" /DietPi/dietpi.txt + sed -i "/^AUTO_SETUP_NET_WIFI_SSID=/c\AUTO_SETUP_NET_WIFI_SSID=$WIFI_SSID" /DietPi/dietpi.txt + sed -i "/^AUTO_SETUP_NET_WIFI_KEY=/c\AUTO_SETUP_NET_WIFI_KEY=$WIFI_KEY" /DietPi/dietpi.txt # Open host if [ -z "$WIFI_KEY" ]; then - sed -i '/Wifi_KEYMGR=/c\Wifi_KEYMGR=NONE' /DietPi/dietpi.txt + sed -i '/AUTO_SETUP_NET_WIFI_KEYMGR=/c\AUTO_SETUP_NET_WIFI_KEYMGR=NONE' /DietPi/dietpi.txt # Key host @@ -2593,7 +2543,7 @@ _EOF_ # WEP tests failed, dropping support as its outdated and not secure. WPA-PSK is recommended for router. else - sed -i '/Wifi_KEYMGR=/c\Wifi_KEYMGR=WPA-PSK' /DietPi/dietpi.txt + sed -i '/AUTO_SETUP_NET_WIFI_KEYMGR=/c\AUTO_SETUP_NET_WIFI_KEYMGR=WPA-PSK' /DietPi/dietpi.txt fi @@ -2776,11 +2726,14 @@ _EOF_ #Apply /DietPi/dietpi/func/dietpi-set_hardware wificountrycode "$wifi_country_code_target" - #iw reg set $wifi_country_code_target # - Restart networking Network_Restart + # - Additional fallback for (older kernel?) devices that fail with wpa_supplicant.conf https://github.com/Fourdee/DietPi/issues/838 + # NB: Requires adapter up... hence, not in dietpi-set_hardware + 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 ':') if [ "$WIFI_COUNTRYCODE" != "$wifi_country_code_target" ]; then @@ -2865,7 +2818,7 @@ _EOF_ INTERNET_ONLINE=0 #Not tested #Check for connection - /DietPi/dietpi/func/check_connection "$INTERNET_URL" + wget --spider --timeout=10 --tries=2 "$INTERNET_URL" if (( $? == 0 )); then INTERNET_ONLINE=2 #Online else @@ -2928,10 +2881,14 @@ _EOF_ #?????????????????????????????????????????????????????? # We cant rely on lsmod for this. Some of our images have cfg80211 built into kernel, so lsmod wont show a result. # Redirect stderr and stdout does nowt 2> /dev/null and &> /dev/null no effect. - #if (( $(lsmod | grep -ci -m1 'cfg80211' ) )); then - WIFI_COUNTRYCODE=$(iw reg get | grep -m1 'country' | awk '{print $2}' | tr -d ':') - #fi + + WIFI_COUNTRYCODE='GB' + if [ -n "$(which iw)" ]; then + + WIFI_COUNTRYCODE=$(iw reg get | grep -m1 'country' | awk '{print $2}' | tr -d ':') + + fi #?????????????????????????????????????????????????????? @@ -2973,8 +2930,8 @@ _EOF_ WIFI_CONNECTED=$(ip r | grep -ci -m1 "wlan$WIFI_INDEX") #Wifi Extras - WIFI_SSID="$(grep -m1 '^Wifi_SSID' /DietPi/dietpi.txt | sed 's/.*=//')" - WIFI_KEY="$(grep -m1 '^Wifi_KEY' /DietPi/dietpi.txt | sed 's/.*=//')" + WIFI_SSID="$(grep -m1 '^AUTO_SETUP_NET_WIFI_SSID=' /DietPi/dietpi.txt | sed 's/.*=//')" + WIFI_KEY="$(grep -m1 '^AUTO_SETUP_NET_WIFI_KEY=' /DietPi/dietpi.txt | sed 's/.*=//')" #Enabled and Connected if (( $WIFI_DISABLED == 0 )) && (( $WIFI_CONNECTED == 1 )); then @@ -3069,7 +3026,7 @@ _EOF_ #IPv6 status local ipv6_enabled=1 local ipv6_status_text='Enabled' - if [ -f /etc/modprobe.d/blacklist-ipv6.conf ]; then + if [ ! -d /proc/sys/net/ipv6 ]; then ipv6_enabled=0 ipv6_status_text='Disabled' fi @@ -3150,7 +3107,30 @@ _EOF_ if (( $CHOICE == 0 )); then - echo -e "blacklist ipv6" > /etc/modprobe.d/blacklist-ipv6.conf + if (( G_HW_ARCH == 10 )); then + # On amd64 images, IPv6 is no kernel module, but can be disabled via grub: https://github.com/Fourdee/DietPi/issues/1343#issuecomment-359652751 + + if (( ! $(grep -ci -m1 'ipv6.disable=1' /etc/default/grub) )); then + + sed -i 's/GRUB_CMDLINE_LINUX_DEFAULT=\"/GRUB_CMDLINE_LINUX_DEFAULT=\"ipv6.disable=1 /g' /etc/default/grub + update-grub + + fi + + else + # On all other images, IPv6 is a kernel module, which can be blacklisted. + + echo 'blacklist ipv6' > /etc/modprobe.d/99-dietpi-blacklist-ipv6.conf + + fi + # - APT force IPv4 + echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99-dietpi-force-ipv4 + # - Wget prefer IPv4 + grep -q '^[[:blank:]]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]]*prefer-family =/c\prefer-family = IPv4' /etc/wgetrc || + grep -q '^[[:blank:]#;]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]#;]*prefer-family =/c\prefer-family = IPv4' /etc/wgetrc || + echo 'prefer-family = IPv4' >> /etc/wgetrc REBOOT_REQUIRED=1 fi @@ -3163,7 +3143,24 @@ _EOF_ if (( $CHOICE == 0 )); then - rm /etc/modprobe.d/blacklist-ipv6.conf &> /dev/null + if (( G_HW_ARCH == 10 )); then + + sed -i 's/ipv6.disable=1 //g' /etc/default/grub + update-grub + + else + + rm /etc/modprobe.d/99-dietpi-blacklist-ipv6.conf &> /dev/null + + fi + # - APT allow IPv6 but do not force it: https://github.com/Fourdee/DietPi/issues/472#issuecomment-356444922 + rm /etc/apt/apt.conf.d/99-dietpi-force-ipv4 &> /dev/null + # - Wget prefer IPv6 + grep -q '^[[:blank:]]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]]*prefer-family =/c\prefer-family = IPv6' /etc/wgetrc || + grep -q '^[[:blank:]#;]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]#;]*prefer-family =/c\prefer-family = IPv6' /etc/wgetrc || + echo 'prefer-family = IPv6' >> /etc/wgetrc REBOOT_REQUIRED=1 fi @@ -3421,7 +3418,7 @@ _EOF_ systemctl stop dietpi-wifi-monitor.service rm /etc/systemd/system/dietpi-wifi-monitor.service - rm /etc/dietpi/dietpi-wifi-monitor.sh + rm /var/lib/dietpi/dietpi-wifi-monitor.sh systemctl daemon-reload fi @@ -3430,7 +3427,7 @@ _EOF_ WiFi_Monitor_Enable(){ - cat << _EOF_ > /etc/dietpi/dietpi-wifi-monitor.sh + cat << _EOF_ > /var/lib/dietpi/dietpi-wifi-monitor.sh #!/bin/bash { URL_PING="$WIFI_GATEWAY" @@ -3438,19 +3435,19 @@ ADAPTER="wlan$WIFI_INDEX" TICKRATE=10 while true do -/DietPi/dietpi/func/dietpi-notify 2 "Checking connnection for: \$ADAPTER" +G_DIETPI-NOTIFY 2 "Checking connnection for: \$ADAPTER" ping -I \$ADAPTER -c 1 \$URL_PING if (( \$? != 0 )); then -/DietPi/dietpi/func/dietpi-notify 2 "Detected connection loss: \$ADAPTER. Reconnecting" +G_DIETPI-NOTIFY 2 "Detected connection loss: \$ADAPTER. Reconnecting" ifdown "\$ADAPTER" sleep 1 ifup "\$ADAPTER" -/DietPi/dietpi/func/dietpi-notify 0 'Completed' +G_DIETPI-NOTIFY 0 'Completed' else -/DietPi/dietpi/func/dietpi-notify 0 "Connection \$ADAPTER" +G_DIETPI-NOTIFY 0 "Connection \$ADAPTER" fi @@ -3462,7 +3459,7 @@ exit 0 } _EOF_ - chmod +x /etc/dietpi/dietpi-wifi-monitor.sh + chmod +x /var/lib/dietpi/dietpi-wifi-monitor.sh cat << _EOF_ > /etc/systemd/system/dietpi-wifi-monitor.service [Unit] @@ -3470,7 +3467,7 @@ Description=Monitors loss of WiFi connection and automatically reconnects After=network.target network-online.target [Service] Type=simple -ExecStart=/bin/bash -c /etc/dietpi/dietpi-wifi-monitor.sh +ExecStart=/bin/bash -c /var/lib/dietpi/dietpi-wifi-monitor.sh [Install] WantedBy=multi-user.target _EOF_ @@ -3707,9 +3704,9 @@ _EOF_ Apply) if (( $WIFI_HOTSPOT == 1 )); then # - update dietpi.txt - sed -i "/wifi_hotspot_ssid=/c\wifi_hotspot_ssid=$HOTSPOT_SSID" /DietPi/dietpi.txt - sed -i "/wifi_hotspot_channel=/c\wifi_hotspot_channel=$HOTSPOT_CHANNEL" /DietPi/dietpi.txt - sed -i "/wifi_hotspot_key=/c\wifi_hotspot_key=$HOTSPOT_KEY" /DietPi/dietpi.txt + sed -i "/SOFTWARE_WIFI_HOTSPOT_SSID=/c\SOFTWARE_WIFI_HOTSPOT_SSID=$HOTSPOT_SSID" /DietPi/dietpi.txt + sed -i "/SOFTWARE_WIFI_HOTSPOT_CHANNEL=/c\SOFTWARE_WIFI_HOTSPOT_CHANNEL=$HOTSPOT_CHANNEL" /DietPi/dietpi.txt + sed -i "/SOFTWARE_WIFI_HOTSPOT_KEY=/c\SOFTWARE_WIFI_HOTSPOT_KEY=$HOTSPOT_KEY" /DietPi/dietpi.txt # - update hostapd conf sed -i "/ssid=/c\ssid=$HOTSPOT_SSID" /etc/hostapd/hostapd.conf @@ -3914,15 +3911,15 @@ _EOF_ #Run benchmark if (( $run_benchmark == 1 )); then - /DietPi/dietpi/func/dietpi-notify 2 "Performing $text_info_test_name benchmark, please wait..." + G_DIETPI-NOTIFY 2 "Performing $text_info_test_name benchmark, please wait..." - /DietPi/dietpi/func/dietpi-notify 2 "Testing Seq Write Speed ($benchmark_filesize MB)" + G_DIETPI-NOTIFY 2 "Testing Seq Write Speed ($benchmark_filesize MB)" - if (( $DISTRO == 3 )); then + if (( $G_DISTRO == 3 )); then write_speed=$(dd bs=4K count=$(( $benchmark_filesize * 1024 / 4 )) if=/dev/zero of=$benchmark_temp_file conv=fdatasync 2>&1 | grep 'MB' | awk '{print $8, $9}') - elif (( $DISTRO == 4 )); then + elif (( $G_DISTRO == 4 )); then write_speed=$(dd bs=4K count=$(( $benchmark_filesize * 1024 / 4 )) if=/dev/zero of=$benchmark_temp_file conv=fdatasync 2>&1 | grep 'MB' | awk '{print $10, $11}') @@ -3931,13 +3928,13 @@ _EOF_ # - Clear cache sync echo 3 > /proc/sys/vm/drop_caches - /DietPi/dietpi/func/dietpi-notify 2 "Testing Seq Read Speed ($benchmark_filesize MB)" + G_DIETPI-NOTIFY 2 "Testing Seq Read Speed ($benchmark_filesize MB)" - if (( $DISTRO == 3 )); then + if (( $G_DISTRO == 3 )); then read_speed=$(dd bs=4K count=$(( $benchmark_filesize * 1024 / 4 )) if=$benchmark_temp_file of=/dev/zero conv=fdatasync 2>&1 | grep 'MB' | awk '{print $8, $9}') - elif (( $DISTRO == 4 )); then + elif (( $G_DISTRO == 4 )); then read_speed=$(dd bs=4K count=$(( $benchmark_filesize * 1024 / 4 )) if=$benchmark_temp_file of=/dev/zero conv=fdatasync 2>&1 | grep 'MB' | awk '{print $10, $11}') @@ -3977,25 +3974,25 @@ _EOF_ # if (( ! $(dpkg --get-selections | grep -ci -m1 '^sysbench[[:space:]]') )); then - # /DietPi/dietpi/func/dietpi-notify 2 "Installing Sysbench, please wait..." - # apt-get install sysbench -y + # G_DIETPI-NOTIFY 2 "Installing Sysbench, please wait..." + # G_AGI sysbench # fi /DietPi/dietpi/dietpi-services stop - # /DietPi/dietpi/func/dietpi-notify 0 "Running Sysbench with max prime of $CPUBENCH_INT_MAX, please wait..." + # G_DIETPI-NOTIFY 0 "Running Sysbench with max prime of $CPUBENCH_INT_MAX, please wait..." # local fp_log_sysbench='/tmp/.fp_log_sysbench' # sysbench --test=cpu --num-threads=$(nproc --all) --cpu-max-prime=$CPUBENCH_INT_MAX --validate=on run | tee -a "$fp_log_sysbench" - # /DietPi/dietpi/func/dietpi-notify 0 "Sysbench completed" + # G_DIETPI-NOTIFY 0 "Sysbench completed" # CPUBENCH_TIME=$(grep -m1 'total time' "$fp_log_sysbench" | awk '{print $NF}') # rm "$fp_log_sysbench" - /DietPi/dietpi/func/dietpi-notify 0 "Running DietPi-CPU Benchmark with max value of 1000000 over $(nproc --all) cores, please wait..." + G_DIETPI-NOTIFY 0 "Running DietPi-CPU Benchmark with max value of 1000000 over $(nproc --all) cores, please wait..." cat << _EOF_ > /tmp/dietpi-bench #!/bin/bash @@ -4160,19 +4157,19 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ sed -i '/over_voltage=/c\#over_voltage=0' /DietPi/config.txt - if (( $HW_MODEL == 3 )); then + if (( $G_HW_MODEL == 3 )); then sed -i '/arm_freq=/c\#arm_freq=1200' /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 - elif (( $HW_MODEL == 2 )); then + elif (( $G_HW_MODEL == 2 )); then 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 - elif (( $HW_MODEL <= 1 )); then + elif (( $G_HW_MODEL <= 1 )); then sed -i '/arm_freq=/c\#arm_freq=700' /DietPi/config.txt sed -i '/core_freq=/c\#core_freq=250' /DietPi/config.txt @@ -4215,10 +4212,10 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ #Overclocking Pi1 # - Zero - echo -e "$HW_MODEL" + echo -e "$G_HW_MODEL" if (( $(cat /DietPi/dietpi/.hw_model | tr '[:upper:]' '[:lower:]' | grep -ci -m1 'rpi zero') )); then - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n Current: $arm_freq_value MHz ARM | $core_freq_value MHz core | $sdram_freq_value MHz SDRAM | $over_voltage_value overvolt" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 13 75 4 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n Current: $arm_freq_value MHz ARM | $core_freq_value MHz core | $sdram_freq_value MHz SDRAM | $over_voltage_value overvolt" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 13 75 4 \ "none" " 1000 MHz ARM | 400 MHz core | 450 MHz SDRAM | 0 overvolt" 3>&1 1>&2 2>&3) case "$OPTION" in @@ -4231,9 +4228,9 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ ;; esac - elif (( $HW_MODEL <= 1 )); then + elif (( $G_HW_MODEL <= 1 )); then - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n Current: $arm_freq_value MHz ARM | $core_freq_value MHz core | $sdram_freq_value MHz SDRAM | $over_voltage_value overvolt" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 14 70 4 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n Current: $arm_freq_value MHz ARM | $core_freq_value MHz core | $sdram_freq_value MHz SDRAM | $over_voltage_value overvolt" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 14 70 4 \ "none" " 700 MHz ARM | 250 MHz core | 400 MHz SDRAM | 0 overvolt" \ "safe" " 900 MHz ARM | 250 MHz core | 400 MHz SDRAM | 2 overvolt" \ "high" " 900 MHz ARM | 500 MHz core | 400 MHz SDRAM | 4 overvolt" \ @@ -4287,9 +4284,9 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ esac #Overclocking Pi2 - elif (( $HW_MODEL == 2 )); then + elif (( $G_HW_MODEL == 2 )); then - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n Current: $arm_freq_value MHz ARM | $core_freq_value MHz core | $sdram_freq_value MHz SDRAM | $over_voltage_value overvolt" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 13 75 4 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n Current: $arm_freq_value MHz ARM | $core_freq_value MHz core | $sdram_freq_value MHz SDRAM | $over_voltage_value overvolt" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 13 75 4 \ "none" " 900 MHz ARM | 250 MHz core | 450 MHz SDRAM | 0 overvolt" \ "low" "1000 MHz ARM | 250 MHz core | 450 MHz SDRAM | 3 overvolt" \ "med" "1000 MHz ARM | 500 MHz core | 450 MHz SDRAM | 5 overvolt" \ @@ -4347,9 +4344,9 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ esac #Overclocking Pi3 - elif (( $HW_MODEL == 3 )); then + elif (( $G_HW_MODEL == 3 )); then - OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $HW_MODEL_DESCRIPTION \n Current: $arm_freq_value MHz ARM | $core_freq_value MHz core | $sdram_freq_value MHz SDRAM | $over_voltage_value overvolt" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 13 75 4 \ + OPTION=$(whiptail --title "$WHIP_TITLE" --menu " Hardware : $G_HW_MODEL_DESCRIPTION \n Current: $arm_freq_value MHz ARM | $core_freq_value MHz core | $sdram_freq_value MHz SDRAM | $over_voltage_value overvolt" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 13 75 4 \ "none" "1200 MHz ARM | 400 MHz core | 450 MHz SDRAM | 0 overvolt" \ "low" "1300 MHz ARM | 400 MHz core | 450 MHz SDRAM | 3 overvolt" \ "med" "1325 MHz ARM | 400 MHz core | 450 MHz SDRAM | 4 overvolt" \ @@ -4424,7 +4421,7 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ TARGETMENUID=0 - local soundcard_current=$(grep -m1 'soundcard=' /DietPi/dietpi.txt | sed 's/.*=//') + local soundcard_current=$(grep -m1 '^CONFIG_SOUNDCARD=' /DietPi/dietpi.txt | sed 's/.*=//') local whiptail_menu_array=() @@ -4437,10 +4434,10 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ fi # - RPi, low power mode (PSU noise ripple reduction): https://github.com/Fourdee/DietPi/issues/757 - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then - local current_cpu_governor=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_governor=' | sed 's/.*=//') - local hdmi_output=$(cat /DietPi/dietpi.txt | grep -m1 'rpi_hdmi_output=' | sed 's/.*=//') + local current_cpu_governor=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_GOVERNOR=' | sed 's/.*=//') + local hdmi_output=$(cat /DietPi/dietpi.txt | grep -m1 'CONFIG_HDMI_OUTPUT=' | sed 's/.*=//') local psu_noise_reduction_enabled=0 if [ "$current_cpu_governor" = "powersave" ] && (( ! $hdmi_output )); then @@ -4470,17 +4467,17 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ whiptail --title "PSU noise reduction" --msgbox "This mode attempts to reduce power consumption on your SBC. In turn, this may reduce PSU inflicted noise, that may degrade audio output quality.\n\nThe following has now been set:\n - CPU gov = Powersave\n - HDMI output = Disabled" --backtitle "$WHIP_BACKTITLE" 14 70 - sed -i "/cpu_governor=/c\cpu_governor=powersave" /DietPi/dietpi.txt + sed -i "/CONFIG_CPU_GOVERNOR=/c\CONFIG_CPU_GOVERNOR=powersave" /DietPi/dietpi.txt /DietPi/dietpi/dietpi-cpu_set - sed -i "/rpi_hdmi_output=/c\rpi_hdmi_output=0" /DietPi/dietpi.txt + sed -i "/CONFIG_HDMI_OUTPUT=/c\CONFIG_HDMI_OUTPUT=0" /DietPi/dietpi.txt else - sed -i "/cpu_governor=/c\cpu_governor=ondemand" /DietPi/dietpi.txt + sed -i "/CONFIG_CPU_GOVERNOR=/c\CONFIG_CPU_GOVERNOR=ondemand" /DietPi/dietpi.txt /DietPi/dietpi/dietpi-cpu_set - sed -i "/rpi_hdmi_output=/c\rpi_hdmi_output=1" /DietPi/dietpi.txt + sed -i "/CONFIG_HDMI_OUTPUT=/c\CONFIG_HDMI_OUTPUT=1" /DietPi/dietpi.txt fi @@ -4495,17 +4492,17 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ # - Global: # RPI, none disables HDMI aswell. - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then whiptail_menu_array+=("none" "Disables HDMI + 3.5mm Analogue") # NanoPi M2/M3, BPi Pro, OPi Zero - elif (( $HW_MODEL == 32 || $HW_MODEL == 51 || $HW_MODEL == 61 || $HW_MODEL == 62 )); then + elif (( $G_HW_MODEL == 32 || $G_HW_MODEL == 51 || $G_HW_MODEL == 61 || $G_HW_MODEL == 62 )); then whiptail_menu_array+=("default" "3.5mm Analogue") # Native PC | List available - elif (( $HW_MODEL == 21 )); then + elif (( $G_HW_MODEL == 21 )); then whiptail_menu_array+=("default" "HW:0,0") @@ -4548,7 +4545,7 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ fi # - RPI - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then whiptail_menu_array+=("rpi-bcm2835" "Onboard: HDMI (if plugged in, else 3.5mm)") whiptail_menu_array+=("rpi-bcm2835-3.5mm" "Onboard: 3.5mm forced output") @@ -4559,6 +4556,8 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ whiptail_menu_array+=("allo-digione" "Allo DigiOne") whiptail_menu_array+=("allo-piano-dac-pcm512x-audio" "Allo Piano DAC") whiptail_menu_array+=("allo-piano-dac-pcm512x-audio" "Allo Piano DAC") + whiptail_menu_array+=("dionaudio-loco" "Dion Audio LOCO") + whiptail_menu_array+=("dionaudio-loco-v2" "Dion Audio LOCO V2") whiptail_menu_array+=("googlevoicehat-soundcard" "Google AIY voice kit") whiptail_menu_array+=("hifiberry-amp" "HifiBerry AMP / AMP+") whiptail_menu_array+=("hifiberry-dac" "HifiBerry DAC / MiniAMP") @@ -4575,38 +4574,38 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ whiptail_menu_array+=("rpi-dac" "Soekris DAM1021 (pcm1794a)") # - C1/C2 - elif (( $HW_MODEL == 10 || $HW_MODEL == 12 )); then + elif (( $G_HW_MODEL == 10 || $G_HW_MODEL == 12 )); then whiptail_menu_array+=("odroid-hifishield-plus" "Odroid HiFi Shield 1/Plus") whiptail_menu_array+=("odroid-hifishield-2" "Odroid HiFi Shield 2") # - h2+ | OPi Zero - elif (( $HW_MODEL == 32 )); then + elif (( $G_HW_MODEL == 32 )); then whiptail_menu_array+=("h2-hdmi" "HDMI") # - Rock64 - elif (( $HW_MODEL == 43 )); then + elif (( $G_HW_MODEL == 43 )); then whiptail_menu_array+=("rock64-analogue" "3.5MM") # NanoPi M2/M3 - elif (( $HW_MODEL == 61 || $HW_MODEL == 62 )); then + elif (( $G_HW_MODEL == 61 || $G_HW_MODEL == 62 )); then whiptail_menu_array+=("s5pxx18-hdmi" "HDMI") # - H3 - elif (( $HW_CPUID == 1 )); then + elif (( $G_HW_CPUID == 1 )); then whiptail_menu_array+=("H3-analogue" "3.5mm analogue") # - H5 - # elif (( $HW_CPUID == 2 )); then + # elif (( $G_HW_CPUID == 2 )); then # whiptail_menu_array+=("H5-analogue" "3.5mm analogue") # - Sparky - elif (( $HW_MODEL == 70 )); then + elif (( $G_HW_MODEL == 70 )); then whiptail_menu_array+=("snd-soc-allo-piano-dac" "Allo Piano DAC") whiptail_menu_array+=("snd-soc-allo-piano-dac-plus" "Allo Piano DAC 2.1") @@ -4614,7 +4613,7 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ whiptail_menu_array+=("allo-cheapo-optical" "Allo Cheapo (Optical output)") # - Asus tb - elif (( $HW_MODEL == 100 )); then + elif (( $G_HW_MODEL == 52 )); then whiptail_menu_array+=("asus-tb-analogue" "3.5mm analogue") @@ -4711,18 +4710,15 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ elif [ "$OPTION" = "Start" ]; then - #install stress - if (( ! $(dpkg --get-selections | grep -ci -m1 '^stress') )); then - - /DietPi/dietpi/func/dietpi-notify 2 'Installing Stress' - /DietPi/dietpi/func/dietpi-notify 2 'Please wait...' + G_AG_CHECK_INSTALL_PREREQ stress + if (( $? != 0 )); then - apt-get install -y stress + exit 1 fi - /DietPi/dietpi/func/dietpi-notify 3 Stress_Test "Running stress test for $STRESS_TEST_DURATION seconds" - /DietPi/dietpi/func/dietpi-notify 2 'To terminate, type: killall -w stress' + G_DIETPI-NOTIFY 3 Stress_Test "Running stress test for $STRESS_TEST_DURATION seconds" + G_DIETPI-NOTIFY 2 'To terminate, type: killall -w stress' local start_time=$(date) local start_time_epoch=$(date +%s) @@ -4751,7 +4747,7 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ # - Check if system supports temp readouts local cpu_supports_temp=0 - local cpu_temp=$(/DietPi/dietpi/dietpi-cpuinfo 1) + local cpu_temp=$(G_OBTAIN_CPU_TEMP) if [[ $cpu_temp =~ ^-?[0-9]+$ ]]; then cpu_supports_temp=1 @@ -4763,7 +4759,7 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ while (( $(ps aux | grep -ci -m1 '[s]tress') == 1 )) do - cpu_temp=$(/DietPi/dietpi/dietpi-cpuinfo 1) + cpu_temp=$(G_OBTAIN_CPU_TEMP) remaning_time=$(( $STRESS_TEST_DURATION + ( $start_time_epoch - $(date +%s) ) )) echo -e "$(date) | $cpu_temp'c | $remaning_time seconds remaining" @@ -4801,8 +4797,8 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ - Max Temp : $STRESS_TEST_RESULTS_TEMP_MAX 'c - log : $fp_log" - /DietPi/dietpi/func/dietpi-notify 0 'Stress Test Completed' - /DietPi/dietpi/func/dietpi-notify 2 "$output_string" + G_DIETPI-NOTIFY 0 'Stress Test Completed' + G_DIETPI-NOTIFY 2 "$output_string" whiptail --title "$WHIP_TITLE" --msgbox "Stress test results:\n$output_string" --backtitle "$WHIP_BACKTITLE" 14 65 @@ -4923,7 +4919,7 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ fi #NTPD mirror - local ntpd_mirror_current=$(cat /etc/ntp.conf | grep -m1 '^server 0.' | awk '{print $2}' | sed 's/^0.//g') + local ntpd_mirror_current=$(grep -m1 '^CONFIG_NTP_MIRROR=' /DietPi/dietpi.txt | sed 's/.*=//') if [ ! -n "$ntpd_mirror_current" ]; then ntpd_mirror_current='Unknown, no string from scrape' @@ -4931,7 +4927,7 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ fi #Network boot wait - local boot_wait_for_network=$(cat /DietPi/dietpi.txt | grep -m1 '^boot_wait_for_network=' | sed 's/.*=//') + local boot_wait_for_network=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_BOOT_WAIT_FOR_NETWORK=' | sed 's/.*=//') local boot_wait_for_network_text=': ' if (( $boot_wait_for_network == 0 )); then @@ -4973,7 +4969,7 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ CHOICE=$? if (( $CHOICE == 0 )); then - sed -i "/^boot_wait_for_network=/c boot_wait_for_network=$OPTION" /DietPi/dietpi.txt + sed -i "/^CONFIG_BOOT_WAIT_FOR_NETWORK=/c CONFIG_BOOT_WAIT_FOR_NETWORK=$OPTION" /DietPi/dietpi.txt #Return to this Menu TARGETMENUID=16 @@ -4993,7 +4989,7 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ ) # - Raspbian - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then whiptail_menu_array+=("http://mirrordirector.raspbian.org/raspbian" "Global") whiptail_menu_array+=("https://www.mirrorservice.org/sites/archive.raspbian.org/raspbian" "Global (https)") @@ -5033,13 +5029,13 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ /DietPi/dietpi/func/dietpi-set_software apt-mirror $OPTION # - test it - /DietPi/dietpi/func/dietpi-notify 2 "Updating Apt, please wait..." + G_DIETPI-NOTIFY 2 "Updating Apt, please wait..." - apt-get update - local result=$? - if (( $result != 0 )); then + G_AGUP + local exit_code=$? + if (( $exit_code != 0 )); then - whiptail --title "Apt Error:" --msgbox "Failed to update apt, exit code: $result\nPlease try another Apt mirror." --backtitle "$WHIP_BACKTITLE" 8 65 + whiptail --title "Apt Error:" --msgbox "Failed to update apt, exit code: $exit_code\nPlease try another Apt mirror." --backtitle "$WHIP_BACKTITLE" 8 65 fi @@ -5065,12 +5061,13 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ whiptail_menu_array+=('debian.pool.ntp.org' 'Debian Global') whiptail_menu_array+=('pool.ntp.org' 'Global') whiptail_menu_array+=('europe.pool.ntp.org' 'Europe') - whiptail_menu_array+=('north-america.pool.ntp.org' 'US North') - whiptail_menu_array+=('south-america.pool.ntp.org' 'US South') - whiptail_menu_array+=('oceania.pool.ntp.org' 'Oceania') + whiptail_menu_array+=('north-america.pool.ntp.org' 'North America') + whiptail_menu_array+=('south-america.pool.ntp.org' 'South America') + whiptail_menu_array+=('africa.pool.ntp.org' 'Africa') whiptail_menu_array+=('asia.pool.ntp.org' 'Asia') + whiptail_menu_array+=('oceania.pool.ntp.org' 'Oceania') - OPTION=$(whiptail --title "Choose NTPD Mirror" --menu "Please select a NTPD mirror, or choose custom for manual entry." --default-item "$ntpd_mirror_current" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 15 100 7 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) + OPTION=$(whiptail --title "Choose NTPD Mirror" --menu "Please select a NTPD mirror, or choose custom for manual entry.\n - Further information: \"http://www.pool.ntp.org/zone/@\"" --default-item "$ntpd_mirror_current" --cancel-button "$TEXT_MENU_BACK" --backtitle "$WHIP_BACKTITLE" 16 100 7 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) CHOICE=$? if (( $CHOICE == 0 )); then @@ -5092,13 +5089,8 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ esac - /DietPi/dietpi/func/dietpi-set_software ntpd-mirror $OPTION - - # Kill all existing, refresh now - killall -w /DietPi/dietpi/func/run_ntpd &> /dev/null - killall -w ntpd &> /dev/null - rm /etc/dietpi/.ntpd_exit_status &> /dev/null - /DietPi/dietpi/func/run_ntpd status + sed -i "/CONFIG_NTP_MIRROR=/c\CONFIG_NTP_MIRROR=$OPTION" /DietPi/dietpi.txt + /DietPi/dietpi/func/dietpi-set_software ntpd-mode $(grep -m1 '^CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/.*=//') #Return to this Menu TARGETMENUID=16 @@ -5230,11 +5222,11 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ #So we can call this in other menus (eg: submenu of this) Load_Proxy_Vars(){ - PROXY_ENABLED=$(cat /DietPi/dietpi.txt | grep -m1 '^proxy_enabled=' | sed 's/.*=//') - PROXY_ADDRESS=$(cat /DietPi/dietpi.txt | grep -m1 '^proxy_address=' | sed 's/.*=//') - PROXY_PORT=$(cat /DietPi/dietpi.txt | grep -m1 '^proxy_port=' | sed 's/.*=//') - PROXY_USERNAME=$(cat /DietPi/dietpi.txt | grep -m1 '^proxy_username=' | sed 's/.*=//') - PROXY_PASSWORD=$(cat /DietPi/dietpi.txt | grep -m1 '^proxy_password=' | sed 's/.*=//') + PROXY_ENABLED=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_ENABLED=' | sed 's/.*=//') + PROXY_ADDRESS=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_ADDRESS=' | sed 's/.*=//') + PROXY_PORT=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_PORT=' | sed 's/.*=//') + PROXY_USERNAME=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_USERNAME=' | sed 's/.*=//') + PROXY_PASSWORD=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PROXY_PASSWORD=' | sed 's/.*=//') } @@ -5323,11 +5315,11 @@ Custom : Write = $CUSTOM_WRITE | Read = $CUSTOM_READ\ Apply) # - Save settings to dietpi.txt - sed -i "/^proxy_enabled=/c\proxy_enabled=$PROXY_ENABLED" /DietPi/dietpi.txt - sed -i "/^proxy_address=/c\proxy_address=$PROXY_ADDRESS" /DietPi/dietpi.txt - sed -i "/^proxy_port=/c\proxy_port=$PROXY_PORT" /DietPi/dietpi.txt - sed -i "/^proxy_username=/c\proxy_username=$PROXY_USERNAME" /DietPi/dietpi.txt - sed -i "/^proxy_password=/c\proxy_password=$PROXY_PASSWORD" /DietPi/dietpi.txt + sed -i "/^CONFIG_PROXY_ENABLED=/c\CONFIG_PROXY_ENABLED=$PROXY_ENABLED" /DietPi/dietpi.txt + sed -i "/^CONFIG_PROXY_ADDRESS=/c\CONFIG_PROXY_ADDRESS=$PROXY_ADDRESS" /DietPi/dietpi.txt + sed -i "/^CONFIG_PROXY_PORT=/c\CONFIG_PROXY_PORT=$PROXY_PORT" /DietPi/dietpi.txt + sed -i "/^CONFIG_PROXY_USERNAME=/c\CONFIG_PROXY_USERNAME=$PROXY_USERNAME" /DietPi/dietpi.txt + sed -i "/^CONFIG_PROXY_PASSWORD=/c\CONFIG_PROXY_PASSWORD=$PROXY_PASSWORD" /DietPi/dietpi.txt # - Delete active export vars #unset {http,https,ftp}_proxy #Does not apply to system when running from a bash script. @@ -5380,7 +5372,7 @@ _EOF_ #///////////////////////////////////////////////////////////////////////////////////// # Main Loop #///////////////////////////////////////////////////////////////////////////////////// - if (( $DIETPI_INSTALL_STAGE >= 0 )); then + if (( $G_DIETPI_INSTALL_STAGE >= 0 )); then #Start DietPi-Config while (( $TARGETMENUID > -1 )); do diff --git a/dietpi/dietpi-cpu_set b/dietpi/dietpi-cpu_set index daac6da53b..e1f0d7af3b 100644 --- a/dietpi/dietpi-cpu_set +++ b/dietpi/dietpi-cpu_set @@ -14,33 +14,30 @@ # - Sets CPU governor user prefs | throttle up percent etc #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-CPU_set' + #Import DietPi-Globals --------------------------------------------------------------- #Exit path for VM - if (( $HW_MODEL == 20 )); then + if (( $G_HW_MODEL == 20 )); then echo -e "\nNotice: CPU Governors are not available for VM.\n" exit fi - CPU_CORES=$(nproc --all) - CPU_GOVERNOR=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_governor=' | sed 's/.*=//') - CPU_MAX_FREQ=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_max_frequency=' | sed 's/.*=//') - CPU_MIN_FREQ=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_min_frequency=' | sed 's/.*=//') + CPU_GOVERNOR=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_GOVERNOR=' | sed 's/.*=//') + CPU_MAX_FREQ=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_MAX_FREQ=' | sed 's/.*=//') + CPU_MIN_FREQ=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_MIN_FREQ=' | sed 's/.*=//') Check_GPU_Gov_Available(){ #Check if target Gov is available on system. if (( ! $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors | grep -ci -m1 "$CPU_GOVERNOR") )); then - /DietPi/dietpi/func/dietpi-notify 1 "CPU gov: $CPU_GOVERNOR, not supported by kernel" + G_DIETPI-NOTIFY 1 "CPU gov: $CPU_GOVERNOR, not supported by kernel" if (( $(cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors | grep -ci -m1 'ondemand') )); then @@ -56,10 +53,10 @@ fi - /DietPi/dietpi/func/dietpi-notify 2 "Switching to CPU gov: $CPU_GOVERNOR" + G_DIETPI-NOTIFY 2 "Switching to CPU gov: $CPU_GOVERNOR" # - Update dietpi.txt - sed -i "/^cpu_governor=/c\cpu_governor=$CPU_GOVERNOR" /DietPi/dietpi.txt + sed -i "/^CONFIG_CPU_GOVERNOR=/c\CONFIG_CPU_GOVERNOR=$CPU_GOVERNOR" /DietPi/dietpi.txt fi @@ -90,7 +87,7 @@ done - /DietPi/dietpi/func/dietpi-notify 2 "Setting CPU max freq: $CPU_MAX_FREQ MHz" + G_DIETPI-NOTIFY 2 "Setting CPU max freq: $CPU_MAX_FREQ MHz" fi @@ -107,11 +104,11 @@ done - /DietPi/dietpi/func/dietpi-notify 2 "Setting CPU min freq: $CPU_MIN_FREQ MHz" + G_DIETPI-NOTIFY 2 "Setting CPU min freq: $CPU_MIN_FREQ MHz" fi - local cpu_throttle_up_percent=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_usage_throttle_up' | sed 's/.*=//') + local cpu_throttle_up_percent=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_USAGE_THROTTLE_UP=' | sed 's/.*=//') #Set CPU governor interactive settings if [ "$input_gov_name" = interactive ]; then @@ -119,7 +116,7 @@ #Set hispeed_load, if available on system (eg: XU4 kernel lacks this feature) if [ -f /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load ]; then - /DietPi/dietpi/func/dietpi-notify 2 "Setting go_hispeed_load: $cpu_throttle_up_percent %" + G_DIETPI-NOTIFY 2 "Setting go_hispeed_load: $cpu_throttle_up_percent %" echo "$cpu_throttle_up_percent" > /sys/devices/system/cpu/cpufreq/interactive/go_hispeed_load fi @@ -127,12 +124,12 @@ #Set CPU governor ondemand settings elif [ "$input_gov_name" = ondemand ]; then - local cpu_ondemand_sampling_rate=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_ondemand_sampling_rate' | sed 's/.*=//') - local cpu_ondemand_sampling_down_factor=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_ondemand_sampling_down_factor' | sed 's/.*=//') + local cpu_ondemand_sampling_rate=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_ONDEMAND_SAMPLE_RATE=' | sed 's/.*=//') + local cpu_ondemand_sampling_down_factor=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_ONDEMAND_SAMPLE_DOWNFACTOR=' | sed 's/.*=//') - /DietPi/dietpi/func/dietpi-notify 2 "Setting up_threshold: $cpu_throttle_up_percent %" - /DietPi/dietpi/func/dietpi-notify 2 "Setting sampling_rate: $cpu_ondemand_sampling_rate microseconds" - /DietPi/dietpi/func/dietpi-notify 2 "Setting sampling_down_factor: $cpu_ondemand_sampling_down_factor" + G_DIETPI-NOTIFY 2 "Setting up_threshold: $cpu_throttle_up_percent %" + G_DIETPI-NOTIFY 2 "Setting sampling_rate: $cpu_ondemand_sampling_rate microseconds" + G_DIETPI-NOTIFY 2 "Setting sampling_down_factor: $cpu_ondemand_sampling_down_factor" #Check for different possible locations # All @@ -155,20 +152,24 @@ fi #Set CPU governor conservative settings - elif [ "$input_gov_name" = conservative ]; then + elif [ "$input_gov_name" = 'conservative' ]; then - cpu_throttle_up_percent=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_usage_throttle_up' | sed 's/.*=//') + cpu_throttle_up_percent=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_USAGE_THROTTLE_UP=' | sed 's/.*=//') #XU3/4 different path (must apply to each core) - if (( $HW_MODEL == 11 )); then + if (( $G_HW_MODEL == 11 )); then for ((i=$input_core_start; i<$input_core_end; i++)) do + echo "$cpu_throttle_up_percent" > /sys/devices/system/cpu/cpu"$i"/cpufreq/conservative/up_threshold + done else + echo "$cpu_throttle_up_percent" > /sys/devices/system/cpu/cpufreq/conservative/up_threshold + fi fi @@ -179,14 +180,14 @@ # Main Loop #///////////////////////////////////////////////////////////////////////////////////// #----------------------------------------------------------------------------------- - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Cpu_Set "Applying CPU gov" + G_DIETPI-NOTIFY 3 DietPi-Cpu_Set "Applying CPU gov" #----------------------------------------------------------------------------------- Check_GPU_Gov_Available #Apply CPU0 gov to all cores (if required) - Apply_CPU_Gov "$CPU_GOVERNOR" 0 $CPU_CORES + Apply_CPU_Gov "$CPU_GOVERNOR" 0 $G_HW_CPU_CORES - /DietPi/dietpi/func/dietpi-notify 0 "CPU gov applied: $CPU_GOVERNOR\n" + G_DIETPI-NOTIFY 0 "CPU gov applied: $CPU_GOVERNOR\n" #----------------------------------------------------------------------------------- exit diff --git a/dietpi/dietpi-cpuinfo b/dietpi/dietpi-cpuinfo index 93764bd388..48f7c79c4e 100644 --- a/dietpi/dietpi-cpuinfo +++ b/dietpi/dietpi-cpuinfo @@ -10,40 +10,35 @@ # # Info: # - Prints CPU information - + # # Usage: # - /DietPi/dietpi/dietpi-cpuinfo Obtain stats and print - # - /DietPi/dietpi/dietpi-cpuinfo 1 Returns current CPU temp # - /DietPi/dietpi/dietpi-cpuinfo 2 Generates file of available, ordered scaling freq's "$FP_CPU_SCALINGAVAILABLE_FREQ" #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 + #Grab Input + INPUT=0 + if [[ $1 =~ ^-?[0-9]+$ ]]; then - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" + INPUT=$1 - #Exit path for VM - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) - HW_CPUID=$(sed -n 9p /DietPi/dietpi/.hw_model) + fi + + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-CPU_info' + #Import DietPi-Globals --------------------------------------------------------------- - if (( $HW_MODEL == 20 )); then + #Exit path for VM + if (( $G_HW_MODEL == 20 )); then echo -e "\nNotice: CPU information is not available for VM.\n" exit fi - #Grab Input - INPUT=0 - if [[ $1 =~ ^-?[0-9]+$ ]]; then - - INPUT=$1 - - fi - #Funcs - CPU_USAGE=0 CPU_GOV_CURRENT='Unknown' aCPU_CURRENT_FREQ=0 @@ -104,112 +99,46 @@ CPU_TEMP_CURRENT='Unknown' CPU_TEMP_PRINT='Unknown' - #Array to store possible locations for temp read. - aFP_TEMPERATURE=( - - #'/sys/class/thermal/thermal_zone1/temp' #sparky/Asus, will break other SBC temp readouts as most have 2 zones, needs a special case - '/sys/class/thermal/thermal_zone0/temp' - '/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input' - '/sys/class/hwmon/hwmon0/device/temp_label' - - ) Obtain_Cpu_Temp(){ - for ((i=0; i<${#aFP_TEMPERATURE[@]}; i++)) - do - - if [ -f "${aFP_TEMPERATURE[$i]}" ]; then - - # Sparky/asus, special case: - if (( $HW_MODEL == 70 || $HW_MODEL == 100 || $HW_MODEL == 110 )); then - - CPU_TEMP_CURRENT=$(cat /sys/class/thermal/thermal_zone1/temp) - - else - - CPU_TEMP_CURRENT=$(cat ${aFP_TEMPERATURE[$i]}) + CPU_TEMP_CURRENT=$(G_OBTAIN_CPU_TEMP) - fi + local cpu_temp_current_f='Unknown' + if [[ $CPU_TEMP_CURRENT =~ ^-?[0-9]+$ ]]; then - # - Boards that provide 2 digit output - # Pine - # NanoPi M2 - # NanoPi M3 - # H3 3.x - # H2+ 3.x - if (( ( $HW_MODEL >= 40 && $HW_MODEL <= 42 ) || - $HW_MODEL == 61 || - $HW_MODEL == 62 || - ( $HW_CPUID == 1 && $(uname -r | grep -ci -m1 '^3.') ) || - ( $HW_MODEL == 32 && $(uname -r | grep -ci -m1 '^3.') ) )); then + cpu_temp_current_f=$(( ( $CPU_TEMP_CURRENT * 9 / 5 ) + 32 )) + if (( $CPU_TEMP_CURRENT >= 70 )); then - echo -e "Do nothing" &> /dev/null + CPU_TEMP_PRINT="\e[91mWarning: $CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f | Reducing the life of your device.\e[0m" - else + elif (( $CPU_TEMP_CURRENT >= 60 )); then - CPU_TEMP_CURRENT=$( echo -e "$CPU_TEMP_CURRENT" | awk '{print $1/1000}' | xargs printf "%0.0f" ) + CPU_TEMP_PRINT="\e[38;5;202m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f\e[90m | Running hot, not recommended.\e[0m" - fi + elif (( $CPU_TEMP_CURRENT >= 50 )); then - local cpu_temp_current_f='Unknown' - if [[ $CPU_TEMP_CURRENT =~ ^-?[0-9]+$ ]]; then + CPU_TEMP_PRINT="\e[93m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f\e[0m \e[90m | Running warm, but safe.\e[0m" - cpu_temp_current_f=$(( ( $CPU_TEMP_CURRENT * 9 / 5 ) + 32 )) - if (( $CPU_TEMP_CURRENT >= 70 )); then + elif (( $CPU_TEMP_CURRENT >= 40 )); then - CPU_TEMP_PRINT="\e[91mWarning: $CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f | Reducing the life of your device.\e[0m" + CPU_TEMP_PRINT="\e[92m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f\e[0m\e[90m | Optimal temperature.\e[0m" - elif (( $CPU_TEMP_CURRENT >= 60 )); then + elif (( $CPU_TEMP_CURRENT >= 30 )); then - CPU_TEMP_PRINT="\e[38;5;202m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f\e[90m | Running hot, not recommended.\e[0m" + CPU_TEMP_PRINT="\e[96m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f\e[0m\e[90m | Cool runnings.\e[0m" - elif (( $CPU_TEMP_CURRENT >= 50 )); then + else - CPU_TEMP_PRINT="\e[93m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f\e[0m \e[90m | Running warm, but safe.\e[0m" - - elif (( $CPU_TEMP_CURRENT >= 40 )); then - - CPU_TEMP_PRINT="\e[92m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f\e[0m\e[90m | Optimal temperature.\e[0m" - - elif (( $CPU_TEMP_CURRENT >= 30 )); then - - CPU_TEMP_PRINT="\e[96m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f\e[0m\e[90m | Cool runnings.\e[0m" - - else - - CPU_TEMP_PRINT="\e[96m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f \e[0m \e[90m| Who put me in the freezer!\e[0m" - - fi - - else - - CPU_TEMP_PRINT="\e[91mKERNELERR: $CPU_TEMP_CURRENT'c\e[0m" - - fi - - break + CPU_TEMP_PRINT="\e[96m$CPU_TEMP_CURRENT'c : $cpu_temp_current_f'f \e[0m \e[90m| Who put me in the freezer!\e[0m" fi - done - - } - - Obtain_Cpu_Usage(){ - - # PS (inaccurate) - local fp_temp='/tmp/.cpu_usage_cpuinfo' - ps -axo %cpu | sed '1d' | sed 's/ //' > "$fp_temp" - while read line - do - - CPU_USAGE=$( echo "scale=1;$CPU_USAGE + $line" | bc -l ) + else - done < "$fp_temp" + CPU_TEMP_PRINT="\e[91mKERNELERR: $CPU_TEMP_CURRENT'c\e[0m" - #ps returns usage of each core, so we devide the total by #n cores - CPU_USAGE=$(echo "scale=1;$CPU_USAGE / $(nproc --all)" | bc -l ) + fi } @@ -231,9 +160,6 @@ #Processor Type echo -e " Architecture \e[90m|\e[0m $(uname -m)" - #Current usage - # echo -e " Usage \e[90m|\e[0m $CPU_USAGE" - #Current Temp echo -e " Temp \e[90m|\e[0m $CPU_TEMP_PRINT" @@ -243,7 +169,7 @@ if [ "$CPU_GOV_CURRENT" = "ondemand" ] || [ "$CPU_GOV_CURRENT" = "conservative" ]; then - echo -e " Throttle up \e[90m|\e[0m $(cat /DietPi/dietpi.txt | grep -m1 '^cpu_usage_throttle_up' | sed 's/.*=//')% CPU usage" + echo -e " Throttle up \e[90m|\e[0m $(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CPU_USAGE_THROTTLE_UP=' | sed 's/.*=//')% CPU usage" fi @@ -260,7 +186,7 @@ echo -e "" #CPU scaling may bump up with script - /DietPi/dietpi/func/dietpi-notify 2 'CPU current frequency, may be affected by this script, due to the processing required to run it.\n' + G_DIETPI-NOTIFY 2 'CPU current frequency, may be affected by this script, due to the processing required to run it.\n' } @@ -270,12 +196,7 @@ #----------------------------------------------------------------------------------- #Return mode - if (( $INPUT == 3 )); then - - Obtain_Cpu_Usage - echo "$CPU_USAGE" - - elif (( $INPUT == 2 )); then + if (( $INPUT == 2 )); then Obtain_Cpu_Freq @@ -296,11 +217,6 @@ fi - elif (( $INPUT == 1 )); then - - Obtain_Cpu_Temp - echo "$CPU_TEMP_CURRENT" - #Print all stats else @@ -319,7 +235,7 @@ unset aCPU_MIN_FREQ unset aCPU_MAX_FREQ unset aCPU_SCALINGAVAILABLE_FREQ - unset aFP_TEMPERATURE + unset afp_temperature #----------------------------------------------------------------------------------- exit #----------------------------------------------------------------------------------- diff --git a/dietpi/dietpi-cron b/dietpi/dietpi-cron index ff8e4a2ebf..fab9678cc0 100644 --- a/dietpi/dietpi-cron +++ b/dietpi/dietpi-cron @@ -15,21 +15,11 @@ # - /DietPi/dietpi/dietpi-cron #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Exit path for non-root logins. - if (( $UID != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit - - fi - - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Cron' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// #Globals diff --git a/dietpi/dietpi-drive_manager b/dietpi/dietpi-drive_manager index 220ad63301..352a35fa66 100644 --- a/dietpi/dietpi-drive_manager +++ b/dietpi/dietpi-drive_manager @@ -17,32 +17,33 @@ # 1 = Selectadrive! Provides a list of available drive mount locations, with value on selection saved to: /tmp/dietpi-drive_manager_selmnt # 2 = Returns exit 1 if low on freespace # 3 = Returns exit 1 if rootfs is currently RO (NB: simple check via mount cmd, does not init full drive manager vars, for quicker loading/processing) + # 4 = Generates a new /etc/fstab based on current mounted drives (for use in PREP_SYSTEM_FOR_DIETPI.sh) # # NB: This script does not support quoted/string UUID entries in /etc/fstab. #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" + #Grab Input (valid interger) + INPUT=0 + if [[ $1 =~ ^-?[0-9]+$ ]]; then + INPUT=$1 + fi - #Exit path for non-root logins. - if (( $UID != 0 )); then + #Import DietPi-Globals --------------------------------------------------------------- + if [ -f /DietPi/dietpi/func/dietpi-globals ]; then - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Drive_Manager' - fi + # - Support for loading during PREP_SYSTEM + elif [ -f "$HOME"/dietpi-globals ]; then - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) - HW_NAME=$(sed -n 2p /DietPi/dietpi/.hw_model) + . "$HOME"/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Drive_Manager' - #Grab Input (valid interger) - INPUT=0 - if [[ $1 =~ ^-?[0-9]+$ ]]; then - INPUT=$1 fi + #Import DietPi-Globals --------------------------------------------------------------- EXIT_CODE=0 @@ -62,7 +63,7 @@ #Drives MAX_DRIVES=0 FORMAT_GPT=1 # default GPT: https://github.com/Fourdee/DietPi/issues/531. 0=MBR - FORMAT_FILESYSTEM_TYPE=0 #0=ext4 1=ntfs 2=fat32 3=hfs+ 4=btrfs 5=f2fs + FORMAT_FILESYSTEM_TYPE=0 #0=ext4 1=ntfs 2=fat32 3=hfs+ 4=btrfs 5=f2fs 6=exfat FORMAT_RECREATE_PARTITION_TABLE=1 #0=for rootfs transfer FORMAT_COMPLETED=0 FORMAT_PREVIOUS_MOUNT_SOURCE=0 #Used to obtain previous mount source fp, before a format, for rootfs transfer @@ -124,7 +125,7 @@ init=0 - /DietPi/dietpi/func/dietpi-notify 2 "Detecting drives, please wait..." + G_DIETPI-NOTIFY 2 "Detecting drives, please wait..." #Copy FSTAB to ram, faster exe cp /etc/fstab "$FP_TEMP_FSTAB" @@ -166,7 +167,7 @@ aDRIVE_MOUNT_TARGET[$i]=$drive_mount_target_dev aDRIVE_ISAVAILABLE[$i]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Detected /dev mount: ${aDRIVE_MOUNT_SOURCE[$i]} > ${aDRIVE_MOUNT_TARGET[$i]}" + G_DIETPI-NOTIFY 2 "Detected /dev mount: ${aDRIVE_MOUNT_SOURCE[$i]} > ${aDRIVE_MOUNT_TARGET[$i]}" # - check UUID elif [ -n "$drive_mount_target_uuid" ]; then @@ -176,7 +177,7 @@ aDRIVE_ISAVAILABLE[$i]=1 aDRIVE_ISUUIDMOUNT[$i]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Detected UUID mount: ${aDRIVE_MOUNT_SOURCE[$i]} > ${aDRIVE_MOUNT_TARGET[$i]}" + G_DIETPI-NOTIFY 2 "Detected UUID mount: ${aDRIVE_MOUNT_SOURCE[$i]} > ${aDRIVE_MOUNT_TARGET[$i]}" # - check PARTUUID elif [ -n "$drive_mount_target_partuuid" ]; then @@ -186,23 +187,49 @@ aDRIVE_ISAVAILABLE[$i]=1 aDRIVE_ISUUIDMOUNT[$i]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Detected PARTUUID mount: ${aDRIVE_MOUNT_SOURCE[$i]} > ${aDRIVE_MOUNT_TARGET[$i]}" + G_DIETPI-NOTIFY 2 "Detected PARTUUID mount: ${aDRIVE_MOUNT_SOURCE[$i]} > ${aDRIVE_MOUNT_TARGET[$i]}" - # - Drive mount does not exist + # - Active drive mount does not exist in fstab, create one elif [ -n "${aDRIVE_UUID[$i]}" ]; then #Ignore master partition tables / drives with no UUID - # create one - local fp_target="/mnt/${aDRIVE_UUID[$i]}" + aDRIVE_MOUNT_TARGET[$i]="/mnt/${aDRIVE_UUID[$i]}" + + G_DIETPI-NOTIFY 2 "Creating UUID fstab entry: ${aDRIVE_MOUNT_SOURCE[$i]}" + + # Always check for rootFS device and set target manually + # - EG: RPi, rootFS source is reported as /dev/root in df scrapes. + if [ "${aDRIVE_MOUNT_SOURCE[$i]}" = "$(findmnt / -o source -n)" ]; then + + aDRIVE_MOUNT_TARGET[$i]='/' + + G_DIETPI-NOTIFY 2 " - Drive is currently mounted, using existing mount location: ${aDRIVE_MOUNT_TARGET[$i]}" - /DietPi/dietpi/func/dietpi-notify 2 "Creating UUID fstab entry: ${aDRIVE_MOUNT_SOURCE[$i]}" + # Check if the drive is already mounted (but not set in fstab) and use existing mount target + elif (( $(df -P | grep -ci -m1 "${aDRIVE_MOUNT_SOURCE[$i]}[[:space:]]") )); then + + G_DIETPI-NOTIFY 2 " - Drive is currently mounted, using existing mount location: ${aDRIVE_MOUNT_TARGET[$i]}" + + aDRIVE_MOUNT_TARGET[$i]=$(df -P | grep -m1 "${aDRIVE_MOUNT_SOURCE[$i]}[[:space:]]" | awk '{print $NF}') + + fi # remove any previous/disabled entries for drive sed -i "\@^${aDRIVE_MOUNT_SOURCE[$i]}[[:space:]]@d" "$FP_TEMP_FSTAB" sed -i "\@^UUID=${aDRIVE_UUID[$i]}[[:space:]]@d" "$FP_TEMP_FSTAB" - echo -e "UUID=${aDRIVE_UUID[$i]} $fp_target auto defaults,noatime,nofail,x-systemd.automount 0 0" >> "$FP_TEMP_FSTAB" + local mount_options='defaults,noatime,nofail' - aDRIVE_MOUNT_TARGET[$i]="$fp_target" + # Disable x-systemd.automount for + # RootFS, breaks FS_partition + # Boot, breaks dietpi-ramdisk on ASUS TB + if [ "${aDRIVE_MOUNT_TARGET[$i]}" != '/' ] && + [ "${aDRIVE_MOUNT_TARGET[$i]}" != '/boot' ]; then + + mount_options+=',x-systemd.automount' + + fi + + echo -e "UUID=${aDRIVE_UUID[$i]} ${aDRIVE_MOUNT_TARGET[$i]} auto $mount_options 0 0" >> "$FP_TEMP_FSTAB" aDRIVE_ISAVAILABLE[$i]=1 aDRIVE_ISUUIDMOUNT[$i]=1 @@ -213,7 +240,7 @@ if (( ${aDRIVE_ISAVAILABLE[$i]} )) && [ ! -d "${aDRIVE_MOUNT_TARGET[$i]}" ]; then - /DietPi/dietpi/func/dietpi-notify 2 "Creating mount folder for ${aDRIVE_MOUNT_TARGET[$i]}" + G_DIETPI-NOTIFY 2 "Creating mount folder for ${aDRIVE_MOUNT_TARGET[$i]}" mkdir -p "${aDRIVE_MOUNT_TARGET[$i]}" fi @@ -229,7 +256,7 @@ #--------------------------------------------------------------- - /DietPi/dietpi/func/dietpi-notify 2 "Processing drive information, please wait..." + G_DIETPI-NOTIFY 2 "Processing drive information, please wait..." #ROOTFS location FP_ROOTFS_SOURCE=$(df -P | grep -m1 '[[:space:]]/$' | awk '{print $1}') @@ -320,13 +347,13 @@ INDEX_DRIVE_BEING_EDITED=$i - /DietPi/dietpi/func/dietpi-notify 2 "RootFS is currently set to R/O. $PROGRAM_NAME requires R/W access." + G_DIETPI-NOTIFY 2 "RootFS is currently set to R/O. $PROGRAM_NAME requires R/W access." whiptail --title "RootFS is R/O" --yesno "RootFS is currently set to 'Read Only'. DietPi-Drive_Manager requires 'Read Write' access to function.\n\nWould you like to renable 'Read Write' access on RootFS?" --backtitle "$PROGRAM_NAME" --defaultno 14 75 if (( $? == 0 )); then Toggle_WriteMode - /DietPi/dietpi/func/dietpi-notify 0 "RootFS R/W now enabled." + G_DIETPI-NOTIFY 0 "RootFS R/W now enabled." # reinit init=1 @@ -335,8 +362,8 @@ /DietPi/dietpi/dietpi-services start - /DietPi/dietpi/func/dietpi-notify 0 "RootFS currently set to R/O." - /DietPi/dietpi/func/dietpi-notify 2 "Please run 'dietpi-drive_manager' again, if you want to re-enable RootFS R/W." + 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." Destroy exit @@ -349,8 +376,8 @@ fi - #User data location - FP_USERDATA_CURRENT=$(/DietPi/dietpi/func/dietpi-set_userdata return_source) + #Obtain actual user data location on disk (follows symlinks) + FP_USERDATA_CURRENT=$(readlink -f $G_FP_DIETPI_USERDATA) done @@ -392,7 +419,7 @@ fi - /DietPi/dietpi/func/dietpi-notify 2 "Partition table target: $parition_table_type" + G_DIETPI-NOTIFY 2 "Partition table target: $parition_table_type" parted -s "$drivepath_no_partitions" mklabel "$parition_table_type" parted -a optimal "$drivepath_no_partitions" mkpart primary 0% 100% @@ -447,6 +474,11 @@ mkfs.f2fs ${aDRIVE_MOUNT_SOURCE[$INDEX_DRIVE_BEING_EDITED]} + # - Format exFAT + elif (( $FORMAT_FILESYSTEM_TYPE == 6 )); then + + mkfs.exfat ${aDRIVE_MOUNT_SOURCE[$INDEX_DRIVE_BEING_EDITED]} + fi #Remove previous fstab entry and mount location @@ -482,22 +514,22 @@ sed -i "\@${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]}[[:space:]]@d" /etc/fstab # Add new rootfs entry - sed -i "\@[[:space:]]/[[:space:]]@c UUID=${aDRIVE_UUID[$INDEX_DRIVE_BEING_EDITED]} / auto defaults,noatime,discard 0 1" /etc/fstab + sed -i "\@[[:space:]]/[[:space:]]@c UUID=${aDRIVE_UUID[$INDEX_DRIVE_BEING_EDITED]} / auto defaults,noatime 0 1" /etc/fstab # - install rsync if (( ! $(dpkg --get-selections | grep -ci -m1 '^rsync[[[:space:]]') )); then - /DietPi/dietpi/func/dietpi-notify 2 "Installing Rsync, please wait...\n" + G_DIETPI-NOTIFY 2 "Installing Rsync, please wait...\n" sleep 1 - apt-get install rsync -y + G_AGI rsync fi rsync -paxv --exclude '/lost+found' / "${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]}"/ if (( $? != 0 )); then - /DietPi/dietpi/func/dietpi-notify 1 'Rsync has failed, RootFS transfer has been aborted.' + G_DIETPI-NOTIFY 1 'Rsync has failed, RootFS transfer has been aborted.' # revert FSTAB changes cp /etc/fstab.bak /etc/fstab @@ -507,7 +539,7 @@ fi #RPi | cmdline.txt - if (( $HW_MODEL < 10 )); then + 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=') @@ -525,7 +557,7 @@ sed -i "s#$rootfstype_current#rootfstype=${aDRIVE_FSTYPE[$INDEX_DRIVE_BEING_EDITED]}#g" /boot/cmdline.txt #C1/C2/XU4 | /DietPi/boot.ini - elif (( $HW_MODEL == 10 || $HW_MODEL == 11 || $HW_MODEL == 12 )); then + 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/\"//') @@ -546,7 +578,7 @@ # global min limit (MB) local free_space_limit=500 - /DietPi/dietpi/func/dietpi-notify 2 'Checking available free space on RootFS, please wait...' + G_DIETPI-NOTIFY 2 'Checking available free space on RootFS, please wait...' #Find rootfs for ((i=0; i<$MAX_DRIVES; i++)) @@ -565,15 +597,15 @@ whiptail --title "Insufficient free space" --msgbox "$message" --backtitle "$PROGRAM_NAME" 14 70 - /DietPi/dietpi/func/dietpi-notify 1 "Insufficient free space on RootFS. $free_space_current MB available, $free_space_limit MB required" - /DietPi/dietpi/func/dietpi-notify 1 'Aborting' + G_DIETPI-NOTIFY 1 "Insufficient free space on RootFS. $free_space_current MB available, $free_space_limit MB required" + G_DIETPI-NOTIFY 1 'Aborting' # export EXIT_CODE=1 else - /DietPi/dietpi/func/dietpi-notify 0 "$free_space_current MB available, $free_space_limit MB required" + G_DIETPI-NOTIFY 0 "$free_space_current MB available, $free_space_limit MB required" fi @@ -593,23 +625,23 @@ # echo 0 > "$fp_test_file" # if (( $? != 0 )); then - # /DietPi/dietpi/func/dietpi-notify 1 "RootFS is currently set to R/O." + # G_DIETPI-NOTIFY 1 "RootFS is currently set to R/O." # EXIT_CODE=1 # fi # rm "$fp_test_file" &> /dev/null - /DietPi/dietpi/func/dietpi-notify 2 "Checking RootFS R/W access. Please wait..." + G_DIETPI-NOTIFY 2 "Checking RootFS R/W access. Please wait..." if (( $(mount | grep -m1 '[[:space:]]/[[:space:]]' | grep -ci -m1 '(ro,') )); then - /DietPi/dietpi/func/dietpi-notify 1 "RootFS is currently set to R/O." - /DietPi/dietpi/func/dietpi-notify 2 "DietPi requires RootFS R/W access. Please run 'dietpi-drive_manager' to re-enable." + G_DIETPI-NOTIFY 1 "RootFS is currently set to R/O." + G_DIETPI-NOTIFY 2 "DietPi requires RootFS R/W access. Please run 'dietpi-drive_manager' to re-enable.\n" EXIT_CODE=1 else - /DietPi/dietpi/func/dietpi-notify 0 "RootFS R/W access." + G_DIETPI-NOTIFY 0 "RootFS R/W access.\n" fi @@ -715,7 +747,7 @@ # - User data local userdata_location_text="RootFS ($FP_USERDATA_CURRENT)" - if [ "$FP_USERDATA_CURRENT" != "/mnt/dietpi_userdata" ]; then + if [ "$FP_USERDATA_CURRENT" != "$G_FP_DIETPI_USERDATA" ]; then userdata_location_text="USB ($FP_USERDATA_CURRENT)" @@ -825,7 +857,7 @@ fi if ( [ "${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]}" != "/" ] && [[ $FP_USERDATA_CURRENT == "${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]}"* ]] ) || #off rootfs - ( [ "${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]}" = "/" ] && [ "$FP_USERDATA_CURRENT" = "/mnt/dietpi_userdata" ] ); then #on rootfs + ( [ "${aDRIVE_MOUNT_TARGET[$INDEX_DRIVE_BEING_EDITED]}" = "/" ] && [ "$FP_USERDATA_CURRENT" = "$G_FP_DIETPI_USERDATA" ] ); then #on rootfs whiptail_menu_array+=("User data" ": Your user data is currently located on this drive") partition_contains_userdata=1 @@ -879,7 +911,7 @@ #Transfer RootFS if [[ ${aDRIVE_MOUNT_SOURCE[$INDEX_DRIVE_BEING_EDITED]} != $FP_ROOTFS_SOURCE ]] && - (( $HW_MODEL < 10 || $HW_MODEL == 10 || $HW_MODEL == 11 || $HW_MODEL == 12 )); then + (( $G_HW_MODEL < 10 || $G_HW_MODEL == 10 || $G_HW_MODEL == 11 || $G_HW_MODEL == 12 )); then whiptail_menu_array+=("Transfer RootFS" ": Transfer RootFS to this drive") @@ -1088,6 +1120,10 @@ format_type_text='F2FS' + elif (( $FORMAT_FILESYSTEM_TYPE == 6 )); then + + format_type_text='EXFAT' + fi local whiptail_menu_array=() @@ -1128,6 +1164,7 @@ whiptail_menu_array+=("3" ": HFS+ | Mac OS X (Intel Mac default file system)") whiptail_menu_array+=("4" ": BTRFS | Linux (Modern filesystem)") whiptail_menu_array+=("5" ": F2FS | Linux (Flash filesystem)") + whiptail_menu_array+=("6" ": exFAT | Windows (Flash filesystem)") WHIP_TITLE='Filesystem Type?' OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Please select a filesystem type for this format:\n\nEXT4:\nHighly recommended if you plan to use this drive solely on this system (dedicated drive).\n\nNTFS:\nRecommended if you plan to use this drive on a Windows system. High CPU usage during transfers.\n\nFull list of different filesystem types:\nhttp://dietpi.com/phpbb/viewtopic.php?f=8&t=673&p=2898#p2898" --cancel-button "Back" --default-item "$FORMAT_FILESYSTEM_TYPE" --backtitle "$PROGRAM_NAME" 24 70 5 "${whiptail_menu_array[@]}" 3>&1 1>&2 2>&3) @@ -1141,22 +1178,29 @@ if (( $OPTION == 3 && ! $(dpkg --get-selections | grep -ci -m1 '^hfsutils') )); then - /DietPi/dietpi/func/dietpi-notify 2 "Installing additional packages for HFS+ support, please wait..." - apt-get install -y hfsplus hfsprogs hfsutils + G_DIETPI-NOTIFY 2 "Installing additional packages for HFS+ support, please wait..." + G_AGI hfsplus hfsprogs hfsutils # - btrfs install packages elif (( $OPTION == 4 && ! $(dpkg --get-selections | grep -ci -m1 '^btrfs-tools') )); then - /DietPi/dietpi/func/dietpi-notify 2 "Installing additional packages for BTRFS support, please wait..." - apt-get install -y btrfs-tools + G_DIETPI-NOTIFY 2 "Installing additional packages for BTRFS support, please wait..." + G_AGI btrfs-tools # - f2fs install packages elif (( $OPTION == 5 && ! $(dpkg --get-selections | grep -ci -m1 '^f2fs-tools') )); then - /DietPi/dietpi/func/dietpi-notify 2 "Installing additional packages for F2FS support, please wait..." - apt-get install -y f2fs-tools + G_DIETPI-NOTIFY 2 "Installing additional packages for F2FS support, please wait..." + G_AGI f2fs-tools + + # - exfat install packages + elif (( $OPTION == 6 && + ! $(dpkg --get-selections | grep -ci -m1 '^exfat-utils') )); then + + G_DIETPI-NOTIFY 2 "Installing additional packages for exFAT support, please wait..." + G_AGI exfat-utils exfat-fuse fi @@ -1223,7 +1267,7 @@ local drive_manager_selection="$OPTION" - /DietPi/dietpi/func/dietpi-notify 0 "Drive mount selected: $drive_manager_selection" + G_DIETPI-NOTIFY 0 "Drive mount selected: $drive_manager_selection" echo -e "$drive_manager_selection" > "$FP_DRIVE_MANAGER_SELECTION" fi @@ -1266,8 +1310,32 @@ fi #----------------------------------------------------------------------------------- + #Generate /etc/fstab based on current drive mounts + if (( $INPUT == 4 )); then + + cat << _EOF_ > /etc/fstab +#Samba Client------------------------------------------------------ +#/mnt/samba . Please use dietpi-config and the Networking Options: NAS menu to setup this mount + +#FTP Client Mount-------------------------------------------------- +#/mnt/ftp_client . Please use dietpi-config and the Networking Options: NAS menu to setup this mount + +#NFS Client Mount-------------------------------------------------- +#/mnt/nfs_client . Please use dietpi-config and the Networking Options: NAS menu to setup this mount + +#TMPFS / MISC ------------------------------------------------------ +proc /proc proc defaults 0 0 +tmpfs /tmp tmpfs defaults,noatime,nodev,nosuid,mode=1777 0 0 +tmpfs /var/log tmpfs defaults,size=20m,noatime,nodev,nosuid,mode=1777 0 0 +tmpfs /DietPi tmpfs defaults,size=10m,noatime,nodev,nosuid,mode=1777 0 0 + +#Internal Drives--------------------------------------------------- +_EOF_ + + Init_Drives_and_Refresh + #Return 1 if RootFS is RO - if (( $INPUT == 3 )); then + elif (( $INPUT == 3 )); then RootFS_RW_Check @@ -1284,9 +1352,9 @@ Menu_Select_Mount_Location #Prevent VM image from running core script - elif (( $HW_MODEL == 20 )); then + elif (( $G_HW_MODEL == 20 )); then - /DietPi/dietpi/func/dietpi-notify 1 "$PROGRAM_NAME is not currently supported on VM images" + G_DIETPI-NOTIFY 1 "$PROGRAM_NAME is not currently supported on VM images" #Drive Manager else diff --git a/dietpi/dietpi-funtime b/dietpi/dietpi-funtime deleted file mode 100644 index 62c464c989..0000000000 --- a/dietpi/dietpi-funtime +++ /dev/null @@ -1,199 +0,0 @@ -#!/bin/bash -{ - #//////////////////////////////////// - # DietPi funtime Script - # - #//////////////////////////////////// - # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com - # - #//////////////////////////////////// - # - # Info: - # - Does absolutetly nothing useful, except: - # - LOOKS COOL! - # - # Usage: - # - Called from bordum, or, /DietPi/dietpi/dietpi-funtime iMODE - #//////////////////////////////////// - - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - INPUT=0 - if [[ $1 =~ ^-?[0-9]+$ ]]; then - INPUT=$1 - fi - - #///////////////////////////////////////////////////////////////////////////////////// - #Funtime_0 processing - #///////////////////////////////////////////////////////////////////////////////////// - - Funtime_0(){ - - local MAX_COUNT=28 - ((MAX_COUNT--)) - - #local count=$MAX_COUNT - #local mode=1 - #local MAX_PASSES=3 - local count=0 - local mode=0 - local MAX_PASSES=2 - - local passes=0 - - local marker=( - - '# processing | D i e t P i #' - 'D# processing | D i e t P i #g' - 'D # processing | D i e t P i #ng' - 'D i# processing | D i e t P i #ing' - 'D i # processing | D i e t P i #sing' - 'D i e# processing | D i e t P i #ssing' - 'D i e # processing | D i e t P i #essing' - 'D i e t# processing | D i e t P i #cessing' - 'D i e t # processing | D i e t P i #ocessing' - 'D i e t # processing | D i e t P i #rocessing' - 'D i e t P# processing | D i e t P i #processing' - 'D i e t P # processing | D i e t P i # processing' - 'D i e t P i# processing | D i e t P i # processing' - 'D i e t P i # processing | D i e t P i# processing' - 'D i e t P i # processing | D i e t P # processing' - 'D i e t P i #processing | D i e t P# processing' - 'D i e t P i #rocessing | D i e t # processing' - 'D i e t P i #ocessing | D i e t # processing' - 'D i e t P i #cessing | D i e t# processing' - 'D i e t P i #essing | D i e # processing' - 'D i e t P i #ssing | D i e# processing' - 'D i e t P i #sing | D i # processing' - 'D i e t P i #ing | D i# processing' - 'D i e t P i #ng | D # processing' - 'D i e t P i #g | D# processing' - 'D i e t P i # | # processing' - 'D i e t P i #|# processing' - 'D i e t P i # processing' - - ) - - while (( $passes < $MAX_PASSES )) - do - if (( $mode == 0 )); then - ((count++)) - if (( $count >= $MAX_COUNT )); then - count=$MAX_COUNT - mode=1 - ((passes++)) - fi - elif (( $mode == 1 )); then - ((count--)) - if (( $count <= 0 )); then - count=0 - mode=0 - ((passes++)) - fi - fi - - #color=$((228 + $count)) - color=154 - - #echo -ne "${marker[$count]}\r" - - echo -ne "\e[38;5;${color}m ${marker[$count]}\r" - #echo -e "\e[38;5;${color}m ${marker[$count]}\r" - - #echo -e "\e[38;5;154m ${marker[$count]}\r" - - #fSleep="0.0$count" - local fSleep=0.03 - sleep "$fSleep" - - done - - unset marker - - } - - Funtime_1(){ - local count=0 - local mode=0 - - local passes=0 - local MAX_PASSES=4 - - local MAX_COUNT=1 - ((MAX_COUNT--)) - local -a marker=( - ' | ' - ' | ' - ' | ' - ' | ' - ' | ' - ' | ' - ' | ' - ' | ' - - ) - - while (( $passes < $MAX_PASSES )) - do - if (( $mode == 0 )); then - ((count++)) - if (( $count >= $MAX_COUNT )); then - count=$MAX_COUNT - mode=1 - ((passes++)) - fi - elif (( $mode == 1 )); then - ((count--)) - if (( $count <= 0 )); then - count=0 - mode=0 - ((passes++)) - fi - fi - - #color=$((228 + $count)) - color=93 - - #echo -ne "${marker[$count]}\r" - - echo -ne "\e[38;5;${color}m ${marker[$count]}\r" - #echo -e "\e[38;5;${color}m ${marker[$count]}\r" - - #echo -e "\e[38;5;154m ${marker[$count]}\r" - - #fSleep="0.0$count" - local fSleep=0.03 - sleep "$fSleep" - - done - - unset marker - - } - - #///////////////////////////////////////////////////////////////////////////////////// - #Main Loop - #///////////////////////////////////////////////////////////////////////////////////// - #---------------------------------------------------------------- - #Hide cursor - tput civis - #---------------------------------------------------------------- - # Run - Funtime_"$INPUT" - #---------------------------------------------------------------- - #Put colours back to normal - echo -e "\e[0m" - - #Move a line down - echo -e "" - #---------------------------------------------------------------- - #enable cursor - tput cnorm - #----------------------------------------------------------------------------------- - exit - #----------------------------------------------------------------------------------- -} \ No newline at end of file diff --git a/dietpi/dietpi-launcher b/dietpi/dietpi-launcher index c47ccc4bca..37228b5fb1 100644 --- a/dietpi/dietpi-launcher +++ b/dietpi/dietpi-launcher @@ -14,27 +14,12 @@ # #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Exit path for non-root logins. - if (( $UID != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit - - fi - - #RootFS RW check - /DietPi/dietpi/dietpi-drive_manager 3 - if (( $? != 0 )); then - - exit - - fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Launcher' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// # MENUS diff --git a/dietpi/dietpi-letsencrypt b/dietpi/dietpi-letsencrypt index cc5b790d41..c910014837 100644 --- a/dietpi/dietpi-letsencrypt +++ b/dietpi/dietpi-letsencrypt @@ -17,27 +17,18 @@ # - /DietPi/dietpi/dietpi-letsencrypt 1 = Create/Renew/Apply cert #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Exit path for non-root logins. - if (( $UID != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit - - fi - - #Grab Input (valid interger) + #Grab Input INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then INPUT=$1 fi - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Letsencrypt' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// #Globals @@ -45,7 +36,7 @@ DP_LOGFILE="/var/log/dietpi-letsencrypt.log" DP_MONTHLY_CRON="/etc/cron.monthly/dietpi-letsencrypt" DP_LETSENCRYPT_BINARY="/usr/bin/certbot" - if (( $DISTRO < 4 )); then + if (( $G_DISTRO < 4 )); then DP_LETSENCRYPT_BINARY="/etc/certbot_scripts/certbot-auto" fi DP_WEBSERVER_INDEX=0 #0=apache2 1=lighttpd 2=nginx 3=minio @@ -62,7 +53,7 @@ Run_Lets_Encrypt(){ - /DietPi/dietpi/func/dietpi-notify 3 "$PROGRAM_NAME" "Running cert" + G_DIETPI-NOTIFY 3 "$PROGRAM_NAME" "Running cert" #Conditions that must be met before allowing run local run_conditions_met=1 @@ -73,28 +64,28 @@ if (( $(ps aux | grep -ci -m1 '[a]pache') )); then DP_WEBSERVER_INDEX=0 - /DietPi/dietpi/func/dietpi-notify 0 "Apache2 webserver detected" - if (( $DISTRO >= 4 )); then + G_DIETPI-NOTIFY 0 "Apache2 webserver detected" + if (( $G_DISTRO >= 4 )); then DP_LETSENCRYPT_BINARY="$DP_LETSENCRYPT_BINARY --apache" fi elif (( $(ps aux | grep -ci -m1 '[l]ighttpd') )); then DP_WEBSERVER_INDEX=1 - /DietPi/dietpi/func/dietpi-notify 0 "Lighttpd webserver detected" + G_DIETPI-NOTIFY 0 "Lighttpd webserver detected" elif (( $(ps aux | grep -ci -m1 '[n]ginx') )); then DP_WEBSERVER_INDEX=2 - /DietPi/dietpi/func/dietpi-notify 0 "Nginx webserver detected" - if (( $DISTRO >= 4 )); then + G_DIETPI-NOTIFY 0 "Nginx webserver detected" + if (( $G_DISTRO >= 4 )); then DP_LETSENCRYPT_BINARY="$DP_LETSENCRYPT_BINARY --nginx" fi elif (( $(ps aux | grep -ci -m1 '[m]inio') )); then DP_WEBSERVER_INDEX=3 - /DietPi/dietpi/func/dietpi-notify 0 "Minio S3 server detected" + G_DIETPI-NOTIFY 0 "Minio S3 server detected" else @@ -194,19 +185,19 @@ _EOF_ #------------------------------------------------------------------------------------------------------ # Nginx - + elif (( $DP_WEBSERVER_INDEX == 2 )); then - + local nginx_defaultsite="/etc/nginx/sites-available/default" - + # Apply domain name sed -i "/server_name/c\ server_name $LETSENCRYPT_DOMAIN;" "$nginx_defaultsite" - + #Restart nginx to apply ServerName changes. systemctl restart nginx local cli_redirect="--no-redirect" - + if (( $LETSENCRYPT_REDIRECT )); then cli_redirect="--redirect" @@ -215,8 +206,8 @@ _EOF_ #Cert me up Nginx $DP_LETSENCRYPT_BINARY --duplicate --agree-tos $cli_redirect --rsa-key-size $LETSENCRYPT_KEYSIZE --email $LETSENCRYPT_EMAIL -d $LETSENCRYPT_DOMAIN - - + + #------------------------------------------------------------------------------------------------------ #Minio elif (( $DP_WEBSERVER_INDEX == 3 )); then @@ -269,7 +260,7 @@ _EOF_ #------------------------------------------------------------------------------------------------------ #ALL | Create cron job - if (( $LETSENCRYPT_AUTORENEW && $DISTRO < 4 )); then + if (( $LETSENCRYPT_AUTORENEW && $G_DISTRO < 4 )); then cat << _EOF_ > "$DP_MONTHLY_CRON" #!/bin/bash @@ -478,8 +469,8 @@ _EOF_ #Menu if (( $INPUT == 0 )); then - /DietPi/dietpi/func/dietpi-notify 1 "Certbot binary not found ( $DP_LETSENCRYPT_BINARY )" - /DietPi/dietpi/func/dietpi-notify 2 "Please install Certbot with DietPi-Software before running this program." + G_DIETPI-NOTIFY 1 "Certbot binary not found ( $DP_LETSENCRYPT_BINARY )" + G_DIETPI-NOTIFY 2 "Please install Certbot with DietPi-Software before running this program." read -p "Press any key to continue....." else diff --git a/dietpi/dietpi-logclear b/dietpi/dietpi-logclear index 23d8671823..4ca445f10f 100644 --- a/dietpi/dietpi-logclear +++ b/dietpi/dietpi-logclear @@ -16,12 +16,6 @@ # - dietpi-logclear 2 | Delete all logs in $FILEPATH_LOGFOLDER and backups. #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - INPUT=-1 if [[ $1 =~ ^-?[0-9]+$ ]]; then @@ -29,6 +23,12 @@ fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Logclear' + #Import DietPi-Globals --------------------------------------------------------------- + #//////////////////////////////////////////////////////////////// # Global #//////////////////////////////////////////////////////////////// @@ -62,7 +62,6 @@ #//////////////////////////////////////////////////////////////// # Process log files. #//////////////////////////////////////////////////////////////// - Process_Logfiles(){ #----------------------------------------------------------------------------------- @@ -126,7 +125,7 @@ fi - /DietPi/dietpi/func/dietpi-notify 2 'Clearing log entries for PiHole, that are not from today, please wait...' + G_DIETPI-NOTIFY 2 'Clearing log entries for PiHole, that are not from today, please wait...' sed -i '/'"$month_day_today"'/!d' /var/log/pihole.log pihole_restart_required=1 @@ -139,7 +138,7 @@ # - 5mb should be more than enough for 1+ days of pihole logs if (( $FILESIZE_BYTES >= 5242880 )); then - /DietPi/dietpi/func/dietpi-notify 2 "${ARRAY_LOG_FILEPATH[$i]} has exceeded 5MB, clearing, please wait..." + G_DIETPI-NOTIFY 2 "${ARRAY_LOG_FILEPATH[$i]} has exceeded 5MB, clearing, please wait..." # RAMlog mode 2: if (( $INPUT == 0 )); then @@ -164,7 +163,7 @@ #restart PiHole if we modified the log file if (( $pihole_restart_required )); then - /DietPi/dietpi/func/dietpi-notify 2 'PiHole logs have been changed, restarting, please wait...' + G_DIETPI-NOTIFY 2 'PiHole logs have been changed, restarting, please wait...' systemctl stop pihole-FTL systemctl stop dnsmasq sleep 1 @@ -240,13 +239,12 @@ #//////////////////////////////////////////////////////////////// #---------------------------------------------------------------- - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Logclear "Welcome" + G_DIETPI-NOTIFY 3 DietPi-Logclear "Welcome" #---------------------------------------------------------------- #How to use print. if (( $INPUT == -1 )); then - echo -e "" - echo -e "\e[90m Available commands:\e[0m" + G_DIETPI-NOTIFY 2 'Available commands:' echo -e "" echo -e "\e[1m dietpi-logclear 0\e[0m" echo -e "\e[38;5;244m Backup contents of all log files from $FILEPATH_LOGFOLDER to $FILEPATH_BACKUPFOLDER/*.\n Also clears the contents of all logs files in $FILEPATH_LOGFOLDER.\e[0m" @@ -275,7 +273,7 @@ fi #Print Info - echo -e " \e[38;5;244mInfo:\e[0m" + G_DIETPI-NOTIFY 2 echo -e " - Log file directory \e[90m|\e[0m $FILEPATH_LOGFOLDER" echo -e " - Processed files \e[90m|\e[0m $INFO_FILES_PROCESSED" @@ -311,4 +309,4 @@ #----------------------------------------------------------------------------------- exit #----------------------------------------------------------------------------------- -} \ No newline at end of file +} diff --git a/dietpi/dietpi-morsecode b/dietpi/dietpi-morsecode index 51d01a4dc5..500a3fc22d 100644 --- a/dietpi/dietpi-morsecode +++ b/dietpi/dietpi-morsecode @@ -17,12 +17,6 @@ # - dietpi-morsecode 2 = Output to ALSA (sound) #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - #At the end of the day, if your using this, your probably in a life threating situation. #I doubt your Transmission downloads, or webserver is going to be more important. #So, Lets change the nice to -10 (High priority) ;) @@ -33,6 +27,12 @@ INPUT=$1 fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Morsecode' + #Import DietPi-Globals --------------------------------------------------------------- + #///////////////////////////////////////////////////////////////////////////////////// # Output Data #///////////////////////////////////////////////////////////////////////////////////// diff --git a/dietpi/dietpi-obtain_hw_model b/dietpi/dietpi-obtain_hw_model index 81729255ca..0ae72f21eb 100644 --- a/dietpi/dietpi-obtain_hw_model +++ b/dietpi/dietpi-obtain_hw_model @@ -12,74 +12,71 @@ # - Called from /DietPi/dietpi/boot # # In DietPi-Software: - # MAX_HW_MODEL=64 #This needs to match highest HW_MODEL value in dietpi-obtain_hw_model - # MAX_HW_ARCH=10 #This needs to match highest HW_ARCH value in dietpi-obtain_hw_model + # MAX_G_HW_MODEL=64 #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 - - # HW_MODEL 110 RoseapplePi - # HW_MODEL 100 Asus Tinker Board - # HW_MODEL 90 A20-OLinuXino-MICRO - # HW_MODEL 80 Cubieboard 3 - # HW_MODEL 71 Beagle Bone Black - # HW_MODEL 70 Sparky SBC - # HW_MODEL 66 NanoPi M1 Plus - # HW_MODEL 65 NanoPi NEO 2 - # HW_MODEL 64 NanoPi NEO Air - # HW_MODEL 63 NanoPi M1/T1 - # HW_MODEL 62 NanoPi M3/T3 - # HW_MODEL 61 NanoPi M2/T2 - # HW_MODEL 60 NanoPi Neo - # HW_MODEL 51 BananaPi Pro (Lemaker) - # HW_MODEL 50 BananaPi M2+ (sinovoip) - # HW_MODEL 43 Rock64 - # HW_MODEL 42 Pine A64+ (2048mb) - # HW_MODEL 41 Pine A64+ (1024mb) - # HW_MODEL 40 Pine A64 (512mb) - # HW_MODEL 38 OrangePi PC 2 - # HW_MODEL 37 OrangePi Prime - # HW_MODEL 36 OrangePi Win - # HW_MODEL 35 OrangePi Zero Plus 2 (H3/H5) - # HW_MODEL 34 OrangePi Plus - # HW_MODEL 33 OrangePi Lite - # HW_MODEL 32 OrangePi Zero (H2+) - # HW_MODEL 31 OrangePi One - # HW_MODEL 30 OrangePi PC - # HW_MODEL 21 x86_64 native (PC) - # HW_MODEL 20 VM x64 (VMware VirtualBox) - # HW_MODEL 13 oDroid U3 - # HW_MODEL 12 oDroid C2 - # HW_MODEL 11 oDroid XU3/4 - # HW_MODEL 10 oDroid C1 - # HW_MODEL 3 Raspberry Pi 3 - # HW_MODEL 2 Raspberry Pi 2 - # HW_MODEL 1 Raspberry Pi 1/Zero (512mb) - # HW_MODEL 0 Raspberry Pi 1 (256mb) + # G_HW_MODEL 71 Beagle Bone Black + # G_HW_MODEL 70 Sparky SBC + # G_HW_MODEL 66 NanoPi M1 Plus + # G_HW_MODEL 65 NanoPi NEO 2 + # G_HW_MODEL 64 NanoPi NEO Air + # G_HW_MODEL 63 NanoPi M1/T1 + # G_HW_MODEL 62 NanoPi M3/T3 + # G_HW_MODEL 61 NanoPi M2/T2 + # G_HW_MODEL 60 NanoPi Neo + # G_HW_MODEL 52 Asus Tinker Board + # G_HW_MODEL 51 BananaPi Pro (Lemaker) + # G_HW_MODEL 50 BananaPi M2+ (sinovoip) + # G_HW_MODEL 43 Rock64 + # G_HW_MODEL 40 Pine A64 + # G_HW_MODEL 38 OrangePi PC 2 + # G_HW_MODEL 37 OrangePi Prime + # G_HW_MODEL 36 OrangePi Win + # G_HW_MODEL 35 OrangePi Zero Plus 2 (H3/H5) + # G_HW_MODEL 34 OrangePi Plus + # G_HW_MODEL 33 OrangePi Lite + # G_HW_MODEL 32 OrangePi Zero (H2+) + # G_HW_MODEL 31 OrangePi One + # G_HW_MODEL 30 OrangePi PC + # G_HW_MODEL 22 Generic device (eg: unknown to DietPi) + # G_HW_MODEL 21 x86_64 native (PC) + # G_HW_MODEL 20 VM x64 (VMware VirtualBox) + # G_HW_MODEL 13 oDroid U3 + # G_HW_MODEL 12 oDroid C2 + # G_HW_MODEL 11 oDroid XU3/XU4/HC1 + # G_HW_MODEL 10 oDroid C1 + # G_HW_MODEL 3 Raspberry Pi 3 + # G_HW_MODEL 2 Raspberry Pi 2 + # G_HW_MODEL 1 Raspberry Pi 1/Zero (512mb) + # G_HW_MODEL 0 Raspberry Pi 1 (256mb) # - Line2 - - # HW_MODEL_DESCRIPTION + # G_HW_MODEL_DESCRIPTION # - Line3 - - # DISTRO 0 unknown - # DISTRO 1 Debian Wheezy (No longer supported, http://dietpi.com/phpbb/viewtopic.php?f=9&t=432#p1898) - # DISTRO 2 Ubuntu 14.04 (No longer supported, left in for user message during update) - # DISTRO 3 Jessie - # DISTRO 4 Stretch, pulled a muscle! + # G_DISTRO 0 unknown + # G_DISTRO 1 Debian Wheezy (No longer supported, http://dietpi.com/phpbb/viewtopic.php?f=9&t=432#p1898) + # G_DISTRO 2 Ubuntu 14.04 (No longer supported, left in for user message during update) + # G_DISTRO 3 Jessie + # G_DISTRO 4 Stretch, pulled a muscle! + # G_DISTRO 5 Buster # - Line4 - # RootFS device path (eg: /dev/mmc01) # - Line5 - # UUID # - Line 6 - - # HW_ARCH 10 x86_64 (VM) - # HW_ARCH 3 armv8/arm64 - # HW_ARCH 2 armv7 - # HW_ARCH 1 armv6 - # HW_ARCH 0 unknown + # G_HW_ARCH 10 x86_64 (VM) + # G_HW_ARCH 3 armv8/arm64 + # G_HW_ARCH 2 armv7 + # G_HW_ARCH 1 armv6 + # G_HW_ARCH 0 unknown # - Line 7 - - # HW_ARCH_DESCRIPTION + # G_HW_ARCH_DESCRIPTION # - Line 8 - # IMAGE_ADDITIONAL_CREDITS (eg: ARMbian, Meveric) # - Line 9 - Group CPU's - # HW_CPUID 0 Not set - # HW_CPUID 1 H3 - # HW_CPUID 2 H5 + # G_HW_CPUID 0 Not set + # G_HW_CPUID 1 H3 + # G_HW_CPUID 2 H5 # - Line 10 - Onboard WiFi/BT Index # HW_ONBOARD_WIFI 0 Not set # HW_ONBOARD_WIFI 1 RPi3/ZeroW (BCM43438) @@ -95,6 +92,10 @@ # HW_MANUFACTURER_NAME #//////////////////////////////////// + #Import DietPi-Globals --------------------------------------------------------------- + #. /DietPi/dietpi/func/dietpi-globals + #Import DietPi-Globals --------------------------------------------------------------- + #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. LANG=en_GB.UTF-8 @@ -105,15 +106,15 @@ #Obtain Hardware Model index #///////////////////////////////////////////////////////////////////////////////////// - HW_MODEL=0 - HW_MODEL_DESCRIPTION='Unknown Device' - FP_HW_MODEL_INDENTIFIER='/etc/.dietpi_hw_model_identifier' - DISTRO=0 + G_HW_MODEL=0 + G_HW_MODEL_DESCRIPTION='Unknown Device' + FP_G_HW_MODEL_INDENTIFIER='/etc/.dietpi_hw_model_identifier' + G_DISTRO=0 HW_UUID=0 - HW_ARCH=0 - HW_ARCH_DESCRIPTION='unknown' + G_HW_ARCH=0 + G_HW_ARCH_DESCRIPTION='unknown' IMAGE_ADDITIONAL_CREDITS='' - HW_CPUID=0 + G_HW_CPUID=0 HW_ONBOARD_WIFI=0 ROOTFS_DEVICE_PATH=$(df | grep -m1 '/$' | awk '{print $1}') @@ -132,236 +133,236 @@ # *" because 10000002 then it indicates that your Raspberry Pi has been over-volted HW_REVISION_CODE=$(cat /proc/cpuinfo | grep 'Revision' | awk '{print $3}') - HW_MODEL_DESCRIPTION='RPi ' + G_HW_MODEL_DESCRIPTION='RPi ' if [[ "$HW_REVISION_CODE" = *"Beta" ]]; then HW_RELEASE_DATE='Q1 2012' - HW_MODEL_DESCRIPTION+='Beta' + G_HW_MODEL_DESCRIPTION+='Beta' HW_PCB_REVISION_CODE='Unknown' HW_MEMORY_SIZE=256 HW_MANUFACTURER_NAME='Unknown' - HW_MODEL=0 + G_HW_MODEL=0 elif [[ "$HW_REVISION_CODE" = *"0002" ]]; then HW_RELEASE_DATE='Q1 2012' - HW_MODEL_DESCRIPTION+='B' + G_HW_MODEL_DESCRIPTION+='B' HW_PCB_REVISION_CODE='1.0' HW_MEMORY_SIZE=256 HW_MANUFACTURER_NAME='Unknown' - HW_MODEL=0 + G_HW_MODEL=0 elif [[ "$HW_REVISION_CODE" = *"0003" ]]; then HW_RELEASE_DATE='Q3 2012' - HW_MODEL_DESCRIPTION+='B (ECN0001)' + G_HW_MODEL_DESCRIPTION+='B (ECN0001)' HW_PCB_REVISION_CODE='1.0' HW_MEMORY_SIZE=256 HW_MANUFACTURER_NAME='Unknown' - HW_MODEL=0 + G_HW_MODEL=0 elif [[ "$HW_REVISION_CODE" = *"0004" ]]; then HW_RELEASE_DATE='Q3 2012' - HW_MODEL_DESCRIPTION+='B' + G_HW_MODEL_DESCRIPTION+='B' HW_PCB_REVISION_CODE='2.0' HW_MEMORY_SIZE=256 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=0 + G_HW_MODEL=0 elif [[ "$HW_REVISION_CODE" = *"0005" ]]; then HW_RELEASE_DATE='Q4 2012' - HW_MODEL_DESCRIPTION+='B' + G_HW_MODEL_DESCRIPTION+='B' HW_PCB_REVISION_CODE='2.0' HW_MEMORY_SIZE=256 HW_MANUFACTURER_NAME='Qisda' - HW_MODEL=0 + G_HW_MODEL=0 elif [[ "$HW_REVISION_CODE" = *"0006" ]]; then HW_RELEASE_DATE='Q4 2012' - HW_MODEL_DESCRIPTION+='B' + G_HW_MODEL_DESCRIPTION+='B' HW_PCB_REVISION_CODE='2.0' HW_MEMORY_SIZE=256 HW_MANUFACTURER_NAME='Egoman' - HW_MODEL=0 + G_HW_MODEL=0 elif [[ "$HW_REVISION_CODE" = *"0007" ]]; then HW_RELEASE_DATE='Q1 2013' - HW_MODEL_DESCRIPTION+='A' + G_HW_MODEL_DESCRIPTION+='A' HW_PCB_REVISION_CODE='2.0' HW_MEMORY_SIZE=256 HW_MANUFACTURER_NAME='Egoman' - HW_MODEL=0 + G_HW_MODEL=0 elif [[ "$HW_REVISION_CODE" = *"0008" ]]; then HW_RELEASE_DATE='Q1 2013' - HW_MODEL_DESCRIPTION+='A' + G_HW_MODEL_DESCRIPTION+='A' HW_PCB_REVISION_CODE='2.0' HW_MEMORY_SIZE=256 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=0 + G_HW_MODEL=0 elif [[ "$HW_REVISION_CODE" = *"0009" ]]; then HW_RELEASE_DATE='Q1 2013' - HW_MODEL_DESCRIPTION+='A' + G_HW_MODEL_DESCRIPTION+='A' HW_PCB_REVISION_CODE='2.0' HW_MEMORY_SIZE=256 HW_MANUFACTURER_NAME='Qisda' - HW_MODEL=0 + G_HW_MODEL=0 elif [[ "$HW_REVISION_CODE" = *"000d" ]]; then HW_RELEASE_DATE='Q4 2012' - HW_MODEL_DESCRIPTION+='B' + G_HW_MODEL_DESCRIPTION+='B' HW_PCB_REVISION_CODE='2.0' HW_MEMORY_SIZE=512 HW_MANUFACTURER_NAME='Egoman' - HW_MODEL=1 + G_HW_MODEL=1 elif [[ "$HW_REVISION_CODE" = *"000e" ]]; then HW_RELEASE_DATE='Q4 2012' - HW_MODEL_DESCRIPTION+='B' + G_HW_MODEL_DESCRIPTION+='B' HW_PCB_REVISION_CODE='2.0' HW_MEMORY_SIZE=512 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=1 + G_HW_MODEL=1 elif [[ "$HW_REVISION_CODE" = *"000f" ]]; then HW_RELEASE_DATE='Q4 2012' - HW_MODEL_DESCRIPTION+='B' + G_HW_MODEL_DESCRIPTION+='B' HW_PCB_REVISION_CODE='2.0' HW_MEMORY_SIZE=512 HW_MANUFACTURER_NAME='Qisda' - HW_MODEL=1 + G_HW_MODEL=1 elif [[ "$HW_REVISION_CODE" = *"0010" ]]; then HW_RELEASE_DATE='Q3 2014' - HW_MODEL_DESCRIPTION+='B+' + G_HW_MODEL_DESCRIPTION+='B+' HW_PCB_REVISION_CODE='1.0' HW_MEMORY_SIZE=512 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=1 + G_HW_MODEL=1 elif [[ "$HW_REVISION_CODE" = *"0011" ]]; then HW_RELEASE_DATE='Q2 2014' - HW_MODEL_DESCRIPTION+='CM' + G_HW_MODEL_DESCRIPTION+='CM' HW_PCB_REVISION_CODE='1.0' HW_MEMORY_SIZE=512 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=1 + G_HW_MODEL=1 elif [[ "$HW_REVISION_CODE" = *"0012" ]]; then HW_RELEASE_DATE='Q4 2014' - HW_MODEL_DESCRIPTION+='A+' + G_HW_MODEL_DESCRIPTION+='A+' HW_PCB_REVISION_CODE='1.0' HW_MEMORY_SIZE=256 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=0 + G_HW_MODEL=0 elif [[ "$HW_REVISION_CODE" = *"0013" ]]; then HW_RELEASE_DATE='Q1 2015' - HW_MODEL_DESCRIPTION+='B+' + G_HW_MODEL_DESCRIPTION+='B+' HW_PCB_REVISION_CODE='1.2' HW_MEMORY_SIZE=512 HW_MANUFACTURER_NAME='Unknown' - HW_MODEL=1 + G_HW_MODEL=1 elif [[ "$HW_REVISION_CODE" = *"a01041" ]]; then HW_RELEASE_DATE='Q1 2015' - HW_MODEL_DESCRIPTION+='2 Model B' + G_HW_MODEL_DESCRIPTION+='2 Model B' HW_PCB_REVISION_CODE='1.1' HW_MEMORY_SIZE=1024 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=2 + G_HW_MODEL=2 elif [[ "$HW_REVISION_CODE" = *"a020a0" ]]; then HW_RELEASE_DATE='Q1 2017' - HW_MODEL_DESCRIPTION+='CM 3' + G_HW_MODEL_DESCRIPTION+='CM 3' HW_PCB_REVISION_CODE='1.0' HW_MEMORY_SIZE=1024 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=3 + G_HW_MODEL=3 HW_ONBOARD_WIFI=1 elif [[ "$HW_REVISION_CODE" = *"a21041" ]]; then HW_RELEASE_DATE='Q1 2015' - HW_MODEL_DESCRIPTION+='2 Model B' + G_HW_MODEL_DESCRIPTION+='2 Model B' HW_PCB_REVISION_CODE='1.1' HW_MEMORY_SIZE=1024 HW_MANUFACTURER_NAME='Embest, China' - HW_MODEL=2 + G_HW_MODEL=2 elif [[ "$HW_REVISION_CODE" = *"a02082" ]]; then HW_RELEASE_DATE='Q1 2016' - HW_MODEL_DESCRIPTION+='3 Model B' + G_HW_MODEL_DESCRIPTION+='3 Model B' HW_PCB_REVISION_CODE='1.2' HW_MEMORY_SIZE=1024 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=3 + G_HW_MODEL=3 HW_ONBOARD_WIFI=1 elif [[ "$HW_REVISION_CODE" = *"a22082" ]]; then HW_RELEASE_DATE='Q1 2016' - HW_MODEL_DESCRIPTION+='3 Model B' + G_HW_MODEL_DESCRIPTION+='3 Model B' HW_PCB_REVISION_CODE='1.2' HW_MEMORY_SIZE=1024 HW_MANUFACTURER_NAME='Embest, China' - HW_MODEL=3 + G_HW_MODEL=3 HW_ONBOARD_WIFI=1 elif [[ "$HW_REVISION_CODE" = *"a32082" ]]; then HW_RELEASE_DATE='Q4 2016' - HW_MODEL_DESCRIPTION+='3 Model B' + G_HW_MODEL_DESCRIPTION+='3 Model B' HW_PCB_REVISION_CODE='1.2' HW_MEMORY_SIZE=1024 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=3 + G_HW_MODEL=3 HW_ONBOARD_WIFI=1 elif [[ "$HW_REVISION_CODE" = *"900092" ]]; then HW_RELEASE_DATE='Q4 2015' - HW_MODEL_DESCRIPTION+='Zero' + G_HW_MODEL_DESCRIPTION+='Zero' HW_PCB_REVISION_CODE='1.2' HW_MEMORY_SIZE=512 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=1 + G_HW_MODEL=1 elif [[ "$HW_REVISION_CODE" = *"900093" ]]; then HW_RELEASE_DATE='Q2 2016' - HW_MODEL_DESCRIPTION+='Zero' + G_HW_MODEL_DESCRIPTION+='Zero' HW_PCB_REVISION_CODE='1.3' HW_MEMORY_SIZE=512 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=1 + G_HW_MODEL=1 elif [[ "$HW_REVISION_CODE" = *"9000c1" ]]; then HW_RELEASE_DATE='Q1 2017' - HW_MODEL_DESCRIPTION+='Zero W' + G_HW_MODEL_DESCRIPTION+='Zero W' HW_PCB_REVISION_CODE='1.1' HW_MEMORY_SIZE=512 HW_MANUFACTURER_NAME='Sony' - HW_MODEL=1 + G_HW_MODEL=1 HW_ONBOARD_WIFI=1 fi @@ -370,263 +371,224 @@ Obtain_HW_Info(){ - #Systems that use /etc/.dietpi_hw_model_identifier for HW_MODEL - if [ -f "$FP_HW_MODEL_INDENTIFIER" ]; then - - HW_MODEL=$(sed -n 1p "$FP_HW_MODEL_INDENTIFIER") - - #RoseapplePi - if (( $HW_MODEL == 110 )); then - - HW_MODEL_DESCRIPTION='RoseapplePi' - IMAGE_ADDITIONAL_CREDITS='ARMbian' - - #Asus Tinker Board - elif (( $HW_MODEL == 100 )); then - - HW_MODEL_DESCRIPTION='Asus Tinker Board' + #Systems that use /etc/.dietpi_hw_model_identifier for G_HW_MODEL + if [ -f "$FP_G_HW_MODEL_INDENTIFIER" ]; then - #A20-OLinuXino-MICRO - elif (( $HW_MODEL == 90 )); then - - HW_MODEL_DESCRIPTION='A20-OLinuXino-MICRO' - IMAGE_ADDITIONAL_CREDITS='ARMbian' - - #Cubieboard 3 - elif (( $HW_MODEL == 80 )); then - - HW_MODEL_DESCRIPTION='Cubieboard 3' - IMAGE_ADDITIONAL_CREDITS='ARMbian' + G_HW_MODEL=$(sed -n 1p "$FP_G_HW_MODEL_INDENTIFIER") #Beagle Bone Black - elif (( $HW_MODEL == 71 )); then + if (( $G_HW_MODEL == 71 )); then - HW_MODEL_DESCRIPTION='BBB' + G_HW_MODEL_DESCRIPTION='BBB' #Sparky SBC - elif (( $HW_MODEL == 70 )); then + elif (( $G_HW_MODEL == 70 )); then - HW_MODEL_DESCRIPTION='Sparky SBC' + G_HW_MODEL_DESCRIPTION='Sparky SBC' #NanoPi M1 Plus - elif (( $HW_MODEL == 66 )); then + elif (( $G_HW_MODEL == 66 )); then - HW_MODEL_DESCRIPTION='NanoPi M1 Plus' + G_HW_MODEL_DESCRIPTION='NanoPi M1 Plus' IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=1 + G_HW_CPUID=1 #NanoPi NEO 2 - elif (( $HW_MODEL == 65 )); then + elif (( $G_HW_MODEL == 65 )); then - HW_MODEL_DESCRIPTION='NanoPi NEO 2' + G_HW_MODEL_DESCRIPTION='NanoPi NEO 2' IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=2 + G_HW_CPUID=2 #NanoPi NEO Air - elif (( $HW_MODEL == 64 )); then + elif (( $G_HW_MODEL == 64 )); then - HW_MODEL_DESCRIPTION='NanoPi NEO Air' + G_HW_MODEL_DESCRIPTION='NanoPi NEO Air' IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=1 + G_HW_CPUID=1 #NanoPi M1 - elif (( $HW_MODEL == 63 )); then + elif (( $G_HW_MODEL == 63 )); then - HW_MODEL_DESCRIPTION='NanoPi M1/T1' + G_HW_MODEL_DESCRIPTION='NanoPi M1/T1' IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=1 + G_HW_CPUID=1 #NanoPi M3 - elif (( $HW_MODEL == 62 )); then + elif (( $G_HW_MODEL == 62 )); then - HW_MODEL_DESCRIPTION='NanoPi M3/T3' + G_HW_MODEL_DESCRIPTION='NanoPi M3/T3' #NanoPi M2 - elif (( $HW_MODEL == 61 )); then + elif (( $G_HW_MODEL == 61 )); then - HW_MODEL_DESCRIPTION='NanoPi M2/T2' + G_HW_MODEL_DESCRIPTION='NanoPi M2/T2' #NanoPi Neo - elif (( $HW_MODEL == 60 )); then + elif (( $G_HW_MODEL == 60 )); then - HW_MODEL_DESCRIPTION='NanoPi Neo' + G_HW_MODEL_DESCRIPTION='NanoPi Neo' IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=1 + G_HW_CPUID=1 - #BananaPi M2+ - elif (( $HW_MODEL == 50 )); then + #Asus Tinker Board + elif (( $G_HW_MODEL == 52 )); then - HW_MODEL_DESCRIPTION='BananaPi M2+' - IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=1 + G_HW_MODEL_DESCRIPTION='Asus Tinker Board' #BananaPi Pro - elif (( $HW_MODEL == 51 )); then + elif (( $G_HW_MODEL == 51 )); then - HW_MODEL_DESCRIPTION='BananaPi Pro' + G_HW_MODEL_DESCRIPTION='BananaPi Pro' IMAGE_ADDITIONAL_CREDITS='ARMbian' + #BananaPi M2+ + elif (( $G_HW_MODEL == 50 )); then + + G_HW_MODEL_DESCRIPTION='BananaPi M2+' + IMAGE_ADDITIONAL_CREDITS='ARMbian' + G_HW_CPUID=1 + #Rock64 - elif (( $HW_MODEL == 43 )); then + elif (( $G_HW_MODEL == 43 )); then - HW_MODEL_DESCRIPTION='Rock64' + G_HW_MODEL_DESCRIPTION='Rock64' IMAGE_ADDITIONAL_CREDITS='Longsleep, Ayufan' #PineA64 - elif (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then + elif (( $G_HW_MODEL == 40 )); then IMAGE_ADDITIONAL_CREDITS='Longsleep, Rhkean' - - MEMTOTAL=$(free | awk '/^Mem:/{print $2}') - if (( $MEMTOTAL > 2000000 )); then - - HW_MODEL_DESCRIPTION='Pine A64+ 2GB' - HW_MODEL=42 - - elif (( $MEMTOTAL > 1000000 )); then - - HW_MODEL_DESCRIPTION='Pine A64+ 1GB' - HW_MODEL=41 - - else - - HW_MODEL_DESCRIPTION='Pine A64 512MB' - HW_MODEL=40 - - fi + G_HW_MODEL_DESCRIPTION='Pine A64' #OrangePi PC 2 - elif (( $HW_MODEL == 38 )); then + elif (( $G_HW_MODEL == 38 )); then - HW_MODEL_DESCRIPTION='OPi PC2' + G_HW_MODEL_DESCRIPTION='OPi PC2' IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=2 + G_HW_CPUID=2 #OrangePi Prime - elif (( $HW_MODEL == 37 )); then + elif (( $G_HW_MODEL == 37 )); then - HW_MODEL_DESCRIPTION='OPi Prime' + G_HW_MODEL_DESCRIPTION='OPi Prime' IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=2 + G_HW_CPUID=2 #OrangePi Win - elif (( $HW_MODEL == 36 )); then + elif (( $G_HW_MODEL == 36 )); then - HW_MODEL_DESCRIPTION='OPi Win' + G_HW_MODEL_DESCRIPTION='OPi Win' IMAGE_ADDITIONAL_CREDITS='ARMbian' #OrangePi Zero Plus 2 (h3/h5) - elif (( $HW_MODEL == 35 )); then + elif (( $G_HW_MODEL == 35 )); then - HW_MODEL_DESCRIPTION='OPi Zero 2 Plus' + G_HW_MODEL_DESCRIPTION='OPi Zero 2 Plus' IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=1 + G_HW_CPUID=1 #OrangePi Plus - elif (( $HW_MODEL == 34 )); then + elif (( $G_HW_MODEL == 34 )); then - HW_MODEL_DESCRIPTION='OrangePi Plus' + G_HW_MODEL_DESCRIPTION='OrangePi Plus' IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=1 + G_HW_CPUID=1 #OrangePi Lite - elif (( $HW_MODEL == 33 )); then + elif (( $G_HW_MODEL == 33 )); then - HW_MODEL_DESCRIPTION='OrangePi Lite' + G_HW_MODEL_DESCRIPTION='OrangePi Lite' IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=1 + G_HW_CPUID=1 #OrangePi Zero - elif (( $HW_MODEL == 32 )); then + elif (( $G_HW_MODEL == 32 )); then - HW_MODEL_DESCRIPTION='OrangePi Zero' + G_HW_MODEL_DESCRIPTION='OrangePi Zero' IMAGE_ADDITIONAL_CREDITS='ARMbian' - #HW_CPUID=1 #H2+ + #G_HW_CPUID=1 #H2+ #OrangePi One - elif (( $HW_MODEL == 31 )); then + elif (( $G_HW_MODEL == 31 )); then - HW_MODEL_DESCRIPTION='OrangePi One' + G_HW_MODEL_DESCRIPTION='OrangePi One' IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=1 + G_HW_CPUID=1 #OrangePi Pc - elif (( $HW_MODEL == 30 )); then + elif (( $G_HW_MODEL == 30 )); then - HW_MODEL_DESCRIPTION='OrangePi PC' + G_HW_MODEL_DESCRIPTION='OrangePi PC' IMAGE_ADDITIONAL_CREDITS='ARMbian' - HW_CPUID=1 + G_HW_CPUID=1 + + #Generic device (eg: unknown to DietPi) + elif (( $G_HW_MODEL == 22 )); then + + G_HW_MODEL_DESCRIPTION='Generic Device' + IMAGE_ADDITIONAL_CREDITS='You!' #x86_64 native PC - elif (( $HW_MODEL == 21 )); then + elif (( $G_HW_MODEL == 21 )); then - HW_MODEL_DESCRIPTION='Native PC' + G_HW_MODEL_DESCRIPTION='Native PC' #VM - elif (( $HW_MODEL == 20 )); then + elif (( $G_HW_MODEL == 20 )); then - HW_MODEL_DESCRIPTION='Virtual Machine' + G_HW_MODEL_DESCRIPTION='Virtual Machine' #oDroid U3 - elif (( $HW_MODEL == 13 )); then + elif (( $G_HW_MODEL == 13 )); then - HW_MODEL_DESCRIPTION='oDroid U3' + G_HW_MODEL_DESCRIPTION='Odroid U3' #IMAGE_ADDITIONAL_CREDITS='Meveric' - elif (( $HW_MODEL == 12 )); then + #Odroid C2 + elif (( $G_HW_MODEL == 12 )); then + + G_HW_MODEL_DESCRIPTION='Odroid C2' + IMAGE_ADDITIONAL_CREDITS='Meveric' + + #Odroid XU3/XU4/HC1 + elif (( $G_HW_MODEL == 11 )); then - HW_MODEL_DESCRIPTION='oDroid C2' + G_HW_MODEL_DESCRIPTION='Odroid XU3/4' IMAGE_ADDITIONAL_CREDITS='Meveric' - #oDroid XU3/4 via /etc/.dietpi_hw_model - elif (( $HW_MODEL == 11 )); then + #Odroid C1 + elif (( $G_HW_MODEL == 10 )); then - HW_MODEL_DESCRIPTION='oDroid XU3/4' + G_HW_MODEL_DESCRIPTION='Odroid C1' IMAGE_ADDITIONAL_CREDITS='Meveric' fi #RPi - elif (( $(cat /etc/os-release | grep -ci -m1 '^ID=raspbian') )); then + elif (( $(grep -ci -m1 '^ID=raspbian' /etc/os-release) )); then #Grab hardware description from rpi_boardinfo RPi_BoardInfo - #oDroid C2 - elif (( $(cat /proc/cpuinfo | grep -ci -m1 'ODROID-C2') )); then - - HW_MODEL_DESCRIPTION='oDroid C2' - HW_MODEL=12 - IMAGE_ADDITIONAL_CREDITS='Meveric' - - #oDroid XU3/4 - elif (( $(cat /proc/cpuinfo | grep -ci -m1 'ODROID-XU3') )); then - - HW_MODEL_DESCRIPTION='oDroid XU3/4' - HW_MODEL=11 - IMAGE_ADDITIONAL_CREDITS='Meveric' - - #oDroid C1 - elif (( $(cat /proc/cpuinfo | grep -ci -m1 'ODROIDC') )); then + fi - HW_MODEL_DESCRIPTION='oDroid C1' - HW_MODEL=10 - IMAGE_ADDITIONAL_CREDITS='Meveric' + #Get Distro Index + if (( $( grep -ci -m1 'jessie' /etc/os-release) )); then - fi + G_DISTRO=3 - #Get Distro Index (assumes jessie) - if (( $( cat /etc/*release | grep -ci -m1 'jessie') )); then + elif (( $( grep -ci -m1 'stretch' /etc/os-release) )); then - DISTRO=3 + G_DISTRO=4 - elif (( $( cat /etc/*release | grep -ci -m1 'stretch') )); then + elif (( $( grep -ci -m1 'buster' /etc/os-release) )); then - DISTRO=4 + G_DISTRO=5 fi - #Generate UUID if it doesnt not exist + #Generate UUID if it does not exist if [ ! -f /DietPi/dietpi/.hw_model ]; then HW_UUID=$(cat /proc/sys/kernel/random/uuid) @@ -638,44 +600,44 @@ fi #Obtain hardware cpu architecture - HW_ARCH_DESCRIPTION=$(uname -m) - if [ "$HW_ARCH_DESCRIPTION" = "armv6l" ]; then + G_HW_ARCH_DESCRIPTION=$(uname -m) + if [ "$G_HW_ARCH_DESCRIPTION" = "armv6l" ]; then - HW_ARCH=1 + G_HW_ARCH=1 - elif [ "$HW_ARCH_DESCRIPTION" = "armv7l" ]; then + elif [ "$G_HW_ARCH_DESCRIPTION" = "armv7l" ]; then - HW_ARCH=2 + G_HW_ARCH=2 - elif [ "$HW_ARCH_DESCRIPTION" = "aarch64" ]; then + elif [ "$G_HW_ARCH_DESCRIPTION" = "aarch64" ]; then - HW_ARCH=3 + G_HW_ARCH=3 - elif [ "$HW_ARCH_DESCRIPTION" = "x86_64" ]; then + elif [ "$G_HW_ARCH_DESCRIPTION" = "x86_64" ]; then - HW_ARCH=10 + G_HW_ARCH=10 # - Unknown arch for DietPi, inform user by adding 'unknown'. else - HW_ARCH_DESCRIPTION+=' (Unknown)' + G_HW_ARCH_DESCRIPTION+=' (Unknown)' fi # - Add HW arch to HW desc - HW_MODEL_DESCRIPTION+=" ($HW_ARCH_DESCRIPTION)" + G_HW_MODEL_DESCRIPTION+=" ($G_HW_ARCH_DESCRIPTION)" #Save data cat << _EOF_ > /DietPi/dietpi/.hw_model -$HW_MODEL -$HW_MODEL_DESCRIPTION -$DISTRO +$G_HW_MODEL +$G_HW_MODEL_DESCRIPTION +$G_DISTRO $ROOTFS_DEVICE_PATH $HW_UUID -$HW_ARCH -$HW_ARCH_DESCRIPTION +$G_HW_ARCH +$G_HW_ARCH_DESCRIPTION $IMAGE_ADDITIONAL_CREDITS -$HW_CPUID +$G_HW_CPUID $HW_ONBOARD_WIFI $HW_REVISION_CODE $HW_RELEASE_DATE @@ -690,6 +652,7 @@ _EOF_ #Main Obtain_HW_Info #----------------------------------------------------------------------------------- - exit + exit 0 #----------------------------------------------------------------------------------- + } diff --git a/dietpi/dietpi-process_tool b/dietpi/dietpi-process_tool index 8650abac75..7c2ab09129 100644 --- a/dietpi/dietpi-process_tool +++ b/dietpi/dietpi-process_tool @@ -17,13 +17,7 @@ # dietpi-process_tool 1 = Apply #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Grab Input (valid interger) + #Grab Input INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then @@ -31,6 +25,12 @@ fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Process_tool' + #Import DietPi-Globals --------------------------------------------------------------- + #///////////////////////////////////////////////////////////////////////////////////// # Globals #///////////////////////////////////////////////////////////////////////////////////// @@ -53,11 +53,11 @@ Apply_Process_Tool(){ - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Process_Tool Apply + G_DIETPI-NOTIFY 3 DietPi-Process_Tool Apply local status_text="" - local status_text_ok="$(/DietPi/dietpi/func/dietpi-notify 0)" - local status_text_failed="$(/DietPi/dietpi/func/dietpi-notify 1)" + local status_text_ok="$(G_DIETPI-NOTIFY 0)" + local status_text_failed="$(G_DIETPI-NOTIFY 1)" for ((i=0; i<$MAX_PROGRAMS; i++)) do @@ -73,12 +73,12 @@ aPID[$i]=$line #info - echo -e " ${aNAME[$i]} (${aPID[$i]})" + echo -e "${aNAME[$i]} (${aPID[$i]})" # - Check if PID exists (this can occur with programs like netdata that run as root initally, create a new process under a different user, then terminate the original root process. if (( ! $( ps ax | awk '{print $1}' | grep -ci -m1 "${aPID[$i]}") )); then - /DietPi/dietpi/func/dietpi-notify 2 PID "${aPID[$i]}" no longer exists + G_DIETPI-NOTIFY 2 PID "${aPID[$i]}" no longer exists else @@ -95,7 +95,7 @@ fi - status_text+=" \e[90mNice ${aNICE[$i]}\e[0m" + status_text+="\e[90mNice ${aNICE[$i]}\e[0m" echo -e "$status_text" # - Affinity @@ -111,7 +111,7 @@ fi - status_text+=" \e[90mAffinity ${aAFFINITY[$i]}\e[0m" + status_text+="\e[90mAffinity ${aAFFINITY[$i]}\e[0m" echo -e "$status_text" # - schedule @@ -172,7 +172,7 @@ fi - status_text+=" \e[90mScheduler ${aSCHEDULE_POLICY[$i]} ${aSCHEDULE_PRIORITY[$i]}\e[0m" + status_text+="\e[90mScheduler ${aSCHEDULE_POLICY[$i]} ${aSCHEDULE_PRIORITY[$i]}\e[0m" echo -e "$status_text" fi @@ -830,7 +830,7 @@ elif (( $INPUT == 1 )); then Apply_Process_Tool - /DietPi/dietpi/func/dietpi-notify -1 ${EXIT_CODE:=0} "$PROGRAM_NAME |" + G_DIETPI-NOTIFY -1 ${EXIT_CODE:=0} "$PROGRAM_NAME |" fi #----------------------------------------------------------------------------------- diff --git a/dietpi/dietpi-ramdisk b/dietpi/dietpi-ramdisk index 610736f574..cde1e56db7 100644 --- a/dietpi/dietpi-ramdisk +++ b/dietpi/dietpi-ramdisk @@ -29,9 +29,15 @@ INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then + INPUT=$1 + fi + #Import DietPi-Globals --------------------------------------------------------------- + #. /DietPi/dietpi/func/dietpi-globals # Not compatible until dietpi-boot.service + #Import DietPi-Globals --------------------------------------------------------------- + FILEPATH_RAM="/DietPi" FILEPATH_DISK="/boot" @@ -47,9 +53,7 @@ #Main Loop #///////////////////////////////////////////////////////////////////////////////////// - #/etc/dietpi/logs/dietpi-ramdisk.log - - #Copy to Ram + #Start: Copy to Ram if (( $INPUT == 0 )); then if [ ! -f /DietPi/.ramdisk ]; then @@ -94,7 +98,7 @@ fi - #Copy everything back to DISK + #Stop: Copy everything back to DISK elif (( $INPUT == 1 )); then echo -e "$(date) | DietPi-Ramdisk: Stopping" @@ -111,7 +115,7 @@ # rm -R "$FILEPATH_DISK"/dietpi #: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298241622 #Copy DietPi to Disk with files from RAM - cp -Rf "$FILEPATH_RAM"/* /boot + cp -Rf "$FILEPATH_RAM"/* /boot/ #remove active flag. rm /DietPi/.ramdisk &> /dev/null diff --git a/dietpi/dietpi-ramlog b/dietpi/dietpi-ramlog index 434b911e64..36daf6465d 100644 --- a/dietpi/dietpi-ramlog +++ b/dietpi/dietpi-ramlog @@ -31,7 +31,11 @@ INPUT=$1 fi - FILEPATH_DIETPI_RAMLOG_SAVE='/etc/dietpi/dietpi-ramlog/storage' + #Import DietPi-Globals --------------------------------------------------------------- + #. /DietPi/dietpi/func/dietpi-globals # Not compatible until dietpi-boot.service + #Import DietPi-Globals --------------------------------------------------------------- + + FILEPATH_DIETPI_RAMLOG_SAVE='/var/lib/dietpi/dietpi-ramlog/storage' #///////////////////////////////////////////////////////////////////////////////////// #Funcs @@ -91,7 +95,7 @@ rm -R "$FILEPATH_DIETPI_RAMLOG_SAVE" #Generate Storage Directory - mkdir -p "$FILEPATH_DIETPI_RAMLOG_SAVE" &> /dev/null + mkdir -p "$FILEPATH_DIETPI_RAMLOG_SAVE" #Copy logfile attributes and ownership to storage (not file contents) cp -R -p --attributes-only /var/log/* "$FILEPATH_DIETPI_RAMLOG_SAVE"/ diff --git a/dietpi/dietpi-services b/dietpi/dietpi-services index f87498de6d..97d2197a51 100644 --- a/dietpi/dietpi-services +++ b/dietpi/dietpi-services @@ -14,22 +14,22 @@ # - /DietPi/dietpi/dietpi-services $AVAILABLE_OPTIONS #//////////////////////////////////// AVAILABLE_OPTIONS=' - - start/stop/restart (all services, known to DietPi) + - start/stop/restart/status (all services, known to DietPi) - start/stop/restart servicename (single service, SystemD) - systemd_controlled/dietpi_controlled (all services, known to DietPi) - enable/disable servicename (single service, SystemD) + - enable/disable all (all services, known to DietPi) - mask/unmask servicename (single service, SystemD)' - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - + #Grab Inputs INPUT_MODE="$1" INPUT_S2="$2" - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Services' + #Import DietPi-Globals --------------------------------------------------------------- aSERVICE_NAME=( 'cron' @@ -110,7 +110,7 @@ 'htpc-manager' 'home-assistant' 'openbazaar' - 'dietpi-wifi-monitor' + #'dietpi-wifi-monitor' : https://github.com/Fourdee/DietPi/issues/1288#issuecomment-350653480 'docker' 'bdd' 'minio' @@ -188,19 +188,22 @@ #ok if (( $3 == 0 || $3 == 5 )); then - echo -e "\e[1A$(/DietPi/dietpi/func/dietpi-notify 0)\e[0m $1 : $2" + G_DIETPI-NOTIFY 0 "$1 : $2" #failed else - echo -e "\e[1A$(/DietPi/dietpi/func/dietpi-notify 1)\e[0m $1 : $2" + G_DIETPI-NOTIFY 1 "$1 : $2" fi } + #$1 = mode (eg: start/stop/restart) Set_Running_State(){ + local target_state="$1" + #???????????????????????????????????????????????????????????????????????? # Although this allows for simple service control without using SystemD, we really should convert these to SystemD services. To keep everything consistent, clean, and obtain a correct exit code. #DietPi: Non-service based control for specific dietpi-software installed programs. @@ -208,19 +211,19 @@ index=0 aDIETPISERVICE_FP=() aDIETPISERVICE_NAME=() - aDIETPISERVICE_NAME[$index]='BruteFIR';aDIETPISERVICE_FP[$index]='/etc/dietpi/dietpi-software/services/brutefir.service';((index++)); - aDIETPISERVICE_NAME[$index]='JackD';aDIETPISERVICE_FP[$index]='/etc/dietpi/dietpi-software/services/jackd.service';((index++)); - aDIETPISERVICE_NAME[$index]='Jconvolver';aDIETPISERVICE_FP[$index]='/etc/dietpi/dietpi-software/services/jconvolver.service';((index++)); + aDIETPISERVICE_NAME[$index]='BruteFIR';aDIETPISERVICE_FP[$index]='/var/lib/dietpi/dietpi-software/services/brutefir.service';((index++)); + aDIETPISERVICE_NAME[$index]='JackD';aDIETPISERVICE_FP[$index]='/var/lib/dietpi/dietpi-software/services/jackd.service';((index++)); + aDIETPISERVICE_NAME[$index]='Jconvolver';aDIETPISERVICE_FP[$index]='/var/lib/dietpi/dietpi-software/services/jconvolver.service';((index++)); for ((i=0; i<${#aDIETPISERVICE_NAME[@]}; i++)) do if [ -f ${aDIETPISERVICE_FP[$i]} ]; then - echo -e "${aDIETPISERVICE_NAME[$i]}" + G_DIETPI-NOTIFY -2 "${aDIETPISERVICE_NAME[$i]}" - ${aDIETPISERVICE_FP[$i]} $INPUT_MODE &> /dev/null - Print_Status $INPUT_MODE ${aDIETPISERVICE_NAME[$i]} $? + ${aDIETPISERVICE_FP[$i]} $target_state &> /dev/null + Print_Status $target_state ${aDIETPISERVICE_NAME[$i]} $? fi @@ -248,7 +251,7 @@ #### ALLO Special #### # - Allo web interface image: Exclude stop on aALLO_EXCLUDED_SERVICES_DURING_STOP service list - if [ -d /var/www/allo ] && [ "$INPUT_MODE" = "stop" ]; then + if [ -d /var/www/allo ] && [ "$target_state" = "stop" ]; then for ((j=0; j<${#aALLO_EXCLUDED_SERVICES_DURING_STOP[@]}; j++)) do @@ -268,11 +271,11 @@ #Apply if (( ${aSERVICE_AVAILABLE[$i]} == 1 )); then - echo -e "${aSERVICE_NAME[$i]}" + G_DIETPI-NOTIFY -2 "${aSERVICE_NAME[$i]}" - systemctl $INPUT_MODE ${aSERVICE_NAME[$i]} &> /dev/null + systemctl $target_state ${aSERVICE_NAME[$i]} &> /dev/null - Print_Status $INPUT_MODE ${aSERVICE_NAME[$i]} $? + Print_Status $target_state ${aSERVICE_NAME[$i]} $? fi @@ -287,19 +290,19 @@ index=0 aDIETPISERVICE_FP=() aDIETPISERVICE_NAME=() - aDIETPISERVICE_NAME[$index]='RaspimJpeg';aDIETPISERVICE_FP[$index]='/etc/dietpi/dietpi-software/services/raspimjpeg.service';((index++)); - aDIETPISERVICE_NAME[$index]='Deluge';aDIETPISERVICE_FP[$index]='/etc/dietpi/dietpi-software/services/deluge.service';((index++)); - aDIETPISERVICE_NAME[$index]='SqueezeBox Server';aDIETPISERVICE_FP[$index]='/etc/dietpi/dietpi-software/services/squeezeboxserver.service';((index++)); + aDIETPISERVICE_NAME[$index]='RaspimJpeg';aDIETPISERVICE_FP[$index]='/var/lib/dietpi/dietpi-software/services/raspimjpeg.service';((index++)); + aDIETPISERVICE_NAME[$index]='Deluge';aDIETPISERVICE_FP[$index]='/var/lib/dietpi/dietpi-software/services/deluge.service';((index++)); + aDIETPISERVICE_NAME[$index]='SqueezeBox Server';aDIETPISERVICE_FP[$index]='/var/lib/dietpi/dietpi-software/services/squeezeboxserver.service';((index++)); for ((i=0; i<${#aDIETPISERVICE_NAME[@]}; i++)) do if [ -f ${aDIETPISERVICE_FP[$i]} ]; then - echo -e "${aDIETPISERVICE_NAME[$i]}" + G_DIETPI-NOTIFY -2 "${aDIETPISERVICE_NAME[$i]}" - ${aDIETPISERVICE_FP[$i]} $INPUT_MODE &> /dev/null - Print_Status $INPUT_MODE ${aDIETPISERVICE_NAME[$i]} $? + ${aDIETPISERVICE_FP[$i]} $target_state &> /dev/null + Print_Status $target_state ${aDIETPISERVICE_NAME[$i]} $? fi @@ -312,8 +315,8 @@ echo -e "" #Apply process tool settings - if [ "$INPUT_MODE" = "start" ] || - [ "$INPUT_MODE" = "restart" ]; then + if [ "$target_state" = "start" ] || + [ "$target_state" = "restart" ]; then /DietPi/dietpi/dietpi-process_tool 1 @@ -327,7 +330,7 @@ # Main #///////////////////////////////////////////////////////////////////////////////////// #Info - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Services "$INPUT_MODE" + G_DIETPI-NOTIFY 3 DietPi-Services "$INPUT_MODE" #Obtain an array of available services installed on system. Populate_Available_Array @@ -351,7 +354,7 @@ #Apply if (( ${aSERVICE_AVAILABLE[$i]} == 1 )); then - echo -e "${aSERVICE_NAME[$i]}" + G_DIETPI-NOTIFY -2 "${aSERVICE_NAME[$i]}" systemctl $SYSTEMD_CMD ${aSERVICE_NAME[$i]} &> /dev/null @@ -381,16 +384,46 @@ fi - systemctl stop $INPUT_S2 + # - Process ALL known services + if [ "$INPUT_S2" = 'all' ]; then + + if [ "$INPUT_MODE" = "disable" ] || + [ "$INPUT_MODE" = "mask" ]; then + + echo -e "" + Set_Running_State stop + + fi + + for ((i=0; i<${#aSERVICE_NAME[@]}; i++)) + do + + if (( ${aSERVICE_AVAILABLE[$i]} )); then - systemctl $SYSTEMD_CMD $INPUT_S2 - if (( $? == 0 )); then - /DietPi/dietpi/func/dietpi-notify 0 "$INPUT_MODE $INPUT_S2" + G_DIETPI-NOTIFY 0 "$INPUT_MODE $INPUT_S2: ${aSERVICE_NAME[$i]}" + systemctl $SYSTEMD_CMD ${aSERVICE_NAME[$i]} + fi + + done + + + # - Process user defined single entry via cmd input else - /DietPi/dietpi/func/dietpi-notify 1 "$INPUT_MODE $INPUT_S2" + systemctl stop $INPUT_S2 + + systemctl $SYSTEMD_CMD $INPUT_S2 + if (( $? == 0 )); then + + G_DIETPI-NOTIFY 0 "$INPUT_MODE $INPUT_S2" + + else + + G_DIETPI-NOTIFY 1 "$INPUT_MODE $INPUT_S2" + + fi fi @@ -399,9 +432,8 @@ if [ "$INPUT_MODE" = "unmask" ] || [ "$INPUT_MODE" = "enable" ]; then - INPUT_MODE='start' echo -e "" - Set_Running_State + Set_Running_State start fi @@ -421,16 +453,16 @@ if [[ "$STATUS" =~ .*'failed'.* ]]; then - /DietPi/dietpi/func/dietpi-notify 1 "$STATUS" + G_DIETPI-NOTIFY 1 "$STATUS" systemctl status "${aSERVICE_NAME[$i]}" -l --no-pager elif [[ "$STATUS" =~ .*'inactive'.* ]]; then - /DietPi/dietpi/func/dietpi-notify 2 "$STATUS" + G_DIETPI-NOTIFY 2 "$STATUS" else - /DietPi/dietpi/func/dietpi-notify 0 "$STATUS" + G_DIETPI-NOTIFY 0 "$STATUS" fi @@ -452,11 +484,11 @@ systemctl $INPUT_MODE $INPUT_S2 &> /dev/null if (( $? == 0 )); then - /DietPi/dietpi/func/dietpi-notify 0 "$INPUT_MODE $INPUT_S2" + G_DIETPI-NOTIFY 0 "$INPUT_MODE $INPUT_S2" else - /DietPi/dietpi/func/dietpi-notify 1 "$INPUT_MODE $INPUT_S2" + G_DIETPI-NOTIFY 1 "$INPUT_MODE $INPUT_S2" fi @@ -468,18 +500,18 @@ # Control ownCloud and Nextcloud maintenance mode: if [ "$INPUT_MODE" = "stop" ] || [ "$INPUT_MODE" = "restart" ]; then - grep -q "'maintenance' => false," /var/www/owncloud/config/config.php &>/dev/null && occ maintenance:mode --on 2> /dev/null - grep -q "'maintenance' => false," /var/www/nextcloud/config/config.php &>/dev/null && ncc maintenance:mode --on 2> /dev/null + grep -q "'maintenance' => false," /var/www/owncloud/config/config.php &> /dev/null && G_RUN_CMD occ maintenance:mode --on + grep -q "'maintenance' => false," /var/www/nextcloud/config/config.php &> /dev/null && G_RUN_CMD ncc maintenance:mode --on fi - Set_Running_State + Set_Running_State "$INPUT_MODE" # Control ownCloud and Nextcloud maintenance mode: if [ "$INPUT_MODE" = "restart" ] || [ "$INPUT_MODE" = "start" ]; then - grep -q "'maintenance' => true," /var/www/owncloud/config/config.php &>/dev/null && occ maintenance:mode --off 2> /dev/null - grep -q "'maintenance' => true," /var/www/nextcloud/config/config.php &>/dev/null && ncc maintenance:mode --off 2> /dev/null + grep -q "'maintenance' => true," /var/www/owncloud/config/config.php &> /dev/null && G_RUN_CMD occ maintenance:mode --off + grep -q "'maintenance' => true," /var/www/nextcloud/config/config.php &> /dev/null && G_RUN_CMD ncc maintenance:mode --off fi @@ -488,7 +520,7 @@ #----------------------------------------------------------------------------------- #Invalid command else - echo -e "\nDietPi-Services\nAvailable commands:\n$AVAILABLE_OPTIONS\n" + G_DIETPI-NOTIFY 2 "Invalid command\e[0m\nAvailable commands:\n$AVAILABLE_OPTIONS\n" fi #----------------------------------------------------------------------------------- rm "$FP_TEMP" diff --git a/dietpi/dietpi-software b/dietpi/dietpi-software index 6f23164f3b..ce3b736036 100644 --- a/dietpi/dietpi-software +++ b/dietpi/dietpi-software @@ -16,55 +16,19 @@ # # Usage: # - dietpi-software - # - /DietPi/dietpi/dietpi-software install iUNIQUEID (OR) sINDEX_{SSHSERVER,FILESERVER,LOGGING,WEBSERVER}_TARGET=-int + # - /DietPi/dietpi/dietpi-software install iUNIQUEID (OR) sINDEX_{SSHSERVER,FILESERVER,LOGGING,WEBSERVER}_TARGET=-int # - /DietPi/dietpi/dietpi-software reinstall #Same as installed, however, only reinstalls if state =2. Does not uninstall due to package removal danger (eg: xserver removes kodi), simply flags to be installed (=1). # - /DietPi/dietpi/dietpi-software uninstall iUNIQUEID - # - /DietPi/dietpi/dietpi-software list #Lists UNIQUEIDs for software. + # - /DietPi/dietpi/dietpi-software list #Lists UNIQUEIDs for software. # - /DietPi/dietpi/dietpi-software setpermissions #Sets shared permissions for /var/www and userdata folders. #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Exit path for non-root logins. - if (( $UID != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit - - fi - - #RootFS RW check - /DietPi/dietpi/dietpi-drive_manager 3 - if (( $? != 0 )); then - - exit - - fi - - #///////////////////////////////////////////////////////////////////////////////////// - #Obtain Install Stage Index - #///////////////////////////////////////////////////////////////////////////////////// - # -3 = first boot / -2 = partition / -1 = filesystem / 0 = run dietpi-software at login / 1 = completed - DIETPI_INSTALL_STAGE=$(cat /DietPi/dietpi/.install_stage) - - #///////////////////////////////////////////////////////////////////////////////////// - #Hardware Details - #///////////////////////////////////////////////////////////////////////////////////// - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) # 0=1(256) 1=1(512) 2=2(1024) - HW_MODEL_DESCRIPTION=$(sed -n 2p /DietPi/dietpi/.hw_model) - HW_ARCH=$(sed -n 6p /DietPi/dietpi/.hw_model) - CPU_CORES_TOTAL=$(nproc --all) - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) - DISTRO_NAME='jessie' - if (( $DISTRO == 4 )); then - - DISTRO_NAME='stretch' - - fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Software' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// #Filepath @@ -74,10 +38,7 @@ FP_DIETPIAUTOMATION_LOG='/root/DietPi-Automation.log' - FP_APT_LOG='/etc/dietpi/logs/dietpi-software_apt.log' - #Used to set user/personal data directories (eg: usbdrive) - FP_DIETPI_USERDATA_DIRECTORY='/mnt/dietpi_userdata' FP_DIETPI_DEDICATED_USBDRIVE='' #Uninstall temp file @@ -155,7 +116,7 @@ _EOF_ fi #Load Software states - /DietPi/dietpi/func/dietpi-notify 2 "Reading database, please wait..." + G_DIETPI-NOTIFY 2 "Reading database, please wait..." #Load if [ -f "$fp_target" ]; then @@ -165,7 +126,7 @@ _EOF_ fi #Always reset choice system during first run to defaults: https://github.com/Fourdee/DietPi/issues/1122 - if (( $DIETPI_INSTALL_STAGE == 0 )); then + if (( $G_DIETPI_INSTALL_STAGE == 0 )); then INDEX_SSHSERVER_CURRENT=-1 INDEX_SSHSERVER_TARGET=-1 @@ -187,7 +148,7 @@ _EOF_ killall -w /DietPi/dietpi/func/run_ntpd &> /dev/null killall -w ntpd &> /dev/null - rm /etc/dietpi/.ntpd_exit_status &> /dev/null + rm /var/lib/dietpi/.ntpd_exit_status &> /dev/null } @@ -202,7 +163,7 @@ _EOF_ if (( $? != 0 )); then # Endless retry - if (( ! $USER_INPUTS )); then + if (( ! $G_USER_INPUTS )); then Reset_NTPD @@ -217,8 +178,8 @@ _EOF_ else Reset_NTPD - echo 0 > /etc/dietpi/.ntpd_exit_status - echo 1 > /etc/dietpi/.ntpd_override + echo 0 > /var/lib/dietpi/.ntpd_exit_status + echo 1 > /var/lib/dietpi/.ntpd_override fi @@ -242,16 +203,8 @@ _EOF_ #Reboot after installation has finished. DISABLE_REBOOT=0 - #Support for apt-fast: https://github.com/Fourdee/DietPi/issues/698 - APT_BINARY='apt-get' - if [ -f /usr/bin/apt-fast ]; then - - APT_BINARY='apt-fast' - - fi - #Global Password: Exception to AUTO first run init. - GLOBAL_PW=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_Global_Password=' | sed 's/.*=//') + GLOBAL_PW=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_GLOBAL_PASSWORD=' | sed 's/.*=//') if [ ! -n "$GLOBAL_PW" ]; then GLOBAL_PW='dietpi' @@ -263,7 +216,7 @@ _EOF_ #Run Installation Flag (1 = run installs) GOSTARTINSTALL=0 - INSTALL_URL_ADDRESS="" + INSTALL_URL_ADDRESS='' INSTALL_DESCRIPTION='DietPi' #Special installation Vars @@ -275,7 +228,7 @@ _EOF_ #PHP5/7 specific directories, apt package-, module- and command names FP_PHP_BASE_DIR='/etc/php/7.0' PHP_APT_PACKAGE_NAME='php' - if (( $DISTRO < 4 )); then + if (( $G_DISTRO < 4 )); then FP_PHP_BASE_DIR='/etc/php5' PHP_APT_PACKAGE_NAME='php5' @@ -325,15 +278,15 @@ _EOF_ TOTAL_SOFTWARE_INDEXS=0 TOTAL_SOFTWARE_INDEXS_HARDLIMIT=171 #Increase as needed. Must be higher than TOTAL_SOFTWARE_INDEXS once calculated in Software_Arrays_Init - INSTALLING_INDEX=0 #Which software index is currently being installed? + INSTALLING_INDEX=0 #Which software index is currently being installed? - aSOFTWARE_CATEGORY_INDEX=0 #Category index - aSOFTWARE_TYPE=0 #0=DietPi 1=Linux | -1=Hidden from install menu, visible in uninstall menu | -2 Hidden from all menus + aSOFTWARE_CATEGORY_INDEX=0 #Category index + aSOFTWARE_TYPE=0 #0=DietPi 1=Linux | -1=Hidden from install menu, visible in uninstall menu | -2 Hidden from all menus - aSOFTWARE_INSTALL_STATE=0 #0=not / 1=tobe, or not tobe that is the... / 2=installed + aSOFTWARE_INSTALL_STATE=0 #0=not / 1=tobe, or not tobe that is the... / 2=installed - aSOFTWARE_WHIP_NAME=0 #Item name eg: Kodi - aSOFTWARE_WHIP_DESC=0 #Blah blah + aSOFTWARE_WHIP_NAME=0 #Item name eg: Kodi + aSOFTWARE_WHIP_DESC=0 #Blah blah FP_ONLINEDOC_URL='http://dietpi.com/phpbb/viewtopic.php?' aSOFTWARE_ONLINEDOC_URL=0 @@ -356,11 +309,11 @@ _EOF_ aSOFTWARE_REQUIRES_NODEJS=0 # - Available for - MAX_HW_MODEL=110 #This needs to match highest HW_MODEL value in dietpi-obtain_hw_model - MAX_HW_ARCH=10 #This needs to match highest HW_ARCH 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 # 2D array (well, bash style) - declare -A aSOFTWARE_AVAIL_HW_MODEL - declare -A aSOFTWARE_AVAIL_HW_ARCH + declare -A aSOFTWARE_AVAIL_G_HW_MODEL + declare -A aSOFTWARE_AVAIL_G_HW_ARCH #///////////////////////////////////////////////////////////////////////////////////// # This function generates the array for all the software avaliable to be installed. @@ -408,9 +361,9 @@ _EOF_ # installations. Full list of models can be found in 'dietpi-obtain_hw_model'. # # # - Disabled for All non-rpi - # for ((i=10; i<=$MAX_HW_MODEL; i++)) + # for ((i=10; i<=$MAX_G_HW_MODEL; i++)) # do - # aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + # aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 # done # # Example: @@ -485,12 +438,12 @@ _EOF_ for ((i=0; i<$TOTAL_SOFTWARE_INDEXS_HARDLIMIT; i++)) do - for ((j=0; j<=$MAX_HW_MODEL; j++)) + for ((j=0; j<=$MAX_G_HW_MODEL; j++)) do - aSOFTWARE_AVAIL_HW_MODEL[$i,$j]=1 + aSOFTWARE_AVAIL_G_HW_MODEL[$i,$j]=1 # ((debug_array_count++)) - # echo -e "$debug_array_count ${aSOFTWARE_AVAIL_HW_MODEL[$i,$j]}" + # echo -e "$debug_array_count ${aSOFTWARE_AVAIL_G_HW_MODEL[$i,$j]}" done @@ -499,12 +452,12 @@ _EOF_ for ((i=0; i<$TOTAL_SOFTWARE_INDEXS_HARDLIMIT; i++)) do - for ((j=0; j<=$MAX_HW_ARCH; j++)) + for ((j=0; j<=$MAX_G_HW_ARCH; j++)) do - aSOFTWARE_AVAIL_HW_ARCH[$i,$j]=1 + aSOFTWARE_AVAIL_G_HW_ARCH[$i,$j]=1 # ((debug_array_count++)) - # echo -e "$debug_array_count ${aSOFTWARE_AVAIL_HW_ARCH[$i,$j]}" + # echo -e "$debug_array_count ${aSOFTWARE_AVAIL_G_HW_ARCH[$i,$j]}" done @@ -606,10 +559,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='http://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=3011#p3011' # - ARMv6 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,1]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,1]=0 # - VM - aSOFTWARE_AVAIL_HW_MODEL[$index_current,20]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,20]=0 #Remote Desktops #-------------------------------------------------------------------------------- @@ -623,15 +576,15 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=30#p408' # - ARMv8 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,3]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,3]=0 # - Disable for Stretch, replaced by tigervnc (vnc4) - if (( $DISTRO >= 4 )); then + if (( $G_DISTRO >= 4 )); then - for ((i=0; i<$MAX_HW_MODEL; i++)) + for ((i=0; i<$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -668,7 +621,7 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=60#p2071' # - ARMv8 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,3]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,3]=0 #------------------ index_current=120 @@ -681,10 +634,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=4149#p4149' # - License RPi only - for ((i=10; i<$MAX_HW_MODEL; i++)) + for ((i=10; i<$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -701,10 +654,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5#p43' # - Disabled for All non-RPi/Odroid boards - for ((i=20; i<$MAX_HW_MODEL; i++)) + for ((i=20; i<$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -729,7 +682,7 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=3928#p3928' # - X86_64 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,10]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,10]=0 #------------------ index_current=33 @@ -787,7 +740,7 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=1221#p1221' # - x86_64 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,10]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,10]=0 #------------------ index_current=38 @@ -800,10 +753,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=57#p57' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -842,10 +795,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=1789#p1789' #disable ARMv6: https://github.com/Fourdee/DietPi/issues/534 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,1]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,1]=0 #disable ARMv8: https://github.com/Fourdee/DietPi/issues/1059#issuecomment-313661959 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,3]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,3]=0 #------------------ index_current=42 @@ -857,7 +810,7 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=1949#p1949' #disable ARMv6: https://github.com/Fourdee/DietPi/issues/648 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,1]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,1]=0 #------------------ index_current=43 @@ -889,10 +842,10 @@ _EOF_ aSOFTWARE_REQUIRES_ALSA[$index_current]=1 # - Currently ARMv7/64 only, so disable all archs - for ((i=0; i<=$MAX_HW_ARCH; i++)) + for ((i=0; i<=$MAX_G_HW_ARCH; i++)) do - aSOFTWARE_AVAIL_HW_ARCH[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,$i]=0 done @@ -900,7 +853,7 @@ _EOF_ for ((i=2; i<=10; i++)) do - aSOFTWARE_AVAIL_HW_ARCH[$index_current,$i]=1 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,$i]=1 done @@ -915,15 +868,15 @@ _EOF_ aSOFTWARE_REQUIRES_ALSA[$index_current]=1 # - Currently ARMv7+ only, so disable all archs - for ((i=0; i<=$MAX_HW_ARCH; i++)) + for ((i=0; i<=$MAX_G_HW_ARCH; i++)) do - aSOFTWARE_AVAIL_HW_ARCH[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,$i]=0 done # renable for armv7+ - aSOFTWARE_AVAIL_HW_ARCH[$index_current,2]=1 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,2]=1 #------------------ index_current=128 @@ -948,7 +901,7 @@ _EOF_ aSOFTWARE_REQUIRES_MYSQL[$index_current]=1 # - VM - aSOFTWARE_AVAIL_HW_MODEL[$index_current,20]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,20]=0 #------------------ index_current=135 @@ -961,7 +914,7 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=6526#p6526' # - VM - aSOFTWARE_AVAIL_HW_MODEL[$index_current,20]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,20]=0 #------------------ index_current=141 @@ -974,15 +927,15 @@ _EOF_ aSOFTWARE_REQUIRES_ALSA[$index_current]=1 # - Currently ARMv7+ only, so disable all archs - for ((i=0; i<=$MAX_HW_ARCH; i++)) + for ((i=0; i<=$MAX_G_HW_ARCH; i++)) do - aSOFTWARE_AVAIL_HW_ARCH[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,$i]=0 done # renable for armv7+ - aSOFTWARE_AVAIL_HW_ARCH[$index_current,2]=1 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,2]=1 #------------------ index_current=143 @@ -1009,7 +962,7 @@ _EOF_ aSOFTWARE_REQUIRES_GIT[$index_current]=1 # - Disabled for ARM64 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,3]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,3]=0 #------------------ @@ -1024,10 +977,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=110#p7536' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1043,14 +996,14 @@ _EOF_ aSOFTWARE_REQUIRES_FFMPEG[$index_current]=1 # - x86_64 - for ((i=0; i<=$MAX_HW_ARCH; i++)) + for ((i=0; i<=$MAX_G_HW_ARCH; i++)) do - aSOFTWARE_AVAIL_HW_ARCH[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,$i]=0 done - aSOFTWARE_AVAIL_HW_ARCH[$index_current,10]=1 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,10]=1 #------------------ index_current=159 @@ -1094,10 +1047,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=9368#p9368' #disable ARMv8: - aSOFTWARE_AVAIL_HW_ARCH[$index_current,3]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,3]=0 #disable x86_64: - aSOFTWARE_AVAIL_HW_ARCH[$index_current,10]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,10]=0 #------------------ index_current=168 @@ -1114,10 +1067,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='xxxxxxxxxxxxxxxxx' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1292,7 +1245,7 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=65#p65' #No deb packages for ARMv6: - aSOFTWARE_AVAIL_HW_ARCH[$index_current,1]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,1]=0 #------------------ index_current=49 @@ -1306,7 +1259,7 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=70#p2187' # - ARMv8 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,3]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,3]=0 #------------------ index_current=50 @@ -1327,10 +1280,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=6476#p6476' # - ARMv6 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,1]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,1]=0 # - ARMv8 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,3]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,3]=0 #------------------ index_current=158 @@ -1347,10 +1300,10 @@ _EOF_ aSOFTWARE_TYPE[$index_current]=0 # - x86_64 - #aSOFTWARE_AVAIL_HW_ARCH[$index_current,10]=0 + #aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,10]=0 # - ARMv8 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,3]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,3]=0 #------------------ index_current=165 @@ -1377,10 +1330,10 @@ _EOF_ aSOFTWARE_REQUIRES_XSERVERXORG[$index_current]=1 # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1396,10 +1349,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5#p45' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1414,10 +1367,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=2963#p2963' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1431,7 +1384,7 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=60#p2068' # - ARMv8 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,3]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,3]=0 #------------------ index_current=53 @@ -1459,14 +1412,14 @@ _EOF_ aSOFTWARE_REQUIRES_DESKTOP[$index_current]=1 #Native PC only - for ((i=0; i<=$MAX_HW_MODEL; i++)) + for ((i=0; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done - aSOFTWARE_AVAIL_HW_MODEL[$index_current,21]=1 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,21]=1 #------------------ index_current=164 @@ -1555,10 +1508,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5#p48' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1573,10 +1526,10 @@ _EOF_ aSOFTWARE_REQUIRES_FFMPEG[$index_current]=1 # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1593,7 +1546,7 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=1207#p1207' # - VM - aSOFTWARE_AVAIL_HW_MODEL[$index_current,20]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,20]=0 #------------------ index_current=61 @@ -1605,7 +1558,7 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=1529#p1529' # - VM - aSOFTWARE_AVAIL_HW_MODEL[$index_current,20]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,20]=0 #------------------ @@ -1659,10 +1612,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=50#p1503' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1676,10 +1629,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=20#p89' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1713,7 +1666,7 @@ _EOF_ aSOFTWARE_TYPE[$index_current]=0 # - ARMv8 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,3]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,3]=0 #Remote Access #-------------------------------------------------------------------------------- @@ -1735,16 +1688,16 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=20#p188' # - Currently ARMv7+ only, so disable all archs - for ((i=0; i<=$MAX_HW_ARCH; i++)) + for ((i=0; i<=$MAX_G_HW_ARCH; i++)) do - aSOFTWARE_AVAIL_HW_ARCH[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,$i]=0 done # renable for armv6/7 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,1]=1 - aSOFTWARE_AVAIL_HW_ARCH[$index_current,2]=1 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,1]=1 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,2]=1 #------------------ index_current=138 @@ -1768,10 +1721,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=40#p1065' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1786,15 +1739,15 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=1066#p1066' # - RPi / Odroids - for ((i=20; i<=$MAX_HW_MODEL; i++)) + for ((i=20; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done #+ BPi Pro - aSOFTWARE_AVAIL_HW_MODEL[$index_current,51]=1 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,51]=1 #------------------ index_current=71 @@ -1807,10 +1760,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=20#p189' # - Disabled for All non-rpi and RPi3 - for ((i=3; i<=$MAX_HW_MODEL; i++)) + for ((i=3; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1823,10 +1776,10 @@ _EOF_ aSOFTWARE_TYPE[$index_current]=0 # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1872,10 +1825,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=9359#p9359' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1891,10 +1844,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=9486#p9486' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -1912,15 +1865,6 @@ _EOF_ #Webserver stacks #-------------------------------------------------------------------------------- - index_current=74 - - aSOFTWARE_WHIP_NAME[$index_current]='LAMP' - aSOFTWARE_WHIP_DESC[$index_current]='apache2 | mysql | php' - aSOFTWARE_CATEGORY_INDEX[$index_current]=13 - aSOFTWARE_TYPE[$index_current]=0 - aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=10#p52' - - #------------------ index_current=75 aSOFTWARE_WHIP_NAME[$index_current]='LASP' @@ -1938,15 +1882,6 @@ _EOF_ aSOFTWARE_TYPE[$index_current]=0 aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=10#p52' - #------------------ - index_current=77 - - aSOFTWARE_WHIP_NAME[$index_current]='LEMP' - aSOFTWARE_WHIP_DESC[$index_current]='nginx | mysql | php' - aSOFTWARE_CATEGORY_INDEX[$index_current]=13 - aSOFTWARE_TYPE[$index_current]=0 - aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5#p5' - #------------------ index_current=78 @@ -1965,15 +1900,6 @@ _EOF_ aSOFTWARE_TYPE[$index_current]=0 aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5#p5' - #------------------ - index_current=80 - - aSOFTWARE_WHIP_NAME[$index_current]='LLMP' - aSOFTWARE_WHIP_DESC[$index_current]='lighttpd | mysql | php' - aSOFTWARE_CATEGORY_INDEX[$index_current]=13 - aSOFTWARE_TYPE[$index_current]=0 - aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=1335#p1335' - #------------------ index_current=81 @@ -2019,15 +1945,6 @@ _EOF_ aSOFTWARE_TYPE[$index_current]=-1 aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5#p5' - #------------------ - index_current=86 - - aSOFTWARE_WHIP_NAME[$index_current]='MySQL' - aSOFTWARE_WHIP_DESC[$index_current]='database' - aSOFTWARE_CATEGORY_INDEX[$index_current]=13 - aSOFTWARE_TYPE[$index_current]=-1 - aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=1335#p1335' - #------------------ index_current=87 @@ -2194,10 +2111,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&p=1529#p1525' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -2213,10 +2130,10 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=20#p70' # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -2230,7 +2147,6 @@ _EOF_ aSOFTWARE_REQUIRES_GIT[$index_current]=1 aSOFTWARE_REQUIRES_BUILDESSENTIAL[$index_current]=1 aSOFTWARE_REQUIRES_SQLITE[$index_current]=1 - aSOFTWARE_REQUIRES_MYSQL[$index_current]=1 aSOFTWARE_REQUIRES_FFMPEG[$index_current]=1 aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=20#p70' @@ -2248,9 +2164,9 @@ _EOF_ aSOFTWARE_REQUIRES_RSYSLOG[$index_current]=1 #Not required, but comes in as package dep #Disabled for ARMv8 on Jessie only: https://github.com/Fourdee/DietPi/issues/855#issuecomment-292712002 - if (( $DISTRO == 3 )); then + if (( $G_DISTRO == 3 )); then - aSOFTWARE_AVAIL_HW_ARCH[$index_current,3]=0 + aSOFTWARE_AVAIL_G_HW_ARCH[$index_current,3]=0 fi @@ -2348,14 +2264,14 @@ _EOF_ aSOFTWARE_TYPE[$index_current]=1 aSOFTWARE_REQUIRES_XSERVERXORG[$index_current]=1 - for ((i=0; i<$MAX_HW_MODEL; i++)) + for ((i=0; i<$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done - aSOFTWARE_AVAIL_HW_MODEL[$index_current,21]=1 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,21]=1 #------------------ index_current=170 @@ -2377,7 +2293,7 @@ _EOF_ index_current=8 aSOFTWARE_WHIP_NAME[$index_current]='Java' - aSOFTWARE_WHIP_DESC[$index_current]='oracle java 8 jdk/jre libary' + aSOFTWARE_WHIP_DESC[$index_current]='OpenJDK 8 + JRE libary' aSOFTWARE_CATEGORY_INDEX[$index_current]=4 aSOFTWARE_TYPE[$index_current]=1 #------------------ @@ -2403,10 +2319,10 @@ _EOF_ aSOFTWARE_TYPE[$index_current]=1 # - Disabled for All non-rpi - for ((i=10; i<=$MAX_HW_MODEL; i++)) + for ((i=10; i<=$MAX_G_HW_MODEL; i++)) do - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$i]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$i]=0 done @@ -2526,9 +2442,9 @@ _EOF_ aSOFTWARE_TYPE[$index_current]=1 # - Stretch only - if (( $DISTRO < 4 )); then + if (( $G_DISTRO < 4 )); then - aSOFTWARE_AVAIL_HW_MODEL[$index_current,$HW_MODEL]=0 + aSOFTWARE_AVAIL_G_HW_MODEL[$index_current,$G_HW_MODEL]=0 fi @@ -2594,6 +2510,29 @@ _EOF_ aSOFTWARE_ONLINEDOC_URL[$index_current]='f=8&t=5&start=10#p63' #------------------ + #-------------------------------------------------------------------------------- + #Free indexes (due to removal of MySQL) + #-------------------------------------------------------------------------------- + index_current=74 + aSOFTWARE_WHIP_NAME[$index_current]='free index' + aSOFTWARE_WHIP_DESC[$index_current]='' + aSOFTWARE_CATEGORY_INDEX[$index_current]=0 + aSOFTWARE_TYPE[$index_current]=-1 + index_current=77 + aSOFTWARE_WHIP_NAME[$index_current]='free index' + aSOFTWARE_WHIP_DESC[$index_current]='' + aSOFTWARE_CATEGORY_INDEX[$index_current]=0 + aSOFTWARE_TYPE[$index_current]=-1 + index_current=80 + aSOFTWARE_WHIP_NAME[$index_current]='free index' + aSOFTWARE_WHIP_DESC[$index_current]='' + aSOFTWARE_CATEGORY_INDEX[$index_current]=0 + aSOFTWARE_TYPE[$index_current]=-1 + index_current=86 + aSOFTWARE_WHIP_NAME[$index_current]='free index' + aSOFTWARE_WHIP_DESC[$index_current]='' + aSOFTWARE_CATEGORY_INDEX[$index_current]=0 + aSOFTWARE_TYPE[$index_current]=-1 #-------------------------------------------------------------------------------- #Total software installations @@ -2641,27 +2580,27 @@ _EOF_ unset aSOFTWARE_REQUIRES_ORACLEJAVA unset aSOFTWARE_REQUIRES_NODEJS - unset aSOFTWARE_AVAIL_HW_MODEL - unset aSOFTWARE_AVAIL_HW_ARCH + unset aSOFTWARE_AVAIL_G_HW_MODEL + unset aSOFTWARE_AVAIL_G_HW_ARCH } #Disable software installation, if user input is required for automated installs Install_Disable_Requires_UserInput(){ - if (( ! $USER_INPUTS )); then + if (( ! $G_USER_INPUTS )); then for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++)) do - if (( ${aSOFTWARE_REQUIRES_USERINPUT[$i]} && - ${aSOFTWARE_INSTALL_STATE[$i]} == 1 )); then + if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 1 && + ${aSOFTWARE_REQUIRES_USERINPUT[$i]} )); then # - Disable aSOFTWARE_INSTALL_STATE[$i]=0 - /DietPi/dietpi/func/dietpi-notify 2 "${aSOFTWARE_WHIP_NAME[$i]}: Requires user input and can not be automated." - /DietPi/dietpi/func/dietpi-notify 1 "${aSOFTWARE_WHIP_NAME[$i]}: Will not be installed. Please run 'dietpi-software' to install." + G_DIETPI-NOTIFY 2 "${aSOFTWARE_WHIP_NAME[$i]}: Requires user input and can not be automated." + G_DIETPI-NOTIFY 1 "${aSOFTWARE_WHIP_NAME[$i]}: Will not be installed. Please run 'dietpi-software' to install." fi @@ -2674,7 +2613,7 @@ _EOF_ #Work out which additional software we need to install Install_Flag_Prereq_Software(){ - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Software "Checking for prerequisite software" + G_DIETPI-NOTIFY 3 DietPi-Software "Checking for prerequisite software" #------------------------------------------------------------------------- #Pre-req software, for items that do not have their own array aSOFTWARE_REQUIRES_SOFTWARENAME @@ -2694,16 +2633,15 @@ _EOF_ aSOFTWARE_INSTALL_STATE[36]=1 # Squeezelite aSOFTWARE_INSTALL_STATE[37]=1 # Shairport Sync - if (( $HW_MODEL == 70 )); then + # if (( $G_HW_MODEL == 70 )); then - aSOFTWARE_INSTALL_STATE[60]=1 # WiFi Hotspot + # aSOFTWARE_INSTALL_STATE[60]=1 # WiFi Hotspot - fi + # fi aSOFTWARE_INSTALL_STATE[65]=1 # Netdata aSOFTWARE_INSTALL_STATE[96]=1 # Samba - #aSOFTWARE_INSTALL_STATE[80]=1 # LLMP aSOFTWARE_INSTALL_STATE[121]=1 # Roon Bridge aSOFTWARE_INSTALL_STATE[124]=1 # NAA Daemon #aSOFTWARE_INSTALL_STATE[128]=1 # MPD @@ -2720,16 +2658,16 @@ _EOF_ #aSOFTWARE_INSTALL_STATE[37]=1 # Shairport Sync # Disabled/optional #aSOFTWARE_INSTALL_STATE[60]=1 # WiFi Hotspot # Installed as per moOde docs - /DietPi/dietpi/func/dietpi-notify 2 "${aSOFTWARE_WHIP_NAME[128]} will be installed" + G_DIETPI-NOTIFY 2 "${aSOFTWARE_WHIP_NAME[128]} will be installed" aSOFTWARE_INSTALL_STATE[128]=1 # MPD - /DietPi/dietpi/func/dietpi-notify 2 "${aSOFTWARE_WHIP_NAME[78]} will be installed" + G_DIETPI-NOTIFY 2 "${aSOFTWARE_WHIP_NAME[78]} will be installed" aSOFTWARE_INSTALL_STATE[78]=1 # LESP, override user choice for now. - /DietPi/dietpi/func/dietpi-notify 2 "${aSOFTWARE_WHIP_NAME[1]} will be installed" + G_DIETPI-NOTIFY 2 "${aSOFTWARE_WHIP_NAME[1]} will be installed" aSOFTWARE_INSTALL_STATE[1]=1 # Samba Client - /DietPi/dietpi/func/dietpi-notify 2 "${aSOFTWARE_WHIP_NAME[96]} will be installed" + G_DIETPI-NOTIFY 2 "${aSOFTWARE_WHIP_NAME[96]} will be installed" aSOFTWARE_INSTALL_STATE[96]=1 # Samba Server fi @@ -2756,7 +2694,7 @@ _EOF_ aSOFTWARE_INSTALL_STATE[$index]=1 #aSOFTWARE_WHIP_NAME - /DietPi/dietpi/func/dietpi-notify 2 "${aSOFTWARE_WHIP_NAME[$index]} will be installed" + G_DIETPI-NOTIFY 2 "${aSOFTWARE_WHIP_NAME[$index]} will be installed" fi @@ -2772,7 +2710,7 @@ _EOF_ aSOFTWARE_INSTALL_STATE[150]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Mono runtime libary will be installed" + G_DIETPI-NOTIFY 2 "Mono runtime libary will be installed" fi @@ -2785,7 +2723,7 @@ _EOF_ aSOFTWARE_INSTALL_STATE[140]=1 - /DietPi/dietpi/func/dietpi-notify 2 "SDL2 will be installed" + G_DIETPI-NOTIFY 2 "SDL2 will be installed" fi @@ -2805,7 +2743,7 @@ _EOF_ aSOFTWARE_INSTALL_STATE[130]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Python-Pip will be installed" + G_DIETPI-NOTIFY 2 "Python-Pip will be installed" fi @@ -2824,7 +2762,7 @@ _EOF_ # - Flag for install aSOFTWARE_INSTALL_STATE[128]=1 - /DietPi/dietpi/func/dietpi-notify 2 "MPD will be installed" + G_DIETPI-NOTIFY 2 "MPD will be installed" fi @@ -2838,7 +2776,7 @@ _EOF_ aSOFTWARE_INSTALL_STATE[94]=1 - /DietPi/dietpi/func/dietpi-notify 2 "ProFTP will be installed" + G_DIETPI-NOTIFY 2 "ProFTP will be installed" fi @@ -2847,7 +2785,7 @@ _EOF_ aSOFTWARE_INSTALL_STATE[96]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Samba Server will be installed" + G_DIETPI-NOTIFY 2 "Samba Server will be installed" fi @@ -2861,7 +2799,7 @@ _EOF_ aSOFTWARE_INSTALL_STATE[91]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Redis will be installed" + G_DIETPI-NOTIFY 2 "Redis will be installed" fi @@ -2885,13 +2823,6 @@ _EOF_ aSOFTWARE_INSTALL_STATE[89]=1 fi - #LLMP - if (( ${aSOFTWARE_INSTALL_STATE[80]} == 1 )); then - aSOFTWARE_INSTALL_STATE[84]=1 - aSOFTWARE_INSTALL_STATE[86]=1 - aSOFTWARE_INSTALL_STATE[89]=1 - fi - #LEAP if (( ${aSOFTWARE_INSTALL_STATE[79]} == 1 )); then aSOFTWARE_INSTALL_STATE[85]=1 @@ -2906,13 +2837,6 @@ _EOF_ aSOFTWARE_INSTALL_STATE[89]=1 fi - #LEMP - if (( ${aSOFTWARE_INSTALL_STATE[77]} == 1 )); then - aSOFTWARE_INSTALL_STATE[85]=1 - aSOFTWARE_INSTALL_STATE[86]=1 - aSOFTWARE_INSTALL_STATE[89]=1 - fi - #LAAP if (( ${aSOFTWARE_INSTALL_STATE[76]} == 1 )); then aSOFTWARE_INSTALL_STATE[83]=1 @@ -2927,13 +2851,6 @@ _EOF_ aSOFTWARE_INSTALL_STATE[89]=1 fi - #LAMP - if (( ${aSOFTWARE_INSTALL_STATE[74]} == 1 )); then - aSOFTWARE_INSTALL_STATE[83]=1 - aSOFTWARE_INSTALL_STATE[86]=1 - aSOFTWARE_INSTALL_STATE[89]=1 - fi - #WEBSERVER - Auto install via choice system for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++)) do @@ -2952,25 +2869,25 @@ _EOF_ #WEBSERVER_APACHE aSOFTWARE_INSTALL_STATE[83]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Apache2 will be installed" + G_DIETPI-NOTIFY 2 "Apache2 will be installed" elif (( $INDEX_WEBSERVER_TARGET == -1 )); then #WEBSERVER_NGINX aSOFTWARE_INSTALL_STATE[85]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Nginx will be installed" + G_DIETPI-NOTIFY 2 "Nginx will be installed" elif (( $INDEX_WEBSERVER_TARGET == -2 )); then #WEBSERVER_LIGHTTPD aSOFTWARE_INSTALL_STATE[84]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Lighttpd will be installed" + G_DIETPI-NOTIFY 2 "Lighttpd will be installed" fi # - Always install WEBSERVER_PHP aSOFTWARE_INSTALL_STATE[89]=1 - /DietPi/dietpi/func/dietpi-notify 2 "PHP will be installed" + G_DIETPI-NOTIFY 2 "PHP will be installed" fi @@ -2987,14 +2904,13 @@ _EOF_ if (( ${aSOFTWARE_REQUIRES_MYSQL[$i]} && ${aSOFTWARE_INSTALL_STATE[$i]} == 1 )); then - # - Check for existing mysql/mariaDB installations - if (( ! ${aSOFTWARE_INSTALL_STATE[86]} && - ! ${aSOFTWARE_INSTALL_STATE[88]} )); then + # - Check for existing MariaDB installations + if (( ! ${aSOFTWARE_INSTALL_STATE[88]} )); then - #WEBSERVER_MYSQL - aSOFTWARE_INSTALL_STATE[86]=1 + #WEBSERVER_MARIADB as new default + aSOFTWARE_INSTALL_STATE[88]=1 - /DietPi/dietpi/func/dietpi-notify 2 "MySQL will be installed" + G_DIETPI-NOTIFY 2 "MariaDB will be installed" fi @@ -3014,7 +2930,7 @@ _EOF_ #WEBSERVER_SQLITE aSOFTWARE_INSTALL_STATE[87]=1 - /DietPi/dietpi/func/dietpi-notify 2 "SQlite will be installed" + G_DIETPI-NOTIFY 2 "SQlite will be installed" break @@ -3026,14 +2942,6 @@ _EOF_ #WEBSERVER_APACHE if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then - #MySQL - if (( ${aSOFTWARE_INSTALL_STATE[86]} >= 1 )); then - - #WEBSERVER_LAMP - aSOFTWARE_INSTALL_STATE[74]=1 - - fi - #SQLite if (( ${aSOFTWARE_INSTALL_STATE[87]} >= 1 )); then @@ -3054,14 +2962,6 @@ _EOF_ #WEBSERVER_NGINX elif (( ${aSOFTWARE_INSTALL_STATE[85]} >= 1 )); then - #MySQL - if (( ${aSOFTWARE_INSTALL_STATE[86]} >= 1 )); then - - #WEBSERVER_LEMP - aSOFTWARE_INSTALL_STATE[77]=1 - - fi - #SQLite if (( ${aSOFTWARE_INSTALL_STATE[87]} >= 1 )); then @@ -3081,14 +2981,6 @@ _EOF_ #WEBSERVER_LIGHTTPD elif (( ${aSOFTWARE_INSTALL_STATE[84]} >= 1 )); then - #MySQL - if (( ${aSOFTWARE_INSTALL_STATE[86]} >= 1 )); then - - #WEBSERVER_LLMP - aSOFTWARE_INSTALL_STATE[80]=1 - - fi - #SQLite if (( ${aSOFTWARE_INSTALL_STATE[87]} >= 1 )); then @@ -3108,31 +3000,6 @@ _EOF_ fi - #Prevent incompatible MySQL + MariaDB installation: https://github.com/Fourdee/DietPi/issues/761#issuecomment-280848758 - if (( ${aSOFTWARE_INSTALL_STATE[86]} >= 1 && ${aSOFTWARE_INSTALL_STATE[88]} >= 1 )); then - - # MySQL installed - if (( ${aSOFTWARE_INSTALL_STATE[86]} == 2 )); then - - aSOFTWARE_INSTALL_STATE[88]=0 - /DietPi/dietpi/func/dietpi-notify 2 "MySQL is already installed, MariaDB install has been disabled" - - # MariaDB installed - elif (( ${aSOFTWARE_INSTALL_STATE[88]} == 2 )); then - - aSOFTWARE_INSTALL_STATE[86]=0 - /DietPi/dietpi/func/dietpi-notify 2 "MariaDB is already installed, MySQL install has been disabled" - - # Both selected for install, disable Maria - else - - aSOFTWARE_INSTALL_STATE[88]=0 - /DietPi/dietpi/func/dietpi-notify 2 "MySQL and MariaDB are selected for install. MariaDB has been de-selected to prevent incompatible MySQL + MariaDB installation" - - fi - - fi - #DESKTOP for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++)) do @@ -3147,7 +3014,7 @@ _EOF_ ! ${aSOFTWARE_INSTALL_STATE[26]} )); then aSOFTWARE_INSTALL_STATE[23]=1 - /DietPi/dietpi/func/dietpi-notify 2 "LXDE desktop will be installed" + G_DIETPI-NOTIFY 2 "LXDE desktop will be installed" fi @@ -3167,7 +3034,7 @@ _EOF_ # - Flag for install aSOFTWARE_INSTALL_STATE[17]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Git will be installed" + G_DIETPI-NOTIFY 2 "Git will be installed" break @@ -3185,7 +3052,7 @@ _EOF_ # - Flag for install aSOFTWARE_INSTALL_STATE[16]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Build-Essential will be installed" + G_DIETPI-NOTIFY 2 "Build-Essential will be installed" break @@ -3203,7 +3070,7 @@ _EOF_ # - Flag for install aSOFTWARE_INSTALL_STATE[102]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Rsyslog will be installed" + G_DIETPI-NOTIFY 2 "Rsyslog will be installed" break @@ -3221,7 +3088,7 @@ _EOF_ # - Flag for install aSOFTWARE_INSTALL_STATE[7]=1 - /DietPi/dietpi/func/dietpi-notify 2 "FFmpeg will be installed" + G_DIETPI-NOTIFY 2 "FFmpeg will be installed" break @@ -3239,7 +3106,7 @@ _EOF_ # - Flag for install aSOFTWARE_INSTALL_STATE[8]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Oracle Java will be installed" + G_DIETPI-NOTIFY 2 "OpenJDK 8 will be installed" break @@ -3257,7 +3124,7 @@ _EOF_ # - Flag for install aSOFTWARE_INSTALL_STATE[9]=1 - /DietPi/dietpi/func/dietpi-notify 2 "NodeJS will be installed" + G_DIETPI-NOTIFY 2 "NodeJS will be installed" break @@ -3275,7 +3142,7 @@ _EOF_ # - Flag for install aSOFTWARE_INSTALL_STATE[5]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Alsa will be installed" + G_DIETPI-NOTIFY 2 "Alsa will be installed" break @@ -3293,7 +3160,7 @@ _EOF_ # - Flag for install aSOFTWARE_INSTALL_STATE[6]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Xserver will be installed" + G_DIETPI-NOTIFY 2 "Xserver will be installed" break @@ -3332,11 +3199,14 @@ _EOF_ ln -sf /usr/share/applications/dietpi-launcher.desktop "$HOME"/Desktop/dietpi-launcher.desktop #Download icons - mkdir -p /etc/dietpi/desktop_icons - wget http://dietpi.com/downloads/conf/desktop/dietpi-icon.png -O /etc/dietpi/desktop_icons/dietpi-icon.png - wget http://dietpi.com/downloads/conf/desktop/grey_16x16.png -O /etc/dietpi/desktop_icons/grey_16x16.png - wget http://dietpi.com/downloads/conf/desktop/kodi-icon.png -O /etc/dietpi/desktop_icons/kodi-icon.png - wget http://dietpi.com/downloads/conf/desktop/justboom.png -O /etc/dietpi/desktop_icons/justboom.png + mkdir -p /var/lib/dietpi/dietpi-software/installed/desktop_icons + wget http://dietpi.com/downloads/conf/desktop/dietpi-icon.png -O /var/lib/dietpi/dietpi-software/installed/desktop_icons/dietpi-icon.png + wget http://dietpi.com/downloads/conf/desktop/grey_16x16.png -O /var/lib/dietpi/dietpi-software/installed/desktop_icons/grey_16x16.png + wget http://dietpi.com/downloads/conf/desktop/kodi-icon.png -O /var/lib/dietpi/dietpi-software/installed/desktop_icons/kodi-icon.png + wget http://dietpi.com/downloads/conf/desktop/justboom.png -O /var/lib/dietpi/dietpi-software/installed/desktop_icons/justboom.png + + # - Replace icon dir in .desktop from /etc/dietpi/desktop_icons + sed -i 's#^Icon=/etc/dietpi/desktop_icons#Icon=/var/lib/dietpi/dietpi-software/installed/desktop_icons#g' /usr/share/applications/*.desktop # - Set execute to prevent "untrusted" prompt in Mate, and possibily other desktops. chmod +x /usr/share/applications/* @@ -3346,80 +3216,26 @@ _EOF_ Create_UserContent_Folders(){ - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/"$FOLDER_MUSIC" - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/"$FOLDER_PICTURES" - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/"$FOLDER_VIDEO" - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/"$FOLDER_DOWNLOADS" + mkdir -p "$G_FP_DIETPI_USERDATA"/"$FOLDER_MUSIC" + mkdir -p "$G_FP_DIETPI_USERDATA"/"$FOLDER_PICTURES" + mkdir -p "$G_FP_DIETPI_USERDATA"/"$FOLDER_VIDEO" + mkdir -p "$G_FP_DIETPI_USERDATA"/"$FOLDER_DOWNLOADS" } Download_Test_Media(){ - if [ ! -f "$FP_DIETPI_USERDATA_DIRECTORY/$FOLDER_MUSIC"/fourdee_tech.ogg ]; then + if [ ! -f "$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC"/fourdee_tech.ogg ]; then #Grab My test music - wget http://dietpi.com/downloads/audio/fourdee_tech.ogg -O "$FP_DIETPI_USERDATA_DIRECTORY/$FOLDER_MUSIC"/fourdee_tech.ogg - #wget http://dietpi.com/downloads/audio/fourdee_space.mp3 -O "$FP_DIETPI_USERDATA_DIRECTORY/$FOLDER_MUSIC"/fourdee_space.mp3 + wget http://dietpi.com/downloads/audio/fourdee_tech.ogg -O "$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC"/fourdee_tech.ogg + #wget http://dietpi.com/downloads/audio/fourdee_space.mp3 -O "$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC"/fourdee_space.mp3 #Grab Absolute Radio Streams - wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=vrbb -O "$FP_DIETPI_USERDATA_DIRECTORY/$FOLDER_MUSIC"/Absolute-Radio.pls - wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=a8bb -O "$FP_DIETPI_USERDATA_DIRECTORY/$FOLDER_MUSIC"/Absolute-Radio-80s.pls - wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=a9bb -O "$FP_DIETPI_USERDATA_DIRECTORY/$FOLDER_MUSIC"/Absolute-Radio-90s.pls - wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=a0bb -O "$FP_DIETPI_USERDATA_DIRECTORY/$FOLDER_MUSIC"/Absolute-Radio-00s.pls - - fi - - } - - #apt-get install - AGI(){ - - local string="$@" - - local force_options='--force-yes' - - if (( $DISTRO >= 4 )); then - - force_options='--allow-downgrades --allow-remove-essential --allow-change-held-packages --allow-unauthenticated' - - fi - - #-qq can add a slight period of appearing nothing is happening, lets inform user - /DietPi/dietpi/func/dietpi-notify 2 "APT is processing, please wait...\n" - DEBIAN_FRONTEND=noninteractive $APT_BINARY install -y -qq $force_options $string 2>&1 | tee "$FP_APT_LOG" - - local result=${PIPESTATUS[0]} - if (( $result != 0 )); then - - Error_AptGet_Failed - - fi - - } - - #apt-get purge - AGP(){ - - local string="$@" - if (( $DISTRO >= 4 )); then - - string+=' --allow-change-held-packages' - - fi - - $APT_BINARY purge -y $string - - } - - #apt-get install -f - AGF(){ - - DEBIAN_FRONTEND=noninteractive $APT_BINARY install -f -y $force_options 2>&1 | tee "$FP_APT_LOG" - - local result=${PIPESTATUS[0]} - if (( $result != 0 )); then - - Error_AptGet_Failed + wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=vrbb -O "$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC"/Absolute-Radio.pls + wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=a8bb -O "$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC"/Absolute-Radio-80s.pls + wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=a9bb -O "$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC"/Absolute-Radio-90s.pls + wget http://network.absoluteradio.co.uk/core/audio/ogg/live.pls?service=a0bb -O "$G_FP_DIETPI_USERDATA/$FOLDER_MUSIC"/Absolute-Radio-00s.pls fi @@ -3432,7 +3248,7 @@ _EOF_ local gigabit_device=1 # - Lets hope the next RPi device is finally gigabit capable. I'll cry if it is not. - if (( $HW_MODEL <= 3 || $HW_MODEL == 30 || $HW_MODEL == 32 || $HW_MODEL == 40 || $HW_MODEL == 60 || $HW_MODEL == 70 )); then + if (( $G_HW_MODEL <= 3 || $G_HW_MODEL == 30 || $G_HW_MODEL == 32 || $G_HW_MODEL == 40 || $G_HW_MODEL == 60 || $G_HW_MODEL == 70 )); then gigabit_device=0 @@ -3449,7 +3265,7 @@ _EOF_ output=2 # - Bump up for VM's - if (( $HW_MODEL == 20 || $HW_MODEL == 21 )); then + if (( $G_HW_MODEL == 20 || $G_HW_MODEL == 21 )); then output=3 @@ -3461,7 +3277,7 @@ _EOF_ output=20 # - Bump up for VM's - if (( $HW_MODEL == 20 || $HW_MODEL == 21 )); then + if (( $G_HW_MODEL == 20 || $G_HW_MODEL == 21 )); then output=40 @@ -3472,17 +3288,17 @@ _EOF_ # - Reduce for RPi's. This is due to the USB bus ethernet in the ARM SoC, which cripples network throughput/performance/latency. # - RPi v3 - elif (( $HW_MODEL == 3 )); then + elif (( $G_HW_MODEL == 3 )); then output=15 # - RPi v2 - elif (( $HW_MODEL == 2 )); then + elif (( $G_HW_MODEL == 2 )); then output=13 # - RPi v1 256/512 - elif (( $HW_MODEL <= 1 )); then + elif (( $G_HW_MODEL <= 1 )); then output=7 @@ -3494,7 +3310,7 @@ _EOF_ output=3 # - Bump up for VM's - if (( $HW_MODEL == 20 || $HW_MODEL == 21 )); then + if (( $G_HW_MODEL == 20 || $G_HW_MODEL == 21 )); then output=5 @@ -3504,7 +3320,7 @@ _EOF_ output=4 # - Reduce for RPi's. This is due to the USB bus ethernet in the ARM SoC, which cripples network throughput/performance/latency. - elif (( $HW_MODEL <= 3 )); then + elif (( $G_HW_MODEL <= 3 )); then output=2 @@ -3541,24 +3357,19 @@ _EOF_ # # INSTALL_URL_ADDRESS='https://github.com/Hellowlol/HTPC-Manager.git' # - # /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - # #Install - # if (( $? == 0 )); then + # G_CHECK_URL "$INSTALL_URL_ADDRESS" # - # #Install Python and PIP - # AGI python python-pip python-imaging + # #Install Python and PIP + # G_AGI python python-pip python-imaging # - # cd "$HOME" - # git clone --depth=1 "$INSTALL_URL_ADDRESS" + # cd "$HOME" + # git clone --depth=1 "$INSTALL_URL_ADDRESS" # - # # - Move HTPC Manager to a 'better' location - # mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/htpc-manager - # mv "$HOME"/HTPC-Manager/* "$FP_DIETPI_USERDATA_DIRECTORY"/htpc-manager/ - # rm -R "$HOME"/HTPC-Manager + # # - Move HTPC Manager to a 'better' location + # mkdir -p "$G_FP_DIETPI_USERDATA"/htpc-manager + # mv "$HOME"/HTPC-Manager/* "$G_FP_DIETPI_USERDATA"/htpc-manager/ + # rm -R "$HOME"/HTPC-Manager # - # else - # Error_NoConnection_NoInstall - # fi # fi # #///////////////////////////////////////////////////////////////////////////////////// @@ -3576,18 +3387,10 @@ _EOF_ # - For desktop entries/icons hosted on dietpi.com INSTALL_URL_ADDRESS='http://dietpi.com/downloads/conf/desktop' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then - - AGI lxde upower policykit-1 iceweasel p7zip-full --no-install-recommends - #upower policykit-1. Needed for LXDE logout menu item to show shutdown/restart ...... - - else - - Error_NoConnection_NoInstall + G_CHECK_URL "$INSTALL_URL_ADDRESS" - fi + G_AGI lxde upower policykit-1 iceweasel p7zip-full --no-install-recommends + #upower policykit-1. Needed for LXDE logout menu item to show shutdown/restart ...... fi @@ -3600,17 +3403,9 @@ _EOF_ # - For desktop entries/icons hosted on dietpi.com INSTALL_URL_ADDRESS='http://dietpi.com/downloads/conf/desktop' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - AGI mate-desktop-environment-extras upower policykit-1 iceweasel p7zip-full --no-install-recommends - - else - - Error_NoConnection_NoInstall - - fi + G_AGI mate-desktop-environment-extras upower policykit-1 iceweasel p7zip-full --no-install-recommends fi @@ -3623,17 +3418,9 @@ _EOF_ # - For desktop entries/icons hosted on dietpi.com INSTALL_URL_ADDRESS='http://dietpi.com/downloads/conf/desktop' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then - - AGI x-window-system-core wmaker gnustep gnustep-devel gnustep-games libc-dbg upower policykit-1 iceweasel p7zip-full --no-install-recommends - - else - - Error_NoConnection_NoInstall + G_CHECK_URL "$INSTALL_URL_ADDRESS" - fi + G_AGI x-window-system-core wmaker gnustep gnustep-devel gnustep-games libc-dbg upower policykit-1 iceweasel p7zip-full --no-install-recommends fi @@ -3646,17 +3433,9 @@ _EOF_ # - For desktop entries/icons hosted on dietpi.com INSTALL_URL_ADDRESS='http://dietpi.com/downloads/conf/desktop' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then - - AGI xfce4 xfce4-terminal gnome-icon-theme tango-icon-theme iceweasel p7zip-full --no-install-recommends - - else - - Error_NoConnection_NoInstall + G_CHECK_URL "$INSTALL_URL_ADDRESS" - fi + G_AGI xfce4 xfce4-terminal gnome-icon-theme tango-icon-theme iceweasel p7zip-full --no-install-recommends fi @@ -3666,7 +3445,7 @@ _EOF_ Banner_Installing - AGI xrdp + G_AGI xrdp fi @@ -3678,36 +3457,28 @@ _EOF_ INSTALL_DESCRIPTION="NoMachine (Secure RDP Server & Client)" #x86_64 - if (( $HW_ARCH == 10 )); then + if (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/nomachine_5.1.44_1_amd64.deb' #arm6 (RPi1) - elif (( $HW_ARCH == 1 )); then + elif (( $G_HW_ARCH == 1 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/nomachine_5.1.44_3_armv6hf.deb' #arm7+ (RPi 2/3) - elif (( $HW_ARCH == 2 )); then + elif (( $G_HW_ARCH == 2 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/nomachine_5.1.44_armhf.deb' fi # Now, check that the links are legitimate - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall - - fi + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb fi @@ -3716,7 +3487,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI transmission-daemon + G_AGI transmission-daemon fi @@ -3727,7 +3498,7 @@ _EOF_ Banner_Installing echo -e "proftpd-basic shared/proftpd/inetd_or_standalone select standalone" | debconf-set-selections - AGI proftpd-basic + G_AGI proftpd-basic fi @@ -3736,7 +3507,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI samba samba-common-bin --no-install-recommends + G_AGI samba samba-common-bin --no-install-recommends fi @@ -3746,7 +3517,7 @@ _EOF_ Banner_Installing - AGI vsftpd --no-install-recommends + G_AGI vsftpd --no-install-recommends fi @@ -3756,7 +3527,7 @@ _EOF_ Banner_Installing - AGI nfs-kernel-server nfs-common ucf rpcbind + G_AGI nfs-kernel-server nfs-common ucf rpcbind fi @@ -3765,7 +3536,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI apache2 + G_AGI apache2 fi @@ -3774,7 +3545,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI nginx xml-core --no-install-recommends + G_AGI nginx xml-core --no-install-recommends fi @@ -3783,26 +3554,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI lighttpd - - fi - - #WEBSERVER_MYSQL - INSTALLING_INDEX=86 - if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - - Banner_Installing - - debconf-set-selections <<< "mysql-server mysql-server/root_password password $GLOBAL_PW" - debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $GLOBAL_PW" - - AGI mysql-server - - # Fix depricated key_buffer -> key_buffer_size per MySQL 5.x notification - sed -i 's/^key_buffer[[:space:]]/key_buffer_size /g' /etc/mysql/my.cnf - - # Restart service and leave it running (just incase another install requires SQL DB creation). - systemctl restart mysql + G_AGI lighttpd fi @@ -3812,10 +3564,10 @@ _EOF_ Banner_Installing - debconf-set-selections <<< "mysql-server mysql-server/root_password password $GLOBAL_PW" - debconf-set-selections <<< "mysql-server mysql-server/root_password_again password $GLOBAL_PW" - - AGI mariadb-server + # In case remove old symlink, created by DietPi MariaDB installation, otherwise installation will fail. + # This will not remove the folder in case, without "-R". + [ "$(readlink /var/lib/mysql)" ] && [ ! -d "$(readlink /var/lib/mysql)/mysql" ] && rm /var/lib/mysql + G_AGI mariadb-server fi @@ -3824,7 +3576,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI sqlite3 + G_AGI sqlite3 fi @@ -3833,11 +3585,11 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI redis-server + G_AGI redis-server #Redis php module | == 2 to check for existing installs, if == 1, then module will be installed together with PHP, to prevent dependency installations if (( ${aSOFTWARE_INSTALL_STATE[89]} == 2 )); then - AGI "$PHP_APT_PACKAGE_NAME"-redis + G_AGI "$PHP_APT_PACKAGE_NAME"-redis fi @@ -3852,40 +3604,42 @@ _EOF_ #Install base PHP packages/modules. if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then - AGI "$PHP_APT_PACKAGE_NAME" libapache2-mod-"$PHP_APT_PACKAGE_NAME" + G_AGI "$PHP_APT_PACKAGE_NAME" libapache2-mod-"$PHP_APT_PACKAGE_NAME" else - AGI "$PHP_APT_PACKAGE_NAME"-fpm "$PHP_APT_PACKAGE_NAME"-cgi "$PHP_APT_PACKAGE_NAME"-xsl + G_AGI "$PHP_APT_PACKAGE_NAME"-fpm "$PHP_APT_PACKAGE_NAME"-cgi + # 'php-xsl' does not exist for >= Stretch, 'php7.0-xsl' is just dummy for 'php7.0-xml': https://github.com/Fourdee/DietPi/issues/1286 + (( $G_DISTRO < 4 )) && G_AGI php5-xsl fi #php-common modules, used by most web software - AGI "$PHP_APT_PACKAGE_NAME"-curl "$PHP_APT_PACKAGE_NAME"-gd "$PHP_APT_PACKAGE_NAME"-apcu "$PHP_APT_PACKAGE_NAME"-mcrypt + G_AGI "$PHP_APT_PACKAGE_NAME"-curl "$PHP_APT_PACKAGE_NAME"-gd "$PHP_APT_PACKAGE_NAME"-apcu "$PHP_APT_PACKAGE_NAME"-mcrypt # + stretch extras - if (( $DISTRO >= 4 )); then + if (( $G_DISTRO >= 4 )); then - AGI "$PHP_APT_PACKAGE_NAME"-mbstring "$PHP_APT_PACKAGE_NAME"-zip "$PHP_APT_PACKAGE_NAME"-xml + G_AGI "$PHP_APT_PACKAGE_NAME"-mbstring "$PHP_APT_PACKAGE_NAME"-zip "$PHP_APT_PACKAGE_NAME"-xml fi #php-SQL modules if (( ${aSOFTWARE_INSTALL_STATE[86]} >= 1 )); then - AGI "$PHP_APT_PACKAGE_NAME"-mysql + G_AGI "$PHP_APT_PACKAGE_NAME"-mysql fi if (( ${aSOFTWARE_INSTALL_STATE[88]} >= 1 )); then - if (( $DISTRO < 4 )); then + if (( $G_DISTRO < 4 )); then #For <= Jessie, php5-mysqlnd provides the newer mysql client libraries compared to php5-mysql. - AGI "$PHP_APT_PACKAGE_NAME"-mysqlnd + G_AGI "$PHP_APT_PACKAGE_NAME"-mysqlnd else #For >= Stretch, php(7.X)-mysqlnd does not exist, thus php-mysql need to be installed: https://packages.debian.org/de/stretch/php-mysql - AGI "$PHP_APT_PACKAGE_NAME"-mysql + G_AGI "$PHP_APT_PACKAGE_NAME"-mysql fi @@ -3893,14 +3647,14 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[87]} >= 1 )); then - AGI "$PHP_APT_PACKAGE_NAME"-sqlite* #wildcard for version (eg:3) + G_AGI "$PHP_APT_PACKAGE_NAME"-sqlite* #wildcard for version (eg:3) fi - #Redis php module | >= 1 to check for existing installs (2) + #Redis php module if (( ${aSOFTWARE_INSTALL_STATE[91]} >= 1 )); then - AGI "$PHP_APT_PACKAGE_NAME"-redis + G_AGI "$PHP_APT_PACKAGE_NAME"-redis fi @@ -3912,14 +3666,13 @@ _EOF_ Banner_Installing - #Mysql must be running during install to allow debconf setup. - systemctl start mysql + #MySQL must be running during install to allow debconf setup. + G_RUN_CMD systemctl start mysql # Set password parameters before installing debconf-set-selections <<< "phpmyadmin phpmyadmin/dbconfig-install boolean true" - debconf-set-selections <<< "phpmyadmin phpmyadmin/app-password-confirm password $GLOBAL_PW" - debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/admin-pass password $GLOBAL_PW" debconf-set-selections <<< "phpmyadmin phpmyadmin/mysql/app-pass password $GLOBAL_PW" + debconf-set-selections <<< "phpmyadmin phpmyadmin/app-password-confirm password $GLOBAL_PW" if (( ${aSOFTWARE_INSTALL_STATE[83]} == 1 )); then @@ -3935,7 +3688,7 @@ _EOF_ fi - AGI phpmyadmin + G_AGI phpmyadmin fi @@ -3946,32 +3699,25 @@ _EOF_ Banner_Installing #Jessie - if (( $DISTRO == 3 )); then + if (( $G_DISTRO == 3 )); then #MPD not available in Jessie Repo for ARMv8 - if (( $HW_ARCH == 3 )); then + if (( $G_HW_ARCH == 3 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/mpd_0.19.21_arm64.deb' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - #libupnp6 for net discov with upnp/avahi - AGI libupnp6 - AGI 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 --no-install-recommends - - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + #libupnp6 for net discov with upnp/avahi + G_AGI libupnp6 + G_AGI 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 --no-install-recommends - fi + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb else - AGI mpd + G_AGI mpd fi @@ -3981,22 +3727,22 @@ _EOF_ INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/mpd_0.20.11-1_' #armv6 - if (( $HW_ARCH == 1 )); then + if (( $G_HW_ARCH == 1 )); then INSTALL_URL_ADDRESS+='armv6' #armv7+ - elif (( $HW_ARCH == 2 )); then + elif (( $G_HW_ARCH == 2 )); then INSTALL_URL_ADDRESS+='armv7' #ARMv8 - elif (( $HW_ARCH == 3 )); then + elif (( $G_HW_ARCH == 3 )); then INSTALL_URL_ADDRESS+='armv8' #x86_64 - elif (( $HW_ARCH == 10 )); then + elif (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS+='amd64' @@ -4004,25 +3750,18 @@ _EOF_ INSTALL_URL_ADDRESS+='.deb' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - #Prereqs - AGI libmpdclient2 libflac8 libyajl2 libavahi-client3 libvorbisfile3 libwavpack1 libmad0 libmpg123-0 libopus0 libavformat57 libfaad2 libcdio-paranoia1 libiso9660-8 libshout3 libid3tag0 - - apt-mark unhold mpd &> /dev/null #??? Not required for dpkg -i installs - - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb + G_CHECK_URL "$INSTALL_URL_ADDRESS" - apt-mark hold mpd # prevent repo updates from overwriting + #Prereqs + G_AGI libmpdclient2 libflac8 libyajl2 libavahi-client3 libvorbisfile3 libwavpack1 libmad0 libmpg123-0 libopus0 libavformat57 libfaad2 libcdio-paranoia1 libiso9660-8 libshout3 libid3tag0 - else + apt-mark unhold mpd &> /dev/null #??? Not required for dpkg -i installs - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb - fi + apt-mark hold mpd # prevent repo updates from overwriting fi @@ -4034,21 +3773,12 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS='https://www.phpbb.com/files/release/phpBB-3.1.6.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip -d /var/www - rm package.zip - - else + INSTALL_URL_ADDRESS='https://www.phpbb.com/files/release/phpBB-3.2.1.zip' + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall - - fi + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip -d /var/www + rm package.zip fi @@ -4059,56 +3789,46 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://github.com/OpenBazaar/OpenBazaar-Server.git' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - #Install - - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - AGI libsodium-dev automake autoconf pkg-config libtool libssl-dev libffi-dev python-dev openssl libzmq3-dev + G_AGI libsodium-dev automake autoconf pkg-config libtool libssl-dev libffi-dev python-dev openssl libzmq3-dev - #Not required. - #AGI software-properties-common - #add-apt-repository -y ppa:chris-lea/libsodium - #apt-get update + #Not required. + #G_AGI software-properties-common + #add-apt-repository -y ppa:chris-lea/libsodium + #G_AGUP - pip install cryptography + pip install cryptography - cd "$HOME" - git clone --depth=1 https://github.com/zeromq/libzmq - git clone --depth=1 https://github.com/pyca/pynacl/ - git clone --depth=1 "$INSTALL_URL_ADDRESS" - - # - compile - cd "$HOME"/libzmq - ./autogen.sh && ./configure && make -j $CPU_CORES_TOTAL - make check && make install && ldconfig - - cd "$HOME"/pynacl - python setup.py build && python setup.py install - - cd "$HOME" - - # - Move OpenBazaar to a 'better' location - mkdir -p /etc/openbazaar-server - mv "$HOME"/OpenBazaar-Server/* /etc/openbazaar-server/ - rm -R "$HOME"/OpenBazaar-Server + cd "$HOME" + git clone --depth=1 https://github.com/zeromq/libzmq + git clone --depth=1 https://github.com/pyca/pynacl/ + git clone --depth=1 "$INSTALL_URL_ADDRESS" - # - install OpenBazaar - cd /etc/openbazaar-server - pip install -r requirements.txt + # - compile + cd "$HOME"/libzmq + ./autogen.sh && ./configure && make -j $G_HW_CPU_CORES + make check && make install && ldconfig - cd "$HOME" + cd "$HOME"/pynacl + python setup.py build && python setup.py install - # - Clean up, remove source libraries - rm -R "$HOME"/libzmq - rm -R "$HOME"/pynacl + cd "$HOME" + # - Move OpenBazaar to a 'better' location + mkdir -p /etc/openbazaar-server + mv "$HOME"/OpenBazaar-Server/* /etc/openbazaar-server/ + rm -R "$HOME"/OpenBazaar-Server - else + # - install OpenBazaar + cd /etc/openbazaar-server + pip install -r requirements.txt - Error_NoConnection_NoInstall + cd "$HOME" - fi + # - Clean up, remove source libraries + rm -R "$HOME"/libzmq + rm -R "$HOME"/pynacl fi @@ -4119,18 +3839,11 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://yacy.net/release/yacy_v1.92_20161226_9000.tar.gz' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.tar.gz - tar xvf package.tar.gz -C /etc/ - rm package.tar.gz - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall - - fi + wget "$INSTALL_URL_ADDRESS" -O package.tar.gz + tar xvf package.tar.gz -C /etc/ + rm package.tar.gz fi @@ -4140,54 +3853,32 @@ _EOF_ Banner_Installing - if (( $DISTRO == 3 )); then + G_DIETPI-NOTIFY 2 'Installing needed PHP modules: https://doc.owncloud.org/server/latest/admin_manual/installation/source_installation.html#php-extensions' + G_AGI "$PHP_APT_PACKAGE_NAME"-intl "$PHP_APT_PACKAGE_NAME"-redis - INSTALL_URL_ADDRESS='https://download.owncloud.org/download/repositories/stable/Debian_8.0/Release.key' + if [ -f /var/www/owncloud/occ ]; then - elif (( $DISTRO == 4 )); then - - INSTALL_URL_ADDRESS='https://download.owncloud.org/download/repositories/stable/Debian_9.0/Release.key' + G_DIETPI-NOTIFY 2 'Existing ownCloud installation found, will NOT overwrite...' else - INSTALL_URL_ADDRESS='https://download.owncloud.org/community/owncloud-latest.zip' - - fi - - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - #Install - if (( $? == 0 )); then - - # Install necessary PHP modules: https://doc.owncloud.org/server/latest/admin_manual/installation/source_installation.html#php-extensions - AGI "$PHP_APT_PACKAGE_NAME"-intl "$PHP_APT_PACKAGE_NAME"-redis - - if [ ! -f /etc/apt/sources.list.d/owncloud.list ] && [ ! -d /var/www/owncloud ]; then - - wget "$INSTALL_URL_ADDRESS" -O owncloud.key_or_zip - apt-key add - < owncloud.key_or_zip 2> /dev/null - unzip -o owncloud.key_or_zip -d /var/www 2> /dev/null - rm owncloud.key_or_zip - - if (( $DISTRO == 3 )); then - - echo -e "deb https://download.owncloud.org/download/repositories/stable/Debian_8.0/ /" > /etc/apt/sources.list.d/owncloud.list - apt-get update + local datadir="$(grep -m1 '^[[:blank:]]*SOFTWARE_OWNCLOUD_DATADIR=' /DietPi/dietpi.txt | sed 's/^.*=//')" + [ -n "$datadir" ] || datadir="$G_FP_DIETPI_USERDATA/owncloud_data" + if [ -f "$datadir"/dietpi-owncloud-installation-backup/occ ]; then - elif (( $DISTRO == 4 )); then + G_DIETPI-NOTIFY 2 'ownCloud installation backup found, starting recovery...' + G_RUN_CMD cp -a "$datadir"/dietpi-owncloud-installation-backup/. /var/www/owncloud - echo -e "deb https://download.owncloud.org/download/repositories/stable/Debian_9.0/ /" > /etc/apt/sources.list.d/owncloud.list - apt-get update + else - fi + INSTALL_URL_ADDRESS='https://download.owncloud.org/community/owncloud-latest.zip' + G_CHECK_URL "$INSTALL_URL_ADDRESS" + G_RUN_CMD wget "$INSTALL_URL_ADDRESS" -O package.zip + G_RUN_CMD unzip -o package.zip -d /var/www + rm package.zip fi - AGI owncloud-files 2> /dev/null - - else - - Error_NoConnection_NoInstall - fi fi @@ -4198,26 +3889,31 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS='https://download.nextcloud.com/server/releases/latest-12.zip' + G_DIETPI-NOTIFY 2 'Installing needed PHP modules: https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation' + G_AGI "$PHP_APT_PACKAGE_NAME"-intl "$PHP_APT_PACKAGE_NAME"-redis - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - #Install - if (( $? == 0 )); then + if [ -f /var/www/nextcloud/occ ]; then - # Install necessary PHP modules: https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation - AGI "$PHP_APT_PACKAGE_NAME"-intl "$PHP_APT_PACKAGE_NAME"-redis + G_DIETPI-NOTIFY 2 'Existing Nextcloud installation found, will NOT overwrite...' - if [ ! -d /var/www/nextcloud ]; then + else - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip -d /var/www - rm package.zip + local datadir="$(grep -m1 '^[[:blank:]]*SOFTWARE_NEXTCLOUD_DATADIR=' /DietPi/dietpi.txt | sed 's/^.*=//')" + [ -n "$datadir" ] || datadir="$G_FP_DIETPI_USERDATA/nextcloudcloud_data" + if [ -f "$datadir"/dietpi-nextcloud-installation-backup/occ ]; then - fi + G_DIETPI-NOTIFY 2 'Nextcloud installation backup found, starting recovery...' + G_RUN_CMD cp -a "$datadir"/dietpi-nextcloud-installation-backup/. /var/www/nextcloud - else + else + + INSTALL_URL_ADDRESS='https://download.nextcloud.com/server/releases/latest.zip' + G_CHECK_URL "$INSTALL_URL_ADDRESS" + G_RUN_CMD wget "$INSTALL_URL_ADDRESS" -O package.zip + G_RUN_CMD unzip -o package.zip -d /var/www + rm package.zip - Error_NoConnection_NoInstall + fi fi @@ -4230,58 +3926,41 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/ympd_1.2.3.7z' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - # Install - if (( $? == 0 )); then + wget "$INSTALL_URL_ADDRESS" -O package.7z + 7z x -y package.7z - wget "$INSTALL_URL_ADDRESS" -O package.7z - 7z x -y package.7z - - local binary_name='ympd_' - # - armv6 - if (( $HW_ARCH == 1 )); then - - binary_name+='armv6' - - # - armv7 - elif (( $HW_ARCH == 2 )); then - - binary_name+='armv7' - - # - arm64 - elif (( $HW_ARCH == 3 )); then - - binary_name+='armv8' - - # - x86_64 - elif (( $HW_ARCH == 10 )); then - - binary_name+='amd64' + local binary_name='ympd_' + # - armv6 + if (( $G_HW_ARCH == 1 )); then - fi + binary_name+='armv6' - if (( $DISTRO == 3 )); then + # - armv7 + elif (( $G_HW_ARCH == 2 )); then - binary_name+='_jessie' + binary_name+='armv7' - else + # - arm64 + elif (( $G_HW_ARCH == 3 )); then - binary_name+='_stretch' + binary_name+='armv8' - fi + # - x86_64 + elif (( $G_HW_ARCH == 10 )); then - mv "$binary_name" /usr/bin/ympd - chmod +x /usr/bin/ympd + binary_name+='amd64' - rm ympd_* - rm package.7z + fi - else + binary_name+="_$G_DISTRO_NAME" - Error_NoConnection_NoInstall + mv "$binary_name" /usr/bin/ympd + chmod +x /usr/bin/ympd - fi + rm ympd_* + rm package.7z fi @@ -4292,12 +3971,12 @@ _EOF_ Banner_Installing #x86_64 - if (( $HW_ARCH == 10 )); then + if (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS='http://download.roonlabs.com/builds/RoonBridge_linuxx64.tar.bz2' #ARMv8 - elif (( $HW_ARCH == 3 )); then + elif (( $G_HW_ARCH == 3 )); then INSTALL_URL_ADDRESS='http://download.roonlabs.com/builds/RoonBridge_linuxarmv8.tar.bz2' @@ -4308,27 +3987,18 @@ _EOF_ fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - # Install - if (( $? == 0 )); then + wget "$INSTALL_URL_ADDRESS" -O package.tar.bz2 + tar xvf package.tar.bz2 + rm package.tar.bz2 - wget "$INSTALL_URL_ADDRESS" -O package.tar.bz2 - tar xvf package.tar.bz2 - rm package.tar.bz2 + # - reinstall, clear dir, prevent mv fail on non-empty dir + rm -R /etc/roonbridge &> /dev/null - # - reinstall, clear dir, prevent mv fail on non-empty dir - rm -R /etc/roonbridge &> /dev/null - - mkdir -p /etc/roonbridge - mv RoonBridge/* /etc/roonbridge - rm -R RoonBridge - - else - - Error_NoConnection_NoInstall - - fi + mkdir -p /etc/roonbridge + mv RoonBridge/* /etc/roonbridge + rm -R RoonBridge fi @@ -4339,41 +4009,32 @@ _EOF_ Banner_Installing # - armv6 - if (( $HW_ARCH == 1 )); then + if (( $G_HW_ARCH == 1 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/cava_0.4.2_armv6.deb' # - armv7 - elif (( $HW_ARCH == 2 )); then + elif (( $G_HW_ARCH == 2 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/cava_0.4.2_armv7.deb' # - arm64 - elif (( $HW_ARCH == 3 )); then + elif (( $G_HW_ARCH == 3 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/cava_0.4.2_arm64.deb' fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - # Install - if (( $? == 0 )); then - - AGI libpulse0 libfftw3-3 + G_CHECK_URL "$INSTALL_URL_ADDRESS" - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb - - # + Font for cava, nice bars - wget http://dietpi.com/downloads/binaries/all/cava.psf -O "$HOME"/cava.psf + G_AGI libpulse0 libfftw3-3 - else - - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb - fi + # + Font for cava, nice bars + wget http://dietpi.com/downloads/binaries/all/cava.psf -O "$HOME"/cava.psf fi @@ -4384,34 +4045,33 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://apt.mopidy.com/mopidy.gpg' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - # Install - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - wget -q -O - "$INSTALL_URL_ADDRESS" | apt-key add - - wget https://apt.mopidy.com/jessie.list -O /etc/apt/sources.list.d/mopidy.list + wget -q -O - "$INSTALL_URL_ADDRESS" | apt-key add - + # No Buster list available yet, use stretch.list for testing: + if (( $G_DISTRO > 4 )); then - apt-get update - AGI mopidy + wget https://apt.mopidy.com/stretch.list -O /etc/apt/sources.list.d/mopidy.list - #ARMv8 - #NB: No ARM64 packages currently exist in mopidy repo. So it will throw a minor error when updating apt. - #Mopidy web client extensions not loading in webpage... - # if (( $HW_ARCH == 3 )); then + else - # AGI build-essential python-dev - # pip install mopidy #no effect, claims already upto date. + wget https://apt.mopidy.com/"$G_DISTRO_NAME".list -O /etc/apt/sources.list.d/mopidy.list - # fi + fi + G_AGUP + G_AGI mopidy - pip install Mopidy-MusicBox-Webclient Mopidy-Local-Images + #ARMv8 + #NB: No ARM64 packages currently exist in mopidy repo. So it will throw a minor error when updating apt. + #Mopidy web client extensions not loading in webpage... + # if (( $G_HW_ARCH == 3 )); then - else + # G_AGI build-essential python-dev + # pip install mopidy #no effect, claims already upto date. - Error_NoConnection_NoInstall + # fi - fi + pip install Mopidy-MusicBox-Webclient Mopidy-Local-Images fi @@ -4422,44 +4082,44 @@ _EOF_ Banner_Installing #Odroids - if (( $HW_MODEL >= 10 )) && (( $HW_MODEL < 20 )); then + if (( $G_HW_MODEL >= 10 )) && (( $G_HW_MODEL < 20 )); then - AGI kodi-odroid + G_AGI kodi-odroid #XU4 - requires pulse audio (fixes corrupt sound) - if (( $HW_MODEL == 11 )); then + if (( $G_HW_MODEL == 11 )); then - AGI pulseaudio --no-install-recommends + G_AGI pulseaudio --no-install-recommends fi #Everything else else - AGI kodi + G_AGI kodi fi # - libcurl3-gnutls required for C2. But lets apply to all: https://github.com/Fourdee/DietPi/issues/446 - AGI libcurl3-gnutls + G_AGI libcurl3-gnutls # - Add NFS support for kodi - if (( $DISTRO == 3 )); then + if (( $G_DISTRO == 3 )); then - AGI libnfs4 + G_AGI libnfs4 fi # - CEC support | * due to C2 having libcec3v4, rpi has libcec3. # XU4 package conflict: https://github.com/Fourdee/DietPi/issues/554 # Due to the vast differences in libcec naming across devices, if CEC fails to install, do not terminate DietPi install. - apt-get install -y libcec3* + G_AGI libcec3* if (( $? != 0 )); then - apt-get install -y libcec3 + G_AGI libcec3 if (( $? != 0 )); then - /DietPi/dietpi/func/dietpi-notify 2 "libcec3 failed to install." + G_DIETPI-NOTIFY 2 "libcec3 failed to install." fi @@ -4472,7 +4132,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI minidlna + G_AGI minidlna fi @@ -4483,12 +4143,12 @@ _EOF_ Banner_Installing #x32 x64 - if (( $HW_MODEL == 20 || $HW_MODEL == 21 )); then + if (( $G_HW_MODEL == 20 || $G_HW_MODEL == 21 )); then INSTALL_URL_ADDRESS="http://dietpi.com/downloads/binaries/all/noip_x32_x64.zip" #ARMv8 - elif (( ( $HW_MODEL == 12 ) || ( $HW_MODEL >=40 && $HW_MODEL < 50 ) )); then + elif (( ( $G_HW_MODEL == 12 ) || ( $G_HW_MODEL >=40 && $G_HW_MODEL < 50 ) )); then INSTALL_URL_ADDRESS="http://dietpi.com/downloads/binaries/all/noip_arm64.zip" @@ -4498,23 +4158,14 @@ _EOF_ INSTALL_URL_ADDRESS="http://dietpi.com/downloads/binaries/all/noip_armhf.zip" fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - #NoIp Binary install - wget "$INSTALL_URL_ADDRESS" -O dietpi-noip.zip - unzip -o dietpi-noip.zip - rm dietpi-noip.zip - mv noip_binary /usr/local/bin/noip2 - chmod +x /usr/local/bin/noip2 - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall - - fi + #NoIp Binary install + wget "$INSTALL_URL_ADDRESS" -O dietpi-noip.zip + unzip -o dietpi-noip.zip + rm dietpi-noip.zip + mv noip_binary /usr/local/bin/noip2 + chmod +x /usr/local/bin/noip2 fi @@ -4525,31 +4176,22 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/amiberry-rpi_v2.1.1.7z' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - AGI alsa-oss joystick libsdl-image1.2 libsdl-ttf2.0-0 libsdl-gfx1.2-5 libguichan-0.8.1-1* libguichan-allegro-0.8.1-1* libguichan-sdl-0.8.1-1* libguichan-opengl-0.8.1-1* libjpgalleg4.4 libxml2 libmpg123-0 + G_AGI alsa-oss joystick libsdl-image1.2 libsdl-ttf2.0-0 libsdl-gfx1.2-5 libguichan-0.8.1-1* libguichan-allegro-0.8.1-1* libguichan-sdl-0.8.1-1* libguichan-opengl-0.8.1-1* libjpgalleg4.4 libxml2 libmpg123-0 - #libmpeg2-4 # Required for dev branch + #libmpeg2-4 # Required for dev branch - # + SDL2 - AGI libpng12-0 libflac8 libmpg123-0 libgoogle-perftools4 libfreetype6 libxxf86vm1 - - #Download binaries - # - Backup existing autostart.uae for user - mv "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/conf/autostart.uae "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/conf/autostart_pre-dietpi-update.uae &> /dev/null - - wget "$INSTALL_URL_ADDRESS" -O package.7z - 7z x -y package.7z -o/etc - rm package.7z - - else + # + SDL2 + G_AGI libpng12-0 libflac8 libmpg123-0 libgoogle-perftools4 libfreetype6 libxxf86vm1 - Error_NoConnection_NoInstall + #Download binaries + # - Backup existing autostart.uae for user + mv "$G_FP_DIETPI_USERDATA"/amiberry/conf/autostart.uae "$G_FP_DIETPI_USERDATA"/amiberry/conf/autostart_pre-dietpi-update.uae &> /dev/null - fi + wget "$INSTALL_URL_ADDRESS" -O package.7z + 7z x -y package.7z -o/etc + rm package.7z fi @@ -4560,22 +4202,13 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/rpi/dxx-rebirth.7z' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - #Install - if (( $? == 0 )); then - - AGI libsdl-mixer1.2 libsdl1.2debian libphysfs1 - - wget "$INSTALL_URL_ADDRESS" -O package.7z - 7z x -y package.7z -o"$FP_DIETPI_USERDATA_DIRECTORY" - rm package.7z - - else - - Error_NoConnection_NoInstall + G_AGI libsdl-mixer1.2 libsdl1.2debian libphysfs1 - fi + wget "$INSTALL_URL_ADDRESS" -O package.7z + 7z x -y package.7z -o"$G_FP_DIETPI_USERDATA" + rm package.7z fi @@ -4585,68 +4218,58 @@ _EOF_ Banner_Installing - if (( $HW_ARCH == 10 )); then + if (( $G_HW_ARCH == 10 )); then - INSTALL_URL_ADDRESS='http://hndl.urbackup.org/Server/2.1.19/urbackup-server_2.1.19_amd64.deb' + INSTALL_URL_ADDRESS='http://hndl.urbackup.org/Server/2.1.20/urbackup-server_2.1.20_amd64.deb' - elif (( $HW_ARCH == 1 || $HW_ARCH == 2 )); then + elif (( $G_HW_ARCH == 1 || $G_HW_ARCH == 2 )); then - INSTALL_URL_ADDRESS='http://hndl.urbackup.org/Server/2.1.19/urbackup-server_2.1.19_armhf.deb' + INSTALL_URL_ADDRESS='http://hndl.urbackup.org/Server/2.1.20/urbackup-server_2.1.20_armhf.deb' #ARMv8 sourcebuild - elif (( $HW_ARCH == 3 )); then + elif (( $G_HW_ARCH == 3 )); then - INSTALL_URL_ADDRESS='http://hndl.urbackup.org/Server/2.1.19/urbackup-server-2.1.19.tar.gz' + INSTALL_URL_ADDRESS='http://hndl.urbackup.org/Server/2.1.20/urbackup-server-2.1.20.tar.gz' fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - - #ARMv8 source build - if (( $HW_ARCH == 3 )); then - - AGI build-essential zlib1g-dev libcurl4-openssl-dev libcrypto++-dev sqlite3 - - wget "$INSTALL_URL_ADDRESS" -O package.tar - tar xzvf package.tar - rm package.tar + G_CHECK_URL "$INSTALL_URL_ADDRESS" - cd urbackup-server-* + #ARMv8 source build + if (( $G_HW_ARCH == 3 )); then - ./configure - make -j $CPU_CORES_TOTAL - make install + G_AGI build-essential zlib1g-dev libcurl4-openssl-dev libcrypto++-dev sqlite3 - sed -i "/ExecStart=/c ExecStart=/usr/local/bin/urbackupsrv run --config /etc/default/urbackupsrv --no-consoletime" urbackup-server.service - cp urbackup-server.service /etc/systemd/system/urbackupsrv.service - cp defaults_server /etc/default/urbackupsrv - cp logrotate_urbackupsrv /etc/logrotate.d/urbackupsrv + wget "$INSTALL_URL_ADDRESS" -O package.tar + tar xzvf package.tar + rm package.tar - cd .. + cd urbackup-server-* - rm -R urbackup-server-* + ./configure + make -j $G_HW_CPU_CORES + make install - #Deb - else + sed -i "/ExecStart=/c ExecStart=/usr/local/bin/urbackupsrv run --config /etc/default/urbackupsrv --no-consoletime" urbackup-server.service + cp urbackup-server.service /etc/systemd/system/urbackupsrv.service + cp defaults_server /etc/default/urbackupsrv + cp logrotate_urbackupsrv /etc/logrotate.d/urbackupsrv - wget "$INSTALL_URL_ADDRESS" -O package.deb + cd .. - echo -e "urbackup-server urbackup/backuppath string $FP_DIETPI_USERDATA_DIRECTORY/urbackup" | debconf-set-selections - dpkg -i package.deb + rm -R urbackup-server-* - apt-get -f install -y + #Deb + else - rm package.deb + wget "$INSTALL_URL_ADDRESS" -O package.deb - fi + echo -e "urbackup-server urbackup/backuppath string $G_FP_DIETPI_USERDATA/urbackup" | debconf-set-selections + dpkg -i package.deb - else + apt-get -f install -y - Error_NoConnection_NoInstall + rm package.deb fi @@ -4659,24 +4282,15 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS="http://dietpi.com/downloads/binaries/rpi/opentyrian_armhf.zip" - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - AGI ibsdl1.2debian libsdl-net1.2 --no-install-recommends - - #Download binaries - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip -d / - rm package.zip - chmod +x /usr/local/games/opentyrian/opentyrian - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + G_AGI ibsdl1.2debian libsdl-net1.2 --no-install-recommends - fi + #Download binaries + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip -d / + rm package.zip + chmod +x /usr/local/games/opentyrian/opentyrian fi @@ -4687,53 +4301,44 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://github.com/Fourdee/RPi_Cam_Web_Interface/archive/6.2.29.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - #Install - if (( $? == 0 )); then - - #Install pre-reqs - AGI gpac motion - - #Get source/binaries and extract - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip - rm package.zip - - cd RPi_Cam* + #Install pre-reqs + G_AGI gpac motion - #Config /etc/motion - mkdir -p /etc/motion - cp etc/motion/motion.conf.1 /etc/motion/motion.conf + #Get source/binaries and extract + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip + rm package.zip - #Config /etc/raspimjpeg - cp etc/raspimjpeg/raspimjpeg.1 /etc/raspimjpeg + cd RPi_Cam* - #Setup /var/www/dietpicam - mkdir -p /var/www/dietpicam/media - cp -R www/* /var/www/dietpicam/ - chmod +x /var/www/dietpicam/raspizip.sh - mknod /var/www/dietpicam/FIFO p - mknod /var/www/dietpicam/FIFO1 p + #Config /etc/motion + mkdir -p /etc/motion + cp etc/motion/motion.conf.1 /etc/motion/motion.conf - #symlink cam preview and status - ln -sf /run/shm/mjpeg/cam.jpg /var/www/dietpicam/cam.jpg - ln -sf /run/shm/mjpeg/status_mjpeg.txt /var/www/dietpicam/status_mjpeg.txt + #Config /etc/raspimjpeg + cp etc/raspimjpeg/raspimjpeg.1 /etc/raspimjpeg - #Setup Raspimjpeg binary - cp bin/raspimjpeg /opt/vc/bin/raspimjpeg - chmod +x /opt/vc/bin/raspimjpeg - ln -s /opt/vc/bin/raspimjpeg /usr/bin/raspimjpeg + #Setup /var/www/dietpicam + mkdir -p /var/www/dietpicam/media + cp -R www/* /var/www/dietpicam/ + chmod +x /var/www/dietpicam/raspizip.sh + mknod /var/www/dietpicam/FIFO p + mknod /var/www/dietpicam/FIFO1 p - #Cleanup / remove extracted source - cd "$HOME" - rm -R "$HOME"/RPi_Cam* - - else + #symlink cam preview and status + ln -sf /run/shm/mjpeg/cam.jpg /var/www/dietpicam/cam.jpg + ln -sf /run/shm/mjpeg/status_mjpeg.txt /var/www/dietpicam/status_mjpeg.txt - Error_NoConnection_NoInstall + #Setup Raspimjpeg binary + cp bin/raspimjpeg /opt/vc/bin/raspimjpeg + chmod +x /opt/vc/bin/raspimjpeg + ln -s /opt/vc/bin/raspimjpeg /usr/bin/raspimjpeg - fi + #Cleanup / remove extracted source + cd "$HOME" + rm -R "$HOME"/RPi_Cam* fi @@ -4742,7 +4347,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI deluged deluge-web deluge-webui deluge-console + G_AGI deluged deluge-web deluge-webui deluge-console fi @@ -4752,27 +4357,20 @@ _EOF_ Banner_Installing - AGI python + G_AGI python #Download Grasshopper local grasshopper_directory='/var/www' INSTALL_URL_ADDRESS='http://sourceforge.net/projects/grasshopperwebapp/files/grasshopper_v5_application.zip/download' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O grasshopper.zip - unzip -o grasshopper.zip -d "$grasshopper_directory" - rm grasshopper.zip - - #Install - chmod +x "$grasshopper_directory"/install/install.sh - "$grasshopper_directory"/install/install.sh - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O grasshopper.zip + unzip -o grasshopper.zip -d "$grasshopper_directory" + rm grasshopper.zip - fi + #Install + chmod +x "$grasshopper_directory"/install/install.sh + "$grasshopper_directory"/install/install.sh fi @@ -4783,22 +4381,15 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://github.com/harmon25/raspcontrol/archive/master.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.zip - - unzip -o package.zip - rm package.zip - mkdir -p /var/www/raspcontrol - mv raspcontrol-master/* /var/www/raspcontrol - rm -R raspcontrol-master - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.zip - fi + unzip -o package.zip + rm package.zip + mkdir -p /var/www/raspcontrol + mv raspcontrol-master/* /var/www/raspcontrol + rm -R raspcontrol-master fi @@ -4809,21 +4400,14 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://www.webmin.com/download/deb/webmin-current.deb' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - - AGF - - rm package.deb - - else + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb - Error_NoConnection_NoInstall + G_AGF - fi + rm package.deb fi @@ -4834,25 +4418,18 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://packages.openmediavault.org/public' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - echo -e "deb $INSTALL_URL_ADDRESS erasmus main" > /etc/apt/sources.list.d/openmediavault.list - apt-get update + echo -e "deb $INSTALL_URL_ADDRESS erasmus main" > /etc/apt/sources.list.d/openmediavault.list + G_AGUP - AGI openmediavault-keyring + G_AGI openmediavault-keyring - debconf-set-selections <<< "openmediavault openmediavault/run-initsystem note" - debconf-set-selections <<< "postfix postfix/main_mailer_type select No configuration" + debconf-set-selections <<< "openmediavault openmediavault/run-initsystem note" + debconf-set-selections <<< "postfix postfix/main_mailer_type select No configuration" - apt-get update - AGI openmediavault postfix - - else - - Error_NoConnection_NoInstall - - fi + G_AGUP + G_AGI openmediavault postfix fi @@ -4863,21 +4440,14 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://github.com/ArturSierzant/OMPD/archive/master.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip -d /var/www/ - - rm -R /var/www/ompd &> /dev/null #Replace/upgrade existing installs - mv /var/www/OMPD* /var/www/ompd - rm package.zip - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip -d /var/www/ - fi + rm -R /var/www/ompd &> /dev/null #Replace/upgrade existing installs + mv /var/www/OMPD* /var/www/ompd + rm package.zip fi @@ -4887,7 +4457,7 @@ _EOF_ Banner_Installing - AGI darkice icecast2 + G_AGI darkice icecast2 fi @@ -4898,22 +4468,15 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://github.com/afaqurk/linux-dash/archive/master.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.zip - - unzip -o package.zip - rm package.zip - mkdir -p /var/www/linuxdash - mv linux-dash-master/* /var/www/linuxdash - rm -R linux-dash-master + G_CHECK_URL "$INSTALL_URL_ADDRESS" - else - - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.zip - fi + unzip -o package.zip + rm package.zip + mkdir -p /var/www/linuxdash + mv linux-dash-master/* /var/www/linuxdash + rm -R linux-dash-master fi @@ -4924,48 +4487,41 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://install.pi-hole.net' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - # - Pre-reqs: https://github.com/Fourdee/DietPi/issues/1282#issuecomment-350490524 - AGI "$PHP_APT_PACKAGE_NAME"-cgi "$PHP_APT_PACKAGE_NAME"-sqlite* + G_CHECK_URL "$INSTALL_URL_ADDRESS" - # - Check free available memory. Increase swapfile size to prevent gravity running out of mem. - if (( $(free -m | grep -m1 'Mem:' | awk '{print $4}') < 512 )); then + # - Pre-reqs: https://github.com/Fourdee/DietPi/issues/1282#issuecomment-350490524 + G_AGI "$PHP_APT_PACKAGE_NAME"-cgi "$PHP_APT_PACKAGE_NAME"-sqlite* - if [ -f /etc/dphys-swapfile ] && - (( $(grep 'CONF_SWAPSIZE=' /etc/dphys-swapfile | sed 's/.*=//') < 512 )); then + # - Check free available memory. Increase swapfile size to prevent gravity running out of mem. + if (( $(free -m | grep -m1 'Mem:' | awk '{print $4}') < 512 )); then - /DietPi/dietpi/func/dietpi-notify 2 "Increasing swapfile size to 512MB before running gravity.sh, please wait...\n" - /DietPi/dietpi/func/dietpi-set_dphys-swapfile 512 + if [ -f /etc/dphys-swapfile ] && + (( $(grep 'CONF_SWAPSIZE=' /etc/dphys-swapfile | sed 's/.*=//') < 512 )); then - fi + G_DIETPI-NOTIFY 2 "Increasing swapfile size to 512MB before running gravity.sh, please wait...\n" + /DietPi/dietpi/func/dietpi-set_dphys-swapfile 512 fi - # NB: PiHole currently replaces the lighttpd.conf file entirly and restricts webserver use to PiHole only. We dont want a limited webserver dedicated to PiHole, so lets avoid it. - mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.bak &> /dev/null - - # - Install - wget "$INSTALL_URL_ADDRESS" -O install.sh - chmod +x install.sh - ./install.sh - local exit_code=$? - if (( $exit_code != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 "Pi-Hole exited with code ($exit_code) and is not installed." - aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]=0 - - fi + fi - mv /etc/lighttpd/lighttpd.conf.bak /etc/lighttpd/lighttpd.conf &> /dev/null + # NB: PiHole currently replaces the lighttpd.conf file entirly and restricts webserver use to PiHole only. We dont want a limited webserver dedicated to PiHole, so lets avoid it. + mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.bak &> /dev/null - else + # - Install + wget "$INSTALL_URL_ADDRESS" -O install.sh + chmod +x install.sh + ./install.sh + local exit_code=$? + if (( $exit_code != 0 )); then - Error_NoConnection_NoInstall + G_DIETPI-NOTIFY 1 "Pi-Hole exited with code ($exit_code) and is not installed." + aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]=0 fi + mv /etc/lighttpd/lighttpd.conf.bak /etc/lighttpd/lighttpd.conf &> /dev/null + fi #SUBSONIC 5 @@ -4974,22 +4530,15 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS='http://sourceforge.net/projects/subsonic/files/subsonic/5.3/subsonic-5.3.deb/download' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - #AGI lame #conflicts with our ffmpeg package: https://github.com/Fourdee/DietPi/issues/946#issuecomment-300738228 - - #Install SubSonic 5.3 - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb - - else + INSTALL_URL_ADDRESS='https://sourceforge.net/projects/subsonic/files/subsonic/5.3/subsonic-5.3.deb/download' + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + #G_AGI lame #conflicts with our ffmpeg package: https://github.com/Fourdee/DietPi/issues/946#issuecomment-300738228 - fi + #Install SubSonic 5.3 + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb fi @@ -4999,22 +4548,15 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS='https://sourceforge.net/projects/subsonic/files/subsonic/6.0/subsonic-6.0.deb/download' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - #AGI lame #conflicts with our ffmpeg package: https://github.com/Fourdee/DietPi/issues/946#issuecomment-300738228 - - #Install SubSonic 6.0 - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb - - else + INSTALL_URL_ADDRESS='https://sourceforge.net/projects/subsonic/files/subsonic/6.1.3/subsonic-6.1.3.deb/download' + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + #G_AGI lame #conflicts with our ffmpeg package: https://github.com/Fourdee/DietPi/issues/946#issuecomment-300738228 - fi + #Install SubSonic 6.0 + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb fi @@ -5025,19 +4567,12 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://github.com/weaved/installer/raw/master/Raspbian%20deb/1.3-07/weavedconnectd_1.3-07v_armhf.deb' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - #Install WEAVED - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb + G_CHECK_URL "$INSTALL_URL_ADDRESS" - else - - Error_NoConnection_NoInstall - - fi + #Install WEAVED + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb fi @@ -5057,12 +4592,12 @@ _EOF_ # >= v111 image if [ -f /etc/.dietpi_image_version ]; then - AGI python-rpi.gpio python3-rpi.gpio + G_AGI python-rpi.gpio python3-rpi.gpio # - < v111 Bug in older DietPi images with sources.list | Use pip, as offical repo = python3-rpi.gpio: Depends: python3 (< 3.3) but 3.4.2-2 is to be installed else - AGI python3-pip + G_AGI python3-pip pip3 install RPi.GPIO fi @@ -5076,61 +4611,53 @@ _EOF_ Banner_Installing # - RPi - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then # http://git.drogon.net/?p=wiringPi;a=shortlog;h=refs/heads/master snapshot INSTALL_URL_ADDRESS='http://git.drogon.net/?p=wiringPi;a=snapshot;h=HEAD;sf=tgz' # - Odroid's - elif (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then + elif (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )); then INSTALL_URL_ADDRESS='https://github.com/hardkernel/wiringPi/archive/master.zip' # - BPiPro - elif (( $HW_MODEL == 51 )); then + elif (( $G_HW_MODEL == 51 )); then INSTALL_URL_ADDRESS='https://github.com/LeMaker/WiringBP/archive/bananapro.zip' fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then - - # - RPi - if (( $HW_MODEL < 10 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.tar - tar xfz package.tar - rm package.tar - - # - Odroid's / BPI - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip package.zip - rm package.zip + # - RPi + if (( $G_HW_MODEL < 10 )); then - fi + wget "$INSTALL_URL_ADDRESS" -O package.tar + tar xfz package.tar + rm package.tar - if (( $HW_MODEL == 51 )); then + # - Odroid's / BPI + else - mv WiringBP* wiringPi + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip package.zip + rm package.zip - fi + fi - cd wiringPi* - chmod +x build - ./build - cd "$HOME" + if (( $G_HW_MODEL == 51 )); then - #rm -R /root/wiringPi* #Also Contains example code for users. + mv WiringBP* wiringPi - else + fi - Error_NoConnection_NoInstall + cd wiringPi* + chmod +x build + ./build + cd "$HOME" - fi + #rm -R /root/wiringPi* #Also Contains example code for users. fi @@ -5150,12 +4677,12 @@ _EOF_ Banner_Installing - AGI python python3 + G_AGI python python3 # - RPi, pre-reqs GPIO control for Node-Red - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then - AGI python-rpi.gpio + G_AGI python-rpi.gpio fi @@ -5170,31 +4697,57 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS="http://repo.mosquitto.org/debian/mosquitto-$DISTRO_NAME.list" - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then + if (( $G_DISTRO > 4 )); then - wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key - apt-key add mosquitto-repo.gpg.key - rm mosquitto-repo.gpg.key + # On Buster, we can use current APT package from Debian repo + G_AGI mosquitto - wget "$INSTALL_URL_ADDRESS" -O /etc/apt/sources.list.d/mosquitto-"$DISTRO_NAME".list + else - # - ARM64 - if (( $HW_ARCH == 3 )); then + # - ARMv8 + if (( $G_HW_ARCH == 3 )); then - echo -e "deb [arch=armhf] http://repo.mosquitto.org/debian $DISTRO_NAME main" > /etc/apt/sources.list.d/mosquitto-"$DISTRO_NAME".list dpkg --add-architecture armhf + G_AGUP fi - apt-get update + #Pre-Req + # - libssl1.0.0 no longer available: https://github.com/Fourdee/DietPi/issues/1299 + INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/' - AGI mosquitto + # - ARMv6/7/8 + if (( $G_HW_ARCH >= 1 && $G_HW_ARCH <= 3 )); then - else + INSTALL_URL_ADDRESS+='libssl1.0.0_1.0.1t-1+deb8u7_armhf.deb' + + # - x86_64 + elif (( $G_HW_ARCH == 10 )); then + + INSTALL_URL_ADDRESS+='libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb' + + fi + G_CHECK_URL "$INSTALL_URL_ADDRESS" + + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb + + INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/mosquitto_1.4.14-0mosquitto1_nows1_armhf.deb' + if (( $G_HW_ARCH == 10 )); then + + INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/mosquitto_1.4.14-0mosquitto1_nows1_amd64.deb' + + fi + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.deb + + #Install deb + # Allow error, so we can install additional required packages automatically + dpkg -i package.deb + G_AGF + rm package.deb fi @@ -5208,25 +4761,17 @@ _EOF_ #Binary URL fails connection test, so we need to parent back a little: https://github.com/Fourdee/DietPi/issues/445#issuecomment-283400449 INSTALL_URL_ADDRESS='https://github.com/blynkkk/blynk-server/releases' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then - - mkdir -p /etc/blynkserver - - INSTALL_URL_ADDRESS='https://github.com/blynkkk/blynk-server/releases/download/v0.25.2/server-0.25.2.jar' - wget "$INSTALL_URL_ADDRESS" -O /etc/blynkserver/server.jar - - # - Install Blynk JS Libary - AGI python - npm install -g onoff - npm install -g blynk-library + G_CHECK_URL "$INSTALL_URL_ADDRESS" - else + mkdir -p /etc/blynkserver - Error_NoConnection_NoInstall + INSTALL_URL_ADDRESS='https://github.com/blynkkk/blynk-server/releases/download/v0.29.7/server-0.29.7-java8.jar' + wget "$INSTALL_URL_ADDRESS" -O /etc/blynkserver/server.jar - fi + # - Install Blynk JS Libary + G_AGI python + npm install -g onoff + npm install -g blynk-library fi @@ -5237,7 +4782,7 @@ _EOF_ Banner_Installing # - Skip license for NAA daemon if needed: - if (( ! $USER_INPUTS )); then + if (( ! $G_USER_INPUTS )); then debconf-set-selections <<< "networkaudiod networkaudiod/license note false" @@ -5247,54 +4792,42 @@ _EOF_ local apackages=() # Jessie - requires stretch packages - if (( $DISTRO == 3 )); then + if (( $G_DISTRO == 3 )); then apackages+=('http://dietpi.com/downloads/binaries/all/gcc-6-base_6.3.0-6_armhf.deb') apackages+=('http://dietpi.com/downloads/binaries/all/libstdc++6_6.3.0-6_armhf.deb') fi - apackages+=('https://www.signalyst.eu/bins/naa/linux/stretch/networkaudiod_3.5.1-35_armhf.deb') + apackages+=('https://www.signalyst.eu/bins/naa/linux/stretch/networkaudiod_3.5.2-36_armhf.deb') # - check online for ((i=0; i<${#apackages[@]}; i++)) do INSTALL_URL_ADDRESS="${apackages[$i]}" - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? != 0 )); then - - Error_NoConnection_NoInstall - - break - - fi + G_CHECK_URL "$INSTALL_URL_ADDRESS" done - # - install (Error_NoConnection_NoInstall() sets state to 0) - if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - - # - Prereqs - AGI libasound2 - - # - Stretch, install additional packages - if (( $DISTRO == 4 )); then + # - Prereqs + G_AGI libasound2 - AGI gcc-6-base libstdc++6 + # - Stretch, install additional packages + if (( $G_DISTRO >= 4 )); then - fi + G_AGI gcc-6-base libstdc++6 - for ((i=0; i<${#apackages[@]}; i++)) - do + fi - wget "${apackages[$i]}" -O package.deb - dpkg -i package.deb - rm package.deb + for ((i=0; i<${#apackages[@]}; i++)) + do - done + wget "${apackages[$i]}" -O package.deb + dpkg -i package.deb + rm package.deb - fi + done unset apackages @@ -5309,7 +4842,7 @@ _EOF_ Banner_Installing - AGI tomcat8 + G_AGI tomcat8 fi @@ -5319,37 +4852,30 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS='http://sourceforge.net/projects/webiopi/files/WebIOPi-0.7.1.tar.gz/download' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then + INSTALL_URL_ADDRESS='https://sourceforge.net/projects/webiopi/files/WebIOPi-0.7.1.tar.gz/download' + G_CHECK_URL "$INSTALL_URL_ADDRESS" - #Python dev, pre-reqs - AGI python-dev python-setuptools --no-install-recommends + #Python dev, pre-reqs + G_AGI python-dev python-setuptools --no-install-recommends - #Install WEBIOPI - wget "$INSTALL_URL_ADDRESS" -O package.tar - tar xvzf package.tar - rm package.tar - - cd WebIOPi* + #Install WEBIOPI + wget "$INSTALL_URL_ADDRESS" -O package.tar + tar xvzf package.tar + rm package.tar - #Automate Weaved prompt - sed -i '/read response/c\response="n"' setup.sh - - #Run setup script - ./setup.sh - clear - - cd .. + cd WebIOPi* - #Cleanup - rm -R WebIOPi* + #Automate Weaved prompt + sed -i '/read response/c\response="n"' setup.sh - else + #Run setup script + ./setup.sh + clear - Error_NoConnection_NoInstall + cd .. - fi + #Cleanup + rm -R WebIOPi* fi @@ -5361,7 +4887,7 @@ _EOF_ #LCD panels can be enabled in Dietpi-config > display options # XU4 enable cloudshell - if (( $HW_MODEL == 11 )); then + if (( $G_HW_MODEL == 11 )); then /DietPi/dietpi/func/dietpi-set_hardware lcdpanel odroid-cloudshell @@ -5376,43 +4902,34 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS='http://www.haproxy.org/download/1.7/src/haproxy-1.7.2.tar.gz' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + INSTALL_URL_ADDRESS='https://www.haproxy.org/download/1.8/src/haproxy-1.8.2.tar.gz' + G_CHECK_URL "$INSTALL_URL_ADDRESS" - #Install - if (( $? == 0 )); then + #Download HAPROXY + wget "$INSTALL_URL_ADDRESS" -O package.tar + tar -xvf package.tar + rm package.tar - #Download HAPROXY - wget "$INSTALL_URL_ADDRESS" -O package.tar - tar -xvf package.tar - rm package.tar - - cd haproxy-* - - #Pre-reqs - AGI libpcre3-dev libssl-dev - #Compile and install - make -j $CPU_CORES_TOTAL TARGET=linux2628 CPU=generic USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 USE_LINUX_SPLICE=1 - make install + cd haproxy-* - mkdir /etc/haproxy + #Pre-reqs + G_AGI libpcre3-dev libssl-dev zlib1g-dev + #Compile and install + make -j $G_HW_CPU_CORES TARGET=linux2628 CPU=generic USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 USE_LINUX_SPLICE=1 + make install - #Exit directory - cd .. + mkdir /etc/haproxy - #Clean up - rm -R haproxy-* + #Exit directory + cd .. - #Install init script as service - cp /DietPi/dietpi/conf/haproxy_init /etc/init.d/haproxy - chmod +x /etc/init.d/haproxy - update-rc.d haproxy defaults + #Clean up + rm -R haproxy-* - else - - Error_NoConnection_NoInstall - - fi + #Install init script as service + cp /DietPi/dietpi/conf/haproxy_init /etc/init.d/haproxy + chmod +x /etc/init.d/haproxy + update-rc.d haproxy defaults fi @@ -5422,41 +4939,50 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/logitechmediaserver_7.9.0_all.deb' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + #Stretch + if (( $G_DISTRO >= 4 )); then - #Install - if (( $? == 0 )); then + #Untested ARMv8 + if (( $G_HW_ARCH == 3 )); then + + dpkg --add-architecture armhf + G_AGUP + fi + + INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/logitechmediaserver_7.9.1_armv7-(stretch).deb' wget "$INSTALL_URL_ADDRESS" -O package.deb dpkg -i package.deb rm package.deb + G_AGF - #https://github.com/Fourdee/DietPi/issues/736 - AGF + else - #Stop service - service logitechmediaserver stop + INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/logitechmediaserver_7.9.0_all.deb' + G_CHECK_URL "$INSTALL_URL_ADDRESS" - #Stretch - # Compile pre-req CPAN modules??? - # if (( $DISTRO >= 4 )); then + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb - # AGI yasm git build-essential automake cpanminus nasm libxml-parser-perl libexpat1-dev libgif-dev zlib1g-dev libjpeg-dev libpng-dev + #https://github.com/Fourdee/DietPi/issues/736 + G_AGF + #Stop service + service logitechmediaserver stop # + ARMv6 cpan - if (( $HW_ARCH == 1 )); then + if (( $G_HW_ARCH == 1 )); then wget http://dietpi.com/downloads/binaries/all/logitechmediaserver_7.9.0_CPAN_5.20_armv6hf.tar.gz -O package.tar tar xvzf package.tar -C / rm package.tar # + ARM64 cpan - elif (( $HW_ARCH == 3 )); then + elif (( $G_HW_ARCH == 3 )); then - AGI libxml-parser-perl - AGI zlib1g-dev libjpeg-dev libpng-dev libjpeg62-turbo-dev # shared libs needed for Image::Scale@0.08 + G_AGI libxml-parser-perl + G_AGI zlib1g-dev libjpeg-dev libpng-dev libjpeg62-turbo-dev # shared libs needed for Image::Scale@0.08 wget http://dietpi.com/downloads/binaries/all/DietPi-LMS7.9-CPAN_arm64.zip -O package.zip unzip -o package.zip -d /usr/share/squeezeboxserver @@ -5464,10 +4990,6 @@ _EOF_ fi - else - - Error_NoConnection_NoInstall - fi fi @@ -5478,22 +5000,12 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS='https://wordpress.org/latest.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip -d /var/www/ - rm package.zip - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall - - fi + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip -d /var/www/ + rm package.zip fi @@ -5503,7 +5015,7 @@ _EOF_ Banner_Installing - AGI tightvncserver x11vnc --no-install-recommends + G_AGI tightvncserver x11vnc --no-install-recommends fi @@ -5513,12 +5025,12 @@ _EOF_ Banner_Installing - AGI vnc4server x11vnc --no-install-recommends + G_AGI vnc4server x11vnc --no-install-recommends # - Stretch+ - if (( $DISTRO >= 4 )); then + if (( $G_DISTRO >= 4 )); then - AGI tigervnc-common + G_AGI tigervnc-common fi @@ -5531,27 +5043,18 @@ _EOF_ Banner_Installing # INSTALL_URL_ADDRESS='https://www.realvnc.com/download/binary/latest/debian/arm/' - # /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + # G_CHECK_URL "$INSTALL_URL_ADDRESS" - ##Install - # if (( $? == 0 )); then + # wget "$INSTALL_URL_ADDRESS" -O package.tar.gz + # tar xvf package.tar.gz + # rm package.tar.gz - # wget "$INSTALL_URL_ADDRESS" -O package.tar.gz - # tar xvf package.tar.gz - # rm package.tar.gz + # dpkg -i VNC*.deb - # dpkg -i VNC*.deb - - # rm VNC*.deb - - # else - - # Error_NoConnection_NoInstall - - # fi + # rm VNC*.deb # - Available in Raspbian apt - AGI realvnc-vnc-server + G_AGI realvnc-vnc-server fi @@ -5563,7 +5066,7 @@ _EOF_ touch /var/log/auth.log #: https://github.com/Fourdee/DietPi/issues/475#issuecomment-310873879 - AGI fail2ban --no-install-recommends + G_AGI fail2ban --no-install-recommends fi @@ -5575,21 +5078,12 @@ _EOF_ INSTALL_URL_ADDRESS='https://github.com/phpsysinfo/phpsysinfo/archive/master.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip -d /var/www/ - rm package.zip - mv /var/www/phpsysinfo-* /var/www/phpsysinfo + G_CHECK_URL "$INSTALL_URL_ADDRESS" - else - - Error_NoConnection_NoInstall - - fi + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip -d /var/www/ + rm package.zip + mv /var/www/phpsysinfo-* /var/www/phpsysinfo fi @@ -5601,20 +5095,11 @@ _EOF_ INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/Single_File_PHP_Gallery_4.6.1.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip -d /var/www/gallery - rm package.zip - - else - - Error_NoConnection_NoInstall + G_CHECK_URL "$INSTALL_URL_ADDRESS" - fi + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip -d /var/www/gallery + rm package.zip fi @@ -5624,35 +5109,25 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS='https://github.com/ampache/ampache/archive/master.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip - rm package.zip - mv ampache-* /var/www/ampache - - #composer install required for 3.8.2 - php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php - php composer-setup.php - php -r "unlink('composer-setup.php');" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - mv composer.phar /usr/local/bin/composer + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip + rm package.zip + mv ampache-* /var/www/ampache - cd /var/www/ampache - composer install --prefer-source --no-interaction - cd "$HOME" - - else + #composer install required for 3.8.2 + php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php + php composer-setup.php + php -r "unlink('composer-setup.php');" - Error_NoConnection_NoInstall + mv composer.phar /usr/local/bin/composer - fi + cd /var/www/ampache + composer install --prefer-source --no-interaction + cd "$HOME" fi @@ -5662,7 +5137,7 @@ _EOF_ Banner_Installing - AGI openvpn easy-rsa iptables + G_AGI openvpn easy-rsa iptables fi @@ -5672,49 +5147,43 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS='https://install.pivpn.io' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - #Install - if (( $? == 0 )); then + G_AGI lsb-release - AGI lsb-release + # - Requires underpriv user: https://github.com/Fourdee/DietPi/issues/570#issuecomment-255588307 + useradd pivpn + mkdir -p /home/pivpn - # - Requires underpriv user: https://github.com/Fourdee/DietPi/issues/570#issuecomment-255588307 - useradd pivpn - mkdir -p /home/pivpn + while true + do - while true - do + wget "$INSTALL_URL_ADDRESS" -O pivpn_install.sh + chmod +x pivpn_install.sh - wget "$INSTALL_URL_ADDRESS" -O pivpn_install.sh - chmod +x pivpn_install.sh + # - Disable reboot + sed -i '/shutdown[[:space:]]/d' pivpn_install.sh - # - Disable reboot - sed -i '/shutdown[[:space:]]/d' pivpn_install.sh + ./pivpn_install.sh + if (( $? != 0 )); then - ./pivpn_install.sh + whiptail --title "PiVPN failed/aborted" --yesno "The PiVPN installer was not successful and/or canceled prior to its completion.\n\nWould you like DietPi to run the PiVPN installer again?" --backtitle "$WHIP_BACKTITLE" --defaultno 12 70 if (( $? != 0 )); then - whiptail --title "PiVPN failed/aborted" --yesno "The PiVPN installer was not successful and/or canceled prior to its completion.\n\nWould you like DietPi to run the PiVPN installer again?" --backtitle "$WHIP_BACKTITLE" --defaultno 12 70 - if (( $? != 0 )); then - - aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]=0 - break - - fi - - else - - rm pivpn_install.sh + aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]=0 break fi - done + else - fi + rm pivpn_install.sh + break + + fi + + done fi @@ -5724,44 +5193,36 @@ _EOF_ Banner_Installing - if (( $DISTRO >= 4 )); then + if (( $G_DISTRO >= 4 )); then - AGI certbot + G_AGI certbot if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then - AGI python-certbot-apache + G_AGI python-certbot-apache fi if (( ${aSOFTWARE_INSTALL_STATE[85]} >= 1 )); then - AGI python-certbot-nginx + G_AGI python-certbot-nginx fi else INSTALL_URL_ADDRESS='https://github.com/certbot/certbot/archive/master.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip -d /root - rm package.zip - mv certbot* /etc/certbot_scripts - - # - Install packages - cd /etc/certbot_scripts - ./certbot-auto -n --os-packages-only - cd ~/ + G_CHECK_URL "$INSTALL_URL_ADDRESS" - else - - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip -d /root + rm package.zip + mv certbot* /etc/certbot_scripts - fi + # - Install packages + cd /etc/certbot_scripts + ./certbot-auto -n --os-packages-only + cd ~/ fi @@ -5782,82 +5243,104 @@ _EOF_ INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/hostapd_2.5_all.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - #Install - if (( $? == 0 )); then + # - Prereqs + G_AGI hostapd isc-dhcp-server iptables libnl-3-200 - # - Prereqs - AGI hostapd isc-dhcp-server iptables libnl-3-200 + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip + rm package.zip - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip - rm package.zip + # - Check for RTL8188C* device, use the patched binary I compiled: https://github.com/pritambaral/hostapd-rtl871xdrv#why + if (( $(lsusb | grep -ci -m1 'RTL8188C') || + $G_HW_MODEL == 70 )); then #Force RTL for allo provided WiFi dongle + + WIFIHOTSPOT_RTL8188C_DEVICE=1 + + fi - # - Check for RTL8188C* device, use the patched binary I compiled: https://github.com/pritambaral/hostapd-rtl871xdrv#why - if (( $(lsusb | grep -ci -m1 'RTL8188C') || - $HW_MODEL == 70 )); then #Force RTL for allo provided WiFi dongle + #Which binary to install + local filename_hostapd='' + local filename_hostapd_cli='' - WIFIHOTSPOT_RTL8188C_DEVICE=1 + # - armv6 + if (( $G_HW_ARCH == 1 )); then + + filename_hostapd='hostapd-nl80211-armv6' + filename_hostapd_cli='hostapd_cli-armv6' + + if (( $WIFIHOTSPOT_RTL8188C_DEVICE )); then + + filename_hostapd='hostapd-rtl8188c-armv6' fi - #Which binary to install - local filename_hostapd='' - local filename_hostapd_cli='' + # - armv7+ + elif (( $G_HW_ARCH == 2 )); then + + filename_hostapd='hostapd-nl80211-armv7' + filename_hostapd_cli='hostapd_cli-armv7' - # - armv6 - if (( $HW_ARCH == 1 )); then + if (( $WIFIHOTSPOT_RTL8188C_DEVICE )); then - filename_hostapd='hostapd-nl80211-armv6' - filename_hostapd_cli='hostapd_cli-armv6' + filename_hostapd='hostapd-rtl8188c-armv7' - if (( $WIFIHOTSPOT_RTL8188C_DEVICE )); then + fi - filename_hostapd='hostapd-rtl8188c-armv6' + # - arm64 + elif (( $G_HW_ARCH == 3 )); then - fi + filename_hostapd='hostapd-nl80211-arm64' + filename_hostapd_cli='hostapd_cli-arm64' - # - armv7+ - elif (( $HW_ARCH == 2 )); then + if (( $WIFIHOTSPOT_RTL8188C_DEVICE )); then - filename_hostapd='hostapd-nl80211-armv7' - filename_hostapd_cli='hostapd_cli-armv7' + filename_hostapd='hostapd-rtl8188c-arm64' - if (( $WIFIHOTSPOT_RTL8188C_DEVICE )); then + fi - filename_hostapd='hostapd-rtl8188c-armv7' + fi - fi + mv "$filename_hostapd" /usr/sbin/hostapd + mv "$filename_hostapd_cli" /usr/sbin/hostapd_cli - # - arm64 - elif (( $HW_ARCH == 3 )); then + chmod +x /usr/sbin/hostapd + chmod +x /usr/sbin/hostapd_cli - filename_hostapd='hostapd-nl80211-arm64' - filename_hostapd_cli='hostapd_cli-arm64' + rm hostapd-* - if (( $WIFIHOTSPOT_RTL8188C_DEVICE )); then + #Enable wifi modules + /DietPi/dietpi/func/dietpi-set_hardware wifimodules enable - filename_hostapd='hostapd-rtl8188c-arm64' + # - Stretch, libssl1.0.0 no longer available: https://github.com/Fourdee/DietPi/issues/1299 + # Possibly only needed for RPi, however, no harm in installing, cover all bases. + if (( $G_DISTRO >= 4 )); then - fi + INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/' - fi + # - ARMv6/7 + if (( $G_HW_ARCH == 1 || $G_HW_ARCH == 2 )); then + + INSTALL_URL_ADDRESS+='libssl1.0.0_1.0.1t-1+deb8u7_armhf.deb' - mv "$filename_hostapd" /usr/sbin/hostapd - mv "$filename_hostapd_cli" /usr/sbin/hostapd_cli + # - ARM64 + elif (( $G_HW_ARCH == 3 )); then - chmod +x /usr/sbin/hostapd - chmod +x /usr/sbin/hostapd_cli + INSTALL_URL_ADDRESS+='libssl1.0.0_1.0.1t-1+deb8u7_arm64.deb' - rm hostapd-* + # - x86_64 + elif (( $G_HW_ARCH == 10 )); then - #Enable wifi modules - /DietPi/dietpi/func/dietpi-set_hardware wifimodules enable + INSTALL_URL_ADDRESS+='libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb' - else + fi + + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb fi @@ -5871,7 +5354,7 @@ _EOF_ Banner_Installing # - Prereqs - AGI tor + G_AGI tor fi @@ -5884,77 +5367,66 @@ _EOF_ INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/shairport-sync_3.1.3_' # - ARMv6 - if (( $HW_ARCH == 1 )); then + if (( $G_HW_ARCH == 1 )); then INSTALL_URL_ADDRESS+='armv6.7z' # - ARMv7 - elif (( $HW_ARCH == 2 )); then + elif (( $G_HW_ARCH == 2 )); then INSTALL_URL_ADDRESS+='armv7.7z' # - ARM64 - elif (( $HW_ARCH == 3 )); then + elif (( $G_HW_ARCH == 3 )); then INSTALL_URL_ADDRESS+='arm64.7z' - fi - - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - # - Prereqs - AGI openssl libsoxr0 libavahi-client3 libtool libconfig9 libpopt0 libdaemon0 --no-install-recommends - - # This occured on C2: shairport-sync : Depends: libpopt-dev but it is not installed - #AGI libpopt-dev + # - x86_64 + # elif (( $G_HW_ARCH == 10 )); then - wget "$INSTALL_URL_ADDRESS" -O package.7z - 7z x -y package.7z -o/ - rm package.7z + # INSTALL_URL_ADDRESS+='amd64.7z' - # - Stretch, libssl1.0.0 no longer available - if (( $DISTRO >= 4 )); then + fi - # - ARMv6 - if (( $HW_ARCH == 1 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - INSTALL_URL_ADDRESS='http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u6_armhf.deb' + # - Prereqs + G_AGI openssl libsoxr0 libavahi-client3 libtool libconfig9 libpopt0 libdaemon0 --no-install-recommends - # - ARMv7 - elif (( $HW_ARCH == 2 )); then + # This occured on C2: shairport-sync : Depends: libpopt-dev but it is not installed + #G_AGI libpopt-dev - INSTALL_URL_ADDRESS='http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u6_armhf.deb' + wget "$INSTALL_URL_ADDRESS" -O package.7z + 7z x -y package.7z -o/ + rm package.7z - # - ARM64 - elif (( $HW_ARCH == 3 )); then + # - Stretch, libssl1.0.0 no longer available + if (( $G_DISTRO >= 4 )); then - INSTALL_URL_ADDRESS='http://ftp.us.debian.org/debian/pool/main/o/openssl/libssl1.0.0_1.0.1t-1+deb8u6_arm64.deb' + INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/' - fi + # - ARMv6/7 + if (( $G_HW_ARCH == 1 || $G_HW_ARCH == 2 )); then - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + INSTALL_URL_ADDRESS+='libssl1.0.0_1.0.1t-1+deb8u7_armhf.deb' - #Install - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb + # - ARM64 + elif (( $G_HW_ARCH == 3 )); then - else + INSTALL_URL_ADDRESS+='libssl1.0.0_1.0.1t-1+deb8u7_arm64.deb' - Error_NoConnection_NoInstall + # - x86_64 + elif (( $G_HW_ARCH == 10 )); then - fi + INSTALL_URL_ADDRESS+='libssl1.0.0_1.0.1t-1+deb8u7_amd64.deb' fi - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb fi @@ -5968,22 +5440,13 @@ _EOF_ #check folder is online INSTALL_URL_ADDRESS='http://dietpi.com/downloads/conf/BruteFIR/' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - # - Prereqs - AGI brutefir + G_CHECK_URL "$INSTALL_URL_ADDRESS" - wget -r -nH --cut-dirs=2 --no-parent --reject="index.htm*" -e robots=off "$INSTALL_URL_ADDRESS" - mv BruteFIR /etc/ - - else - - Error_NoConnection_NoInstall + # - Prereqs + G_AGI brutefir - fi + wget -r -nH --cut-dirs=2 --no-parent --reject="index.htm*" -e robots=off "$INSTALL_URL_ADDRESS" + mv BruteFIR /etc/ fi @@ -5994,22 +5457,13 @@ _EOF_ Banner_Installing #check folder is online - INSTALL_URL_ADDRESS='https://download.pydio.com/pub/core/archives/pydio-core-8.0.1.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip -d /var/www - mv /var/www/pydio-core-* /var/www/pydio - rm package.zip - - else + INSTALL_URL_ADDRESS='https://download.pydio.com/pub/core/archives/pydio-core-8.0.2.zip' + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall - - fi + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip -d /var/www + mv /var/www/pydio-core-* /var/www/pydio + rm package.zip fi @@ -6020,53 +5474,43 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/squeezelite-1.8_all.7z' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - # - Prereqs - AGI squeezelite - - # - Overwrite binary with latest version: - wget "$INSTALL_URL_ADDRESS" -O package.7z - 7z x -y package.7z -o/usr/bin - rm package.7z - - rm /usr/bin/squeezelite + G_CHECK_URL "$INSTALL_URL_ADDRESS" - local target_binary='' - - if (( $HW_ARCH == 1 )); then + # - Prereqs + G_AGI squeezelite - target_binary='squeezelite_armv6' + # - Overwrite binary with latest version: + wget "$INSTALL_URL_ADDRESS" -O package.7z + 7z x -y package.7z -o/usr/bin + rm package.7z - # - ARMv7 - elif (( $HW_ARCH == 2 )); then + rm /usr/bin/squeezelite - target_binary='squeezelite_armv7' + local target_binary='' - # - ARM64 - elif (( $HW_ARCH == 3 )); then + if (( $G_HW_ARCH == 1 )); then - target_binary='squeezelite_arm64' + target_binary='squeezelite_armv6' - # - x86_64 - elif (( $HW_ARCH == 10 )); then + # - ARMv7 + elif (( $G_HW_ARCH == 2 )); then - target_binary='squeezelite_amd64' + target_binary='squeezelite_armv7' - fi + # - ARM64 + elif (( $G_HW_ARCH == 3 )); then - ln -sf /usr/bin/"$target_binary" /usr/bin/squeezelite - chmod +x /usr/bin/squeezelite + target_binary='squeezelite_arm64' - else + # - x86_64 + elif (( $G_HW_ARCH == 10 )); then - Error_NoConnection_NoInstall + target_binary='squeezelite_amd64' fi + ln -sf /usr/bin/"$target_binary" /usr/bin/squeezelite + chmod +x /usr/bin/squeezelite fi @@ -6078,30 +5522,21 @@ _EOF_ #check, is online INSTALL_URL_ADDRESS='https://github.com/Fourdee/emonhub/archive/emon-pi.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - # - Prereqs - AGI minicom python-serial python-configobj --no-install-recommends - pip install paho-mqtt pydispatcher - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip - rm package.zip - - # - move everything to /etc/emonhub - rm -R /etc/emonhub - mkdir -p /etc/emonhub - mv emonhub-*/* /etc/emonhub/ - rm -R emonhub-* + G_CHECK_URL "$INSTALL_URL_ADDRESS" - else + # - Prereqs + G_AGI minicom python-serial python-configobj --no-install-recommends + pip install paho-mqtt pydispatcher - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip + rm package.zip - fi + # - move everything to /etc/emonhub + rm -R /etc/emonhub + mkdir -p /etc/emonhub + mv emonhub-*/* /etc/emonhub/ + rm -R emonhub-* fi @@ -6112,24 +5547,15 @@ _EOF_ Banner_Installing #check, is online - INSTALL_URL_ADDRESS='https://github.com/XavierBerger/RPi-Monitor-deb/raw/a7ae61cec8589b0fe1a835170ff34a268ab4a295/packages/rpimonitor_2.11-r5_all.deb' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb - - # - Prereqs - apt-get -f -y install - - else + INSTALL_URL_ADDRESS='https://github.com/XavierBerger/RPi-Monitor-deb/raw/master/packages/rpimonitor_2.12-r0_all.deb' + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb - fi + # - Prereqs + apt-get -f -y install fi @@ -6142,45 +5568,36 @@ _EOF_ INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/netdata_1.6.0_' #armv6 - if (( $HW_ARCH == 1 )); then + if (( $G_HW_ARCH == 1 )); then INSTALL_URL_ADDRESS+='armv6.deb' #armv7+ - elif (( $HW_ARCH == 2 )); then + elif (( $G_HW_ARCH == 2 )); then INSTALL_URL_ADDRESS+='armv7.deb' #ARMv8 - elif (( $HW_ARCH == 3 )); then + elif (( $G_HW_ARCH == 3 )); then INSTALL_URL_ADDRESS+='arm64.deb' #amd64 - elif (( $HW_ARCH == 10 )); then + elif (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS+='amd64.deb' fi #check, is online - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - # - For compression - AGI --no-install-recommends zlib1g-dev - - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb + G_CHECK_URL "$INSTALL_URL_ADDRESS" - else - - Error_NoConnection_NoInstall + # - For compression + G_AGI --no-install-recommends zlib1g-dev - fi + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb fi @@ -6192,21 +5609,12 @@ _EOF_ #check folder is online INSTALL_URL_ADDRESS='https://github.com/fruux/Baikal/archive/master.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - #Install - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip -d /var/www - rm package.zip - mv /var/www/Baikal* /var/www/baikal - - else - - Error_NoConnection_NoInstall - - fi + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip -d /var/www + rm package.zip + mv /var/www/Baikal* /var/www/baikal fi @@ -6216,7 +5624,7 @@ _EOF_ Banner_Installing - AGI mumble-server + G_AGI mumble-server fi @@ -6230,78 +5638,75 @@ _EOF_ INSTALL_URL_ADDRESS='http://download.opensuse.org/repositories/home:/emby/xUbuntu_14.04/' # x86_64, use Debian repos - if (( $HW_ARCH == 10 )); then + if (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS='http://download.opensuse.org/repositories/home:/emby/Debian_' - if (( $DISTRO == 3 )); then + if (( $G_DISTRO == 3 )); then INSTALL_URL_ADDRESS+='8.0' - elif (( $DISTRO == 4 )); then + elif (( $G_DISTRO == 4 )); then INSTALL_URL_ADDRESS+='9.0' + elif (( $G_DISTRO == 5 )); then + + # http://download.opensuse.org/repositories/home:/emby/Debian_Next/ + INSTALL_URL_ADDRESS+='Next' + fi INSTALL_URL_ADDRESS+='/' fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then - - echo -e "deb $INSTALL_URL_ADDRESS /" > /etc/apt/sources.list.d/emby-server.list - wget "$INSTALL_URL_ADDRESS"Release.key - apt-key add - < Release.key - rm Release.key - apt-get update + G_CHECK_URL "$INSTALL_URL_ADDRESS" - #ARMv7, Grab required pre-reqs from various sources: https://github.com/Fourdee/DietPi/issues/1128#issuecomment-326743471 / https://github.com/Fourdee/DietPi/issues/1150#issuecomment-330291298 - if (( $HW_ARCH == 2 )); then + echo -e "deb $INSTALL_URL_ADDRESS /" > /etc/apt/sources.list.d/emby-server.list + wget "$INSTALL_URL_ADDRESS"Release.key + apt-key add - < Release.key + rm Release.key + G_AGUP - wget http://ftp.us.debian.org/debian/pool/main/libj/libjpeg8/libjpeg8_8d-1+deb7u1_armhf.deb -O package.deb - dpkg -i package.deb - rm package.deb - - wget http://ftp.us.debian.org/debian/pool/main/libp/libpng/libpng12-0_1.2.50-2+deb8u3_armhf.deb -O package.deb - dpkg -i package.deb - rm package.deb + #ARMv7, Grab required pre-reqs from various sources: https://github.com/Fourdee/DietPi/issues/1128#issuecomment-326743471 / https://github.com/Fourdee/DietPi/issues/1150#issuecomment-330291298 + if (( $G_HW_ARCH == 2 )); then - wget http://ftp.us.debian.org/debian/pool/main/libw/libwebp/libwebp5_0.4.1-1.2+b2_armhf.deb -O package.deb - dpkg -i package.deb - rm package.deb - - #ARMv8 - elif (( $HW_ARCH == 3 )); then - - wget http://ftp.us.debian.org/debian/pool/main/libp/libpng/libpng12-0_1.2.50-2+deb8u3_arm64.deb -O package.deb - dpkg -i package.deb - rm package.deb + wget http://ftp.us.debian.org/debian/pool/main/libj/libjpeg8/libjpeg8_8d-1+deb7u1_armhf.deb -O package.deb + dpkg -i package.deb + rm package.deb - wget http://ftp.us.debian.org/debian/pool/main/libw/libwebp/libwebp5_0.4.1-1.2+b2_arm64.deb -O package.deb - dpkg -i package.deb - rm package.deb + wget http://ftp.us.debian.org/debian/pool/main/libp/libpng/libpng12-0_1.2.50-2+deb8u3_armhf.deb -O package.deb + dpkg -i package.deb + rm package.deb - wget https://mirror.i-novus.ru/ubuntu-ports/pool/main/libj/libjpeg-turbo/libjpeg-turbo8_1.3.0-0ubuntu2_arm64.deb -O package.deb - dpkg -i package.deb - rm package.deb + wget http://ftp.us.debian.org/debian/pool/main/libw/libwebp/libwebp5_0.4.1-1.2+b2_armhf.deb -O package.deb + dpkg -i package.deb + rm package.deb - wget http://turul.canonical.com/pool/main/libj/libjpeg8-empty/libjpeg8_8c-2ubuntu8_arm64.deb -O package.deb - dpkg -i package.deb - rm package.deb + #ARMv8 + elif (( $G_HW_ARCH == 3 )); then - fi + wget http://ftp.us.debian.org/debian/pool/main/libp/libpng/libpng12-0_1.2.50-2+deb8u3_arm64.deb -O package.deb + dpkg -i package.deb + rm package.deb - AGI emby-server embymagick + wget http://ftp.us.debian.org/debian/pool/main/libw/libwebp/libwebp5_0.4.1-1.2+b2_arm64.deb -O package.deb + dpkg -i package.deb + rm package.deb - else + wget https://mirror.i-novus.ru/ubuntu-ports/pool/main/libj/libjpeg-turbo/libjpeg-turbo8_1.3.0-0ubuntu2_arm64.deb -O package.deb + dpkg -i package.deb + rm package.deb - Error_NoConnection_NoInstall + wget http://turul.canonical.com/pool/main/libj/libjpeg8-empty/libjpeg8_8c-2ubuntu8_arm64.deb -O package.deb + dpkg -i package.deb + rm package.deb fi + G_AGI emby-server embymagick + fi #PLEXMEDIASERVER @@ -6313,9 +5718,9 @@ _EOF_ #check folder is online #x86_64 - if (( $HW_ARCH == 10 )); then + if (( $G_HW_ARCH == 10 )); then - INSTALL_URL_ADDRESS='https://downloads.plex.tv/plex-media-server/1.5.6.3790-4613ce077/plexmediaserver_1.5.6.3790-4613ce077_amd64.deb' + INSTALL_URL_ADDRESS='https://downloads.plex.tv/plex-media-server/1.10.1.4602-f54242b6b/plexmediaserver_1.10.1.4602-f54242b6b_amd64.deb' #ARM else @@ -6324,45 +5729,36 @@ _EOF_ fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - #x86_64 - if (( $HW_ARCH == 10 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb + #x86_64 + if (( $G_HW_ARCH == 10 )); then - #ARM - else + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb - echo -e "deb [arch=armhf] $INSTALL_URL_ADDRESS $DISTRO_NAME main" > /etc/apt/sources.list.d/plex.list - wget -O - "$INSTALL_URL_ADDRESS"dev2day-pms.gpg.key | apt-key add - - apt-get update + #ARM + else - #ARMv8: Install 32bit binaries - if (( $HW_ARCH == 3 )); then + echo -e "deb [arch=armhf] $INSTALL_URL_ADDRESS $G_DISTRO_NAME main" > /etc/apt/sources.list.d/plex.list + wget -O - "$INSTALL_URL_ADDRESS"dev2day-pms.gpg.key | apt-key add - + G_AGUP - dpkg --add-architecture armhf - apt-get update - AGI binutils:armhf plexmediaserver-installer:armhf + #ARMv8: Install 32bit binaries + if (( $G_HW_ARCH == 3 )); then - #ARM32 - else + dpkg --add-architecture armhf + G_AGUP + G_AGI binutils:armhf plexmediaserver-installer:armhf - AGI plexmediaserver-installer + #ARM32 + else - fi + G_AGI plexmediaserver-installer fi - else - - Error_NoConnection_NoInstall - fi fi @@ -6374,35 +5770,26 @@ _EOF_ Banner_Installing #x86_64 - if (( $HW_ARCH == 10 )); then + if (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS='http://builds.cuberite.org/job/Cuberite%20Linux%20x64%20Master/lastSuccessfulBuild/artifact/Cuberite.tar.gz' #32bit ARM - elif (( $HW_ARCH == 1 || $HW_ARCH == 2 )); then + elif (( $G_HW_ARCH == 1 || $G_HW_ARCH == 2 )); then INSTALL_URL_ADDRESS='http://builds.cuberite.org/job/Cuberite%20Linux%20raspi-armhf%20Master/lastSuccessfulBuild/artifact/Cuberite.tar.gz' fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.tar - mkdir -p /etc/cubrite - tar xzvf package.tar -C /etc/cubrite - rm package.tar - - # - Move everything into base directory (cuberite) - mv /etc/cubrite/Server/* /etc/cubrite/ - rm -R /etc/cuberite/Server - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.tar + mkdir -p /etc/cubrite + tar xzvf package.tar -C /etc/cubrite + rm package.tar - fi + # - Move everything into base directory (cuberite) + mv /etc/cubrite/Server/* /etc/cubrite/ + rm -R /etc/cuberite/Server fi @@ -6415,31 +5802,22 @@ _EOF_ #check folder is online INSTALL_URL_ADDRESS='https://github.com/hexparrot/mineos-node.git' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - #prereqs - AGI python python3 supervisor rdiff-backup screen rsync + G_CHECK_URL "$INSTALL_URL_ADDRESS" - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/mineos - cd "$FP_DIETPI_USERDATA_DIRECTORY"/mineos - git clone https://github.com/hexparrot/mineos-node.git minecraft + #prereqs + G_AGI python python3 supervisor rdiff-backup screen rsync - cd minecraft - git config core.filemode false - chmod +x service.js mineos_console.js generate-sslcert.sh webui.js + mkdir -p "$G_FP_DIETPI_USERDATA"/mineos + cd "$G_FP_DIETPI_USERDATA"/mineos + git clone https://github.com/hexparrot/mineos-node.git minecraft - npm install + cd minecraft + git config core.filemode false + chmod +x service.js mineos_console.js generate-sslcert.sh webui.js - cd "$HOME" + npm install - else - - Error_NoConnection_NoInstall - - fi + cd "$HOME" fi @@ -6452,37 +5830,28 @@ _EOF_ INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/gogs_' #armv6 - if (( $HW_ARCH == 1 )); then + if (( $G_HW_ARCH == 1 )); then INSTALL_URL_ADDRESS+='armv6.zip' #armv7+ - elif (( $HW_ARCH == 2 )); then + elif (( $G_HW_ARCH == 2 )); then INSTALL_URL_ADDRESS+='armv7.zip' #x86_64 - elif (( $HW_ARCH == 10 )); then + elif (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS+='amd64.zip' fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip - rm package.zip - - mv gogs* /etc/gogs - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip + rm package.zip - fi + mv gogs* /etc/gogs fi @@ -6492,7 +5861,7 @@ _EOF_ Banner_Installing - AGI qbittorrent-nox + G_AGI qbittorrent-nox fi @@ -6503,38 +5872,29 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://bintray.com/novik65/generic/download_file?file_path=ruTorrent-3.7.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - AGI rtorrent screen #mediainfo - - #Raspbian unrar free - if (( $HW_MODEL < 10 )); then - - AGI unrar-free #https://github.com/Fourdee/DietPi/issues/176#issuecomment-240101365 - - else + G_AGI rtorrent screen #mediainfo - AGI unrar #https://github.com/Fourdee/DietPi/issues/176#issuecomment-240101365 + #Raspbian unrar free + if (( $G_HW_MODEL < 10 )); then - fi + G_AGI unrar-free #https://github.com/Fourdee/DietPi/issues/176#issuecomment-240101365 + else - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip - rm package.zip + G_AGI unrar #https://github.com/Fourdee/DietPi/issues/176#issuecomment-240101365 - mkdir -p /var/www/rutorrent - mv ruTorrent-*/* /var/www/rutorrent/ - rm -R ruTorrent-* + fi - else - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip + rm package.zip - fi + mkdir -p /var/www/rutorrent + mv ruTorrent-*/* /var/www/rutorrent/ + rm -R ruTorrent-* fi @@ -6544,36 +5904,41 @@ _EOF_ Banner_Installing - #aria2 binary - INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/aria2_' + if (( $G_DISTRO >= 4 )); then - # - armv6 - if (( $HW_ARCH == 1 )); then + G_AGI aria2 - INSTALL_URL_ADDRESS+='armv6.7z' + else - # - armv7+ - elif (( $HW_ARCH == 2 )); then + #aria2 binary + INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/aria2_' - INSTALL_URL_ADDRESS+='armv7.7z' + # - armv6 + if (( $G_HW_ARCH == 1 )); then - # - arm64 - elif (( $HW_ARCH == 3 )); then + INSTALL_URL_ADDRESS+='armv6.7z' - INSTALL_URL_ADDRESS+='arm64.7z' + # - armv7+ + elif (( $G_HW_ARCH == 2 )); then - # - x86_64 - elif (( $HW_ARCH == 10 )); then + INSTALL_URL_ADDRESS+='armv7.7z' + + # - arm64 + elif (( $G_HW_ARCH == 3 )); then - INSTALL_URL_ADDRESS+='x86_64.7z' + INSTALL_URL_ADDRESS+='arm64.7z' - fi + # - x86_64 + elif (( $G_HW_ARCH == 10 )); then + + INSTALL_URL_ADDRESS+='x86_64.7z' + + fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" # - prereqs - AGI libc-ares2 + G_AGI libc-ares2 wget "$INSTALL_URL_ADDRESS" -O package.7z 7z x -y package.7z @@ -6582,30 +5947,19 @@ _EOF_ mv aria2_* /usr/local/bin/aria2c chmod +x /usr/local/bin/aria2c - else - - Error_NoConnection_NoInstall - fi #Web interface INSTALL_URL_ADDRESS='https://github.com/ziahamza/webui-aria2/archive/master.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip - rm package.zip - - cp -R webui-aria2* /var/www/aria2 - rm -R webui-aria2* - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip + rm package.zip - fi + cp -R webui-aria2* /var/www/aria2 + rm -R webui-aria2* fi @@ -6616,38 +5970,29 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://github.com/SickRage/SickRage/archive/master.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - AGI python libxslt1.1 libxml2 python-openssl python-xmltodict - - #Raspbian unrar free - if (( $HW_MODEL < 10 )); then - - AGI unrar-free - - else + G_AGI python libxslt1.1 libxml2 python-openssl python-xmltodict - AGI unrar + #Raspbian unrar free + if (( $G_HW_MODEL < 10 )); then - fi + G_AGI unrar-free - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip - rm package.zip + else - mkdir -p /etc/sickrage + G_AGI unrar - mv SickRage-*/* /etc/sickrage/ - rm -R SickRage-* + fi - else + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip + rm package.zip - Error_NoConnection_NoInstall + mkdir -p /etc/sickrage - fi + mv SickRage-*/* /etc/sickrage/ + rm -R SickRage-* fi @@ -6658,42 +6003,35 @@ _EOF_ Banner_Installing # - armv6+ - if (( $HW_ARCH == 1 || $HW_ARCH == 2 )); then + if (( $G_HW_ARCH == 1 || $G_HW_ARCH == 2 )); then - INSTALL_URL_ADDRESS='https://github.com/syncthing/syncthing/releases/download/v0.14.40/syncthing-linux-arm-v0.14.40.tar.gz' + INSTALL_URL_ADDRESS='https://github.com/syncthing/syncthing/releases/download/v0.14.42/syncthing-linux-arm-v0.14.42.tar.gz' # - arm64 - elif (( $HW_ARCH == 3 )); then + elif (( $G_HW_ARCH == 3 )); then - INSTALL_URL_ADDRESS='https://github.com/syncthing/syncthing/releases/download/v0.14.40/syncthing-linux-arm64-v0.14.40.tar.gz' + INSTALL_URL_ADDRESS='https://github.com/syncthing/syncthing/releases/download/v0.14.42/syncthing-linux-arm64-v0.14.42.tar.gz' # - x86_64 - elif (( $HW_ARCH == 10 )); then + elif (( $G_HW_ARCH == 10 )); then - INSTALL_URL_ADDRESS='https://github.com/syncthing/syncthing/releases/download/v0.14.40/syncthing-linux-amd64-v0.14.40.tar.gz' + INSTALL_URL_ADDRESS='https://github.com/syncthing/syncthing/releases/download/v0.14.42/syncthing-linux-amd64-v0.14.42.tar.gz' fi #?? #For some reason checking connection (spider) against the files above fails. - #/DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - /DietPi/dietpi/func/check_connection https://github.com/syncthing/syncthing - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.tar - tar xzvf package.tar - rm package.tar - - mkdir -p /etc/syncthing - cp -R syncthing-*/syncthing /etc/syncthing/ - rm -R syncthing-* + #G_CHECK_URL "$INSTALL_URL_ADDRESS" + G_CHECK_URL https://github.com/syncthing/syncthing - else - - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.tar + tar xzvf package.tar + rm package.tar - fi + mkdir -p /etc/syncthing + cp -R syncthing-*/syncthing /etc/syncthing/ + rm -R syncthing-* fi @@ -6704,58 +6042,43 @@ _EOF_ Banner_Installing # - armv6/7 - if (( $HW_ARCH == 1 || $HW_ARCH == 2 )); then + if (( $G_HW_ARCH == 1 || $G_HW_ARCH == 2 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/libjpeg8_8d1-2_armhf.deb' # - x86_64 - elif (( $HW_ARCH == 10 )); then + elif (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/libjpeg8_8d1-2_amd64.deb' fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb - - else - - Error_NoConnection_NoInstall - - fi + G_CHECK_URL "$INSTALL_URL_ADDRESS" + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb # - armv6+ - if (( $HW_ARCH == 1 || $HW_ARCH == 2 )); then + if (( $G_HW_ARCH == 1 || $G_HW_ARCH == 2 )); then INSTALL_URL_ADDRESS='http://patch.codelathe.com/tonido/live/installer/armv6l-rpi/tonido.tar.gz' # - x86_64 - elif (( $HW_ARCH == 10 )); then + elif (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS='http://www.tonido.com/download.php?tonido64.tar.gz' fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - AGI libpng12-0 libfontconfig1 + G_AGI libpng12-0 libfontconfig1 - wget "$INSTALL_URL_ADDRESS" -O package.tar - mkdir /etc/tonido - tar xvf package.tar -C /etc/tonido - rm package.tar - - else - - Error_NoConnection_NoInstall - - fi + wget "$INSTALL_URL_ADDRESS" -O package.tar + mkdir /etc/tonido + tar xvf package.tar -C /etc/tonido + rm package.tar fi @@ -6766,78 +6089,70 @@ _EOF_ Banner_Installing #Stretch via apt - if (( $DISTRO >= 4 )); then + if (( $G_DISTRO >= 4 )); then - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then - AGI chromium-browser + G_AGI chromium-browser else - AGI chromium + G_AGI chromium fi else #armv6+ - if (( $HW_ARCH == 1 || $HW_ARCH == 2 )); then + if (( $G_HW_ARCH == 1 || $G_HW_ARCH == 2 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/chromium_52.0.2743.116-1-deb8u1.1_armhf.deb' #ARMv8 - elif (( $HW_ARCH == 3 )); then + elif (( $G_HW_ARCH == 3 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/chromium_52.0.2743.116-1-deb8u1.1_arm64.deb' fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - - # - Odroid's, 'apt-get install -f' removes chromium package, rather than install required deps... - if (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - AGI libgnome-keyring0 libnspr4 libnss3 libnss3-1d libspeechd2 libxslt1.1 libxss1 xdg-utils libgnome-keyring-common libltdl7 - - else + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb - AGF + # - Odroid's, 'apt-get install -f' removes chromium package, rather than install required deps... + if (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )); then - fi + G_AGI libgnome-keyring0 libnspr4 libnss3 libnss3-1d libspeechd2 libxslt1.1 libxss1 xdg-utils libgnome-keyring-common libltdl7 - wget http://dietpi.com/downloads/binaries/all/chromium-l10n_52.0.2743.116-1-deb8u1.1_all.deb -O package.deb - dpkg -i package.deb + else - # armv6+ - if (( $HW_ARCH == 1 || $HW_ARCH == 2 )); then + G_AGF - wget http://dietpi.com/downloads/binaries/all/chromedriver_52.0.2743.116-1-deb8u1.1_armhf.deb -O package.deb - dpkg -i package.deb + fi - # arm64 - elif (( $HW_ARCH == 3 )); then + wget http://dietpi.com/downloads/binaries/all/chromium-l10n_52.0.2743.116-1-deb8u1.1_all.deb -O package.deb + dpkg -i package.deb - wget http://dietpi.com/downloads/binaries/all/chromedriver_52.0.2743.116-1-deb8u1.1_arm64.deb -O package.deb - dpkg -i package.deb + # armv6+ + if (( $G_HW_ARCH == 1 || $G_HW_ARCH == 2 )); then - fi + wget http://dietpi.com/downloads/binaries/all/chromedriver_52.0.2743.116-1-deb8u1.1_armhf.deb -O package.deb + dpkg -i package.deb - rm package.deb + # arm64 + elif (( $G_HW_ARCH == 3 )); then - # - Prevent Debian repo from replacing our chromium packages: https://github.com/Fourdee/DietPi/issues/658 - apt-mark hold chromium chromedriver + wget http://dietpi.com/downloads/binaries/all/chromedriver_52.0.2743.116-1-deb8u1.1_arm64.deb -O package.deb + dpkg -i package.deb - else + fi - Error_NoConnection_NoInstall + rm package.deb - fi + # - Prevent Debian repo from replacing our chromium packages: https://github.com/Fourdee/DietPi/issues/658 + apt-mark hold chromium chromedriver fi @@ -6850,38 +6165,31 @@ _EOF_ Banner_Installing #Jessie, prefer latest motion release. - if (( $DISTRO == 3 )); then + if (( $G_DISTRO == 3 )); then - INSTALL_URL_ADDRESS='http://github.com/Motion-Project/motion/releases/download/release-4.0.1/pi_jessie_motion_4.0.1-1_armhf.deb' + INSTALL_URL_ADDRESS='https://github.com/Motion-Project/motion/releases/download/release-4.1.1/pi_jessie_motion_4.1.1-1_armhf.deb' #url/redireect always fails wget spider test... - /DietPi/dietpi/func/check_connection "http://github.com/Motion-Project/motion" - if (( $? == 0 )); then - - # - Prereqs - AGI v4l-utils python python-dev curl libssl-dev libcurl4-openssl-dev libjpeg-dev zlib1g-dev libx264-142 libavcodec56 libavformat56 libmysqlclient18 libswscale3 libpq5 - - # - Motion - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb + G_CHECK_URL "http://github.com/Motion-Project/motion" - # - Motioneye - pip install motioneye - - else + # - Prereqs + G_AGI v4l-utils python python-dev curl libssl-dev libcurl4-openssl-dev libjpeg-dev zlib1g-dev libx264-142 libavcodec56 libavformat56 libmysqlclient18 libswscale3 libpq5 - Error_NoConnection_NoInstall + # - Motion + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb - fi + # - Motioneye + pip install motioneye #Stretch else # - Prereqs - AGI v4l-utils python python-dev curl libssl-dev libcurl4-openssl-dev libjpeg-dev zlib1g-dev + G_AGI v4l-utils python python-dev curl libssl-dev libcurl4-openssl-dev libjpeg-dev zlib1g-dev - AGI motion + G_AGI motion # - Motioneye pip install motioneye @@ -6896,31 +6204,24 @@ _EOF_ Banner_Installing - if (( $DISTRO == 3 )); then #https://github.com/Fourdee/DietPi/issues/855#issuecomment-292712002 + if (( $G_DISTRO == 3 )); then #https://github.com/Fourdee/DietPi/issues/855#issuecomment-292712002 INSTALL_URL_ADDRESS='http://davesteele.github.io/cloudprint-service' #url/redirect fails wget spider test... - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - INSTALL_URL_ADDRESS+='/repo' + INSTALL_URL_ADDRESS+='/repo' - echo -e "deb $INSTALL_URL_ADDRESS cloudprint-jessie main" > /etc/apt/sources.list.d/cloudprint.list - wget -q -O - https://davesteele.github.io/key-366150CE.pub.txt | apt-key add - - apt-get update + echo -e "deb $INSTALL_URL_ADDRESS cloudprint-jessie main" > /etc/apt/sources.list.d/cloudprint.list + wget -q -O - https://davesteele.github.io/key-366150CE.pub.txt | apt-key add - + G_AGUP - AGI cloudprint-service - - else - - Error_NoConnection_NoInstall - - fi + G_AGI cloudprint-service else - AGI cloudprint-service + G_AGI cloudprint-service fi @@ -6935,37 +6236,28 @@ _EOF_ INSTALL_URL_ADDRESS='https://virtualhere.com/sites/default/files/usbserver/vhusbd' #armv6+ - if (( $HW_ARCH == 1 || $HW_ARCH == 2 )); then + if (( $G_HW_ARCH == 1 || $G_HW_ARCH == 2 )); then INSTALL_URL_ADDRESS+='arm' #ARMv8 - elif (( $HW_ARCH == 3 )); then + elif (( $G_HW_ARCH == 3 )); then INSTALL_URL_ADDRESS+='arm64' #x86_64 - elif (( $HW_ARCH == 10 )); then + elif (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS+='x86_64' fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - mkdir -p /etc/vhusbd + G_CHECK_URL "$INSTALL_URL_ADDRESS" - wget "$INSTALL_URL_ADDRESS" -O /etc/vhusbd/vhusbd - chmod +x /etc/vhusbd/vhusbd + mkdir -p /etc/vhusbd - else - - Error_NoConnection_NoInstall - - fi + wget "$INSTALL_URL_ADDRESS" -O /etc/vhusbd/vhusbd + chmod +x /etc/vhusbd/vhusbd fi @@ -6975,41 +6267,34 @@ _EOF_ Banner_Installing - local version='2.3.1' + local version='2.3.2' INSTALL_URL_ADDRESS="https://github.com/sabnzbd/sabnzbd/archive/$version.zip" - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - #prereqs - AGI par2 python-dev libffi-dev libssl-dev - - if (( $HW_MODEL < 10 )); then - - AGI unrar-free - - else + #prereqs + G_AGI par2 python-dev libffi-dev libssl-dev - AGI unrar + if (( $G_HW_MODEL < 10 )); then - fi + G_AGI unrar-free - wget "$INSTALL_URL_ADDRESS" -O package.zip - mkdir -p /etc/sabnzbd - unzip -o package.zip -d /etc/sabnzbd - rm package.zip + else - mv /etc/sabnzbd/sabnzbd-"$version"/* /etc/sabnzbd/ - rm -R /etc/sabnzbd/sabnzbd-"$version" + G_AGI unrar - pip install cheetah cryptography sabyenc + fi - else + wget "$INSTALL_URL_ADDRESS" -O package.zip + mkdir -p /etc/sabnzbd + unzip -o package.zip -d /etc/sabnzbd + rm package.zip - Error_NoConnection_NoInstall + mv /etc/sabnzbd/sabnzbd-"$version"/* /etc/sabnzbd/ + rm -R /etc/sabnzbd/sabnzbd-"$version" - fi + pip install cheetah cryptography sabyenc fi @@ -7020,20 +6305,13 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://github.com/Fornoth/spotify-connect-web/releases' #full path fails wget spider test... - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - INSTALL_URL_ADDRESS+='/download/0.0.3-alpha/spotify-connect-web_0.0.3-alpha.tar.gz' + G_CHECK_URL "$INSTALL_URL_ADDRESS" - wget "$INSTALL_URL_ADDRESS" -O package.tar - tar zxvf package.tar -C "$FP_DIETPI_USERDATA_DIRECTORY"/ - rm package.tar - - else + INSTALL_URL_ADDRESS+='/download/0.0.3-alpha/spotify-connect-web_0.0.3-alpha.tar.gz' - Error_NoConnection_NoInstall - - fi + wget "$INSTALL_URL_ADDRESS" -O package.tar + tar zxvf package.tar -C "$G_FP_DIETPI_USERDATA"/ + rm package.tar fi @@ -7044,25 +6322,18 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://github.com/CouchPotato/CouchPotatoServer/archive/master.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - AGI libffi-dev libssl-dev python-lxml python3-lxml - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip - rm package.zip + G_CHECK_URL "$INSTALL_URL_ADDRESS" - rm -R /etc/couchpotato &> /dev/null - mv CouchPotato* /etc/couchpotato + G_AGI libffi-dev libssl-dev python-lxml python3-lxml - pip install --upgrade pyopenssl - - else + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip + rm package.zip - Error_NoConnection_NoInstall + rm -R /etc/couchpotato &> /dev/null + mv CouchPotato* /etc/couchpotato - fi + pip install --upgrade pyopenssl fi @@ -7072,37 +6343,28 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS='https://github.com/phanan/koel/archive/v3.6.2.zip' - - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - AGI python - - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip - rm package.zip - mv koel-* /var/www/koel + INSTALL_URL_ADDRESS='https://github.com/phanan/koel/archive/v3.7.0.zip' - php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php - php composer-setup.php - php -r "unlink('composer-setup.php');" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - mv composer.phar /usr/local/bin/composer + G_AGI python - cd /var/www/koel - npm install yarn -g --unsafe-perm - composer install - npm install - cd "$HOME" + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip + rm package.zip + mv koel-* /var/www/koel - else + php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php + php composer-setup.php + php -r "unlink('composer-setup.php');" - Error_NoConnection_NoInstall + mv composer.phar /usr/local/bin/composer - fi + cd /var/www/koel + npm install yarn -g --unsafe-perm + composer install + npm install + cd "$HOME" fi @@ -7113,18 +6375,19 @@ _EOF_ Banner_Installing apt-key adv --keyserver keyserver.ubuntu.com --recv-keys FDA5DFFC - if (( $HW_ARCH == 3 )); then + if (( $G_HW_ARCH == 3 )); then echo -e "deb [arch=armhf] https://apt.sonarr.tv/ master main" > /etc/apt/sources.list.d/sonarr.list + dpkg --add-architecture armhf else echo -e "deb https://apt.sonarr.tv/ master main" > /etc/apt/sources.list.d/sonarr.list fi - apt-get update + G_AGUP - AGI nzbdrone + G_AGI nzbdrone fi @@ -7136,22 +6399,13 @@ _EOF_ INSTALL_URL_ADDRESS='https://api.github.com/repos/Radarr/Radarr/releases' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - AGI mono-devel mediainfo sqlite3 libmono-cil-dev - - wget $( curl -s "$INSTALL_URL_ADDRESS" | grep linux.tar.gz | grep browser_download_url | head -1 | cut -d \" -f 4 ) -O package.tar - tar -xf package.tar -C /opt/ - rm package.tar - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + G_AGI mono-devel mediainfo sqlite3 libmono-cil-dev - fi + wget $( curl -s "$INSTALL_URL_ADDRESS" | grep linux.tar.gz | grep browser_download_url | head -1 | cut -d \" -f 4 ) -O package.tar + tar -xf package.tar -C /opt/ + rm package.tar fi @@ -7163,22 +6417,13 @@ _EOF_ INSTALL_URL_ADDRESS='https://github.com/JonnyWong16/plexpy.git' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - AGI python - - git clone --depth=1 "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - mv plexpy /opt/ + G_AGI python - else - - Error_NoConnection_NoInstall + git clone --depth=1 "$INSTALL_URL_ADDRESS" - fi + mv plexpy /opt/ fi @@ -7190,28 +6435,19 @@ _EOF_ INSTALL_URL_ADDRESS='https://api.github.com/repos/Jackett/Jackett/releases' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - AGI mono-devel - - wget $( curl -s "$INSTALL_URL_ADDRESS" | grep Jackett.Binaries.Mono.tar.gz | grep browser_download_url | head -1 | cut -d \" -f 4 ) -O package.tar - tar -xvf package.tar - rm package.tar - - mkdir /opt/jackett + G_CHECK_URL "$INSTALL_URL_ADDRESS" - mv Jackett/* /opt/jackett + G_AGI mono-devel - rm -R Jackett + wget $( curl -s "$INSTALL_URL_ADDRESS" | grep Jackett.Binaries.Mono.tar.gz | grep browser_download_url | head -1 | cut -d \" -f 4 ) -O package.tar + tar -xvf package.tar + rm package.tar - else + mkdir /opt/jackett - Error_NoConnection_NoInstall + mv Jackett/* /opt/jackett - fi + rm -R Jackett fi @@ -7223,23 +6459,14 @@ _EOF_ INSTALL_URL_ADDRESS='http://dist.jriver.com/latest/mediacenter/mediacenter22native.list' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - wget -q -O - http://dist.jriver.com/mediacenter@jriver.com.gpg.key | apt-key add - - wget "$INSTALL_URL_ADDRESS" -O /etc/apt/sources.list.d/mediacenter22.list - - apt-get update - - AGI mediacenter22 + G_CHECK_URL "$INSTALL_URL_ADDRESS" - else + wget -q -O - http://dist.jriver.com/mediacenter@jriver.com.gpg.key | apt-key add - + wget "$INSTALL_URL_ADDRESS" -O /etc/apt/sources.list.d/mediacenter22.list - Error_NoConnection_NoInstall + G_AGUP - fi + G_AGI mediacenter22 fi @@ -7251,23 +6478,14 @@ _EOF_ INSTALL_URL_ADDRESS='https://nzbget.net' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - INSTALL_URL_ADDRESS+='/download/nzbget-latest-bin-linux.run' - - wget "$INSTALL_URL_ADDRESS" -O package.run - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget - sh package.run --destdir "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget - rm package.run - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + INSTALL_URL_ADDRESS+='/download/nzbget-latest-bin-linux.run' - fi + wget "$INSTALL_URL_ADDRESS" -O package.run + mkdir -p "$G_FP_DIETPI_USERDATA"/nzbget + sh package.run --destdir "$G_FP_DIETPI_USERDATA"/nzbget + rm package.run fi @@ -7279,27 +6497,22 @@ _EOF_ INSTALL_URL_ADDRESS='https://github.com/Hellowlol/HTPC-Manager.git' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - #Install - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - #Install Python and PIP - AGI python python-pip python-imaging python-dev + #Install Python and PIP + G_AGI python python-pip python-imaging python-dev - cd "$HOME" - git clone --depth=1 "$INSTALL_URL_ADDRESS" + cd "$HOME" + git clone --depth=1 "$INSTALL_URL_ADDRESS" - # - Move HTPC Manager to a 'better' location - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/htpc-manager - mv "$HOME"/HTPC-Manager/* "$FP_DIETPI_USERDATA_DIRECTORY"/htpc-manager/ - rm -R "$HOME"/HTPC-Manager + # - Move HTPC Manager to a 'better' location + mkdir -p "$G_FP_DIETPI_USERDATA"/htpc-manager + mv "$HOME"/HTPC-Manager/* "$G_FP_DIETPI_USERDATA"/htpc-manager/ + rm -R "$HOME"/HTPC-Manager - # - psutil for system stats - pip install psutil + # - psutil for system stats + pip install psutil - else - Error_NoConnection_NoInstall - fi fi #OctoPrint @@ -7309,24 +6522,16 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://github.com/foosel/OctoPrint.git' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then - - AGI python python-dev - - git clone "$INSTALL_URL_ADDRESS" - mv OctoPrint* "$FP_DIETPI_USERDATA_DIRECTORY"/octoprint + G_CHECK_URL "$INSTALL_URL_ADDRESS" - cd "$FP_DIETPI_USERDATA_DIRECTORY"/octoprint - python setup.py install - cd "$HOME" + G_AGI python python-dev - else - - Error_NoConnection_NoInstall + git clone "$INSTALL_URL_ADDRESS" + mv OctoPrint* "$G_FP_DIETPI_USERDATA"/octoprint - fi + cd "$G_FP_DIETPI_USERDATA"/octoprint + python setup.py install + cd "$HOME" fi @@ -7337,23 +6542,15 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://download.roonlabs.com/builds/RoonServer_linuxx64.tar.bz2' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then - - AGI libav-tools cifs-utils - - wget "$INSTALL_URL_ADDRESS" -O package.tar - tar xvf package.tar - rm package.tar - - mv RoonServer "$FP_DIETPI_USERDATA_DIRECTORY"/roonserver + G_CHECK_URL "$INSTALL_URL_ADDRESS" - else + G_AGI libav-tools cifs-utils - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.tar + tar xvf package.tar + rm package.tar - fi + mv RoonServer "$G_FP_DIETPI_USERDATA"/roonserver fi @@ -7365,7 +6562,7 @@ _EOF_ debconf-set-selections <<< "steam steam/question select I AGREE" - AGI steam + G_AGI steam fi @@ -7378,7 +6575,7 @@ _EOF_ # Download the proper Minio executable and put it in the proper location # Check to see if this is a n x86 or x64 box. If so download the x86 Minio if not download 32bit ARM linux version - if (( $HW_ARCH == 10 )); then + if (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS='https://dl.minio.io/server/minio/release/linux-amd64/minio' @@ -7388,42 +6585,25 @@ _EOF_ fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - #Download executable - wget -O /usr/local/bin/minio $INSTALL_URL_ADDRESS - chmod +x /usr/local/bin/minio - MinioContinue=1 - else - Error_NoConnection_NoInstall - MinioContinue=0 - fi + #Download executable + wget -O /usr/local/bin/minio $INSTALL_URL_ADDRESS + chmod +x /usr/local/bin/minio # Check, Download, Install startup script INSTALL_URL_ADDRESS='https://github.com/minio/minio-service/raw/master/linux-systemd/minio.service' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then - # Download the systemd service script - wget -O /etc/systemd/system/minio.service $INSTALL_URL_ADDRESS - MinioContinue=1 - else - Error_NoConnection_NoInstall - MinioContinue=0 - fi + G_CHECK_URL "$INSTALL_URL_ADDRESS" - if ((MinioContinue == 1)); then + # Download the systemd service script + wget -O /etc/systemd/system/minio.service $INSTALL_URL_ADDRESS # Create no login, with home directory, with group of same name, user to run Minio in adduser --system --group minio-user # Create default data directory & grant minio-user proper access - mkdir "$FP_DIETPI_USERDATA_DIRECTORY"/minio-data - - - fi + mkdir "$G_FP_DIETPI_USERDATA"/minio-data fi @@ -7435,17 +6615,13 @@ _EOF_ INSTALL_URL_ADDRESS='https://get.docker.com' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - # Offical Docker recommended install command - wget -O DockerInstall.sh "$INSTALL_URL_ADDRESS" - chmod +x DockerInstall.sh - ./DockerInstall.sh - #rm DockerInstall.sh - else - Error_NoConnection_NoInstall - fi + # Offical Docker recommended install command + wget -O DockerInstall.sh "$INSTALL_URL_ADDRESS" + chmod +x DockerInstall.sh + ./DockerInstall.sh + #rm DockerInstall.sh fi @@ -7455,7 +6631,7 @@ _EOF_ Banner_Installing - if (( $HW_ARCH == 10 )); then + if (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS='http://FuguHub.com/install/FuguHub.linux.install' @@ -7465,19 +6641,13 @@ _EOF_ fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then - - wget -O FHinstall.sh "$INSTALL_URL_ADDRESS" - chmod +x FHinstall.sh - ./FHinstall.sh - rm FHinstall.sh - wget http://fuguhub.com/box.zip -O /home/bd/applications/box.zip + G_CHECK_URL "$INSTALL_URL_ADDRESS" - else - Error_NoConnection_NoInstall - fi + wget -O FHinstall.sh "$INSTALL_URL_ADDRESS" + chmod +x FHinstall.sh + ./FHinstall.sh + rm FHinstall.sh + wget http://fuguhub.com/box.zip -O /home/bd/applications/box.zip fi @@ -7489,64 +6659,50 @@ _EOF_ INSTALL_URL_ADDRESS='http://ci.mengcraft.com:8080/job/nukkit/lastStableBuild/artifact/target/nukkit-1.0-SNAPSHOT.jar' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then + mkdir /usr/local/bin/nukkit + wget -O /usr/local/bin/nukkit/nukkit.jar "$INSTALL_URL_ADDRESS" - mkdir /usr/local/bin/nukkit - wget -O /usr/local/bin/nukkit/nukkit.jar "$INSTALL_URL_ADDRESS" - - else - Error_NoConnection_NoInstall - fi fi #GITEA INSTALLING_INDEX=165 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - Banner_Installing - - INSTALL_URL_ADDRESS='https://dl.gitea.io/gitea/1.3.1/gitea-1.3.1-' - - #armv6 - if (( $HW_ARCH == 1 )); then - - INSTALL_URL_ADDRESS+='linux-arm-6' - - #armv7 - elif (( $HW_ARCH == 2 )); then + Banner_Installing - INSTALL_URL_ADDRESS+='linux-arm-7' + INSTALL_URL_ADDRESS='https://dl.gitea.io/gitea/1.3.2/gitea-1.3.2-' - #armv8 - elif (( $HW_ARCH == 3 )); then + #armv6 + if (( $G_HW_ARCH == 1 )); then - INSTALL_URL_ADDRESS+='linux-arm64' + INSTALL_URL_ADDRESS+='linux-arm-6' - #x86_64 - elif (( $HW_ARCH == 10 )); then + #armv7 + elif (( $G_HW_ARCH == 2 )); then - INSTALL_URL_ADDRESS+='linux-amd64' + INSTALL_URL_ADDRESS+='linux-arm-7' - fi + #armv8 + elif (( $G_HW_ARCH == 3 )); then - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + INSTALL_URL_ADDRESS+='linux-arm64' - #Install - if (( $? == 0 )); then + #x86_64 + elif (( $G_HW_ARCH == 10 )); then - # - Data storage / user data - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/gitea/gitea-repositories + INSTALL_URL_ADDRESS+='linux-amd64' - wget "$INSTALL_URL_ADDRESS" -O "$FP_DIETPI_USERDATA_DIRECTORY"/gitea/gitea - chmod +x "$FP_DIETPI_USERDATA_DIRECTORY"/gitea/gitea + fi - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + # - Data storage / user data + mkdir -p "$G_FP_DIETPI_USERDATA"/gitea/gitea-repositories - fi + wget "$INSTALL_URL_ADDRESS" -O "$G_FP_DIETPI_USERDATA"/gitea/gitea + chmod +x "$G_FP_DIETPI_USERDATA"/gitea/gitea fi @@ -7557,19 +6713,12 @@ _EOF_ Banner_Installing - INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/allo_web_interface_v4.7z' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.7z - 7z x -y package.7z -o/var/www/ - rm package.7z - - else - - Error_NoConnection_NoInstall + INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/allo_web_interface_v5.7z' + G_CHECK_URL "$INSTALL_URL_ADDRESS" - fi + wget "$INSTALL_URL_ADDRESS" -O package.7z + 7z x -y package.7z -o/var/www/ + rm package.7z fi @@ -7580,38 +6729,31 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/gmrender_1_' - if (( $HW_ARCH == 10 )); then + if (( $G_HW_ARCH == 10 )); then INSTALL_URL_ADDRESS+='amd64.deb' - elif (( $HW_ARCH == 3 )); then + elif (( $G_HW_ARCH == 3 )); then INSTALL_URL_ADDRESS+='arm64.deb' - elif (( $HW_ARCH == 2 )); then + elif (( $G_HW_ARCH == 2 )); then INSTALL_URL_ADDRESS+='armv7.deb' - elif (( $HW_ARCH == 1 )); then + elif (( $G_HW_ARCH == 1 )); then INSTALL_URL_ADDRESS+='armv6.deb' fi - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - AGI libupnp6 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-alsa - - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + G_AGI libupnp6 gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly gstreamer1.0-alsa - fi + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb fi @@ -7632,20 +6774,13 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://dtcooper.github.io/raspotify/key.asc' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - wget -O - "$INSTALL_URL_ADDRESS" | apt-key add - - echo -e "deb https://dtcooper.github.io/raspotify jessie main" > /etc/apt/sources.list.d/raspotify.list - apt-get update - - AGI raspotify - - else + G_CHECK_URL "$INSTALL_URL_ADDRESS" - Error_NoConnection_NoInstall + wget -O - "$INSTALL_URL_ADDRESS" | apt-key add - + echo -e "deb https://dtcooper.github.io/raspotify jessie main" > /etc/apt/sources.list.d/raspotify.list + G_AGUP - fi + G_AGI raspotify fi @@ -7656,86 +6791,79 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/moode/rel-stretch-r40b9.zip' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - cd "$HOME" - wget "$INSTALL_URL_ADDRESS" -O package.zip - unzip -o package.zip + cd "$HOME" + wget "$INSTALL_URL_ADDRESS" -O package.zip + unzip -o package.zip - #Pre-Reqs ----------------------------------------------------------------------- - # Core packages - AGI rpi-update mpc memcached $PHP_APT_PACKAGE_NAME-memcache \ + #Pre-Reqs ----------------------------------------------------------------------- + # Core packages + G_AGI rpi-update mpc memcached $PHP_APT_PACKAGE_NAME-memcache \ bs2b-ladspa libbs2b0 libasound2-plugin-equal telnet automake sysstat tcpdump shellinabox \ udisks-glue exfat-fuse inotify-tools libav-tools #php5-memcached - # WiFi Hotspot - AGI dnsmasq hostapd + # WiFi Hotspot + G_AGI dnsmasq hostapd - # BT - AGI bluez bluez-firmware \ + # BT + G_AGI bluez bluez-firmware \ dh-autoreconf expect libortp-dev libbluetooth-dev libasound2-dev \ libusb-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libsbc1 libsbc-dev - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then - AGI pi-bluetooth + G_AGI pi-bluetooth - fi + fi - #Disable Shell in box -------------------------------------------------------------------- - systemctl stop shellinabox - systemctl disable shellinabox - - #HostAPD/BT ------------------------------------------------------------------------------- - systemctl disable hostapd - systemctl disable dnsmasq - - cd "$HOME" - git clone https://github.com/Arkq/bluez-alsa.git --depth=1 - cd bluez-alsa - autoreconf --install - mkdir build - cd build - ../configure --disable-hcitop --with-alsaplugindir=/usr/lib/arm-linux-gnueabihf/alsa-lib - make -j $(nproc --all) - make install - cd "$HOME" - rm -rf bluez-alsa + #Disable Shell in box -------------------------------------------------------------------- + systemctl stop shellinabox + systemctl disable shellinabox - systemctl daemon-reload - systemctl disable bluetooth.service - systemctl disable bluealsa.service - systemctl disable hciuart.service - - mkdir -p /var/run/bluealsa - - #Wiring Pi ------------------------------------------------------------------------------- - #??? Use/test with DietPi WP install - cd "$HOME" - cp ./rel-stretch/other/wiringpi/wiringPi-*.tar.gz ./ - tar xfz ./wiringPi-*.tar.gz - cd wiringPi-96344ff - ./build - cd "$HOME" - rm -rf ./wiringPi-* - - #Rotary encoder driver -------------------------------------------------------------------- - cp ./rel-stretch/other/rotenc/rotenc.c ./ - gcc -std=c99 rotenc.c -orotenc -lwiringPi - cp ./rotenc /usr/local/bin - rm ./rotenc* - - #Compile and install MPD ------------------------------------------------------------------ - # Installed via DietPi pre-built binaries. + #HostAPD/BT ------------------------------------------------------------------------------- + systemctl disable hostapd + systemctl disable dnsmasq - else + cd "$HOME" + git clone https://github.com/Arkq/bluez-alsa.git --depth=1 + cd bluez-alsa + autoreconf --install + mkdir build + cd build + ../configure --disable-hcitop --with-alsaplugindir=/usr/lib/arm-linux-gnueabihf/alsa-lib + make -j $(nproc --all) + make install + cd "$HOME" + rm -rf bluez-alsa + + systemctl daemon-reload + systemctl disable bluetooth.service + systemctl disable bluealsa.service + systemctl disable hciuart.service - Error_NoConnection_NoInstall + mkdir -p /var/run/bluealsa - fi + #Wiring Pi ------------------------------------------------------------------------------- + #??? Use/test with DietPi WP install + cd "$HOME" + cp ./rel-stretch/other/wiringpi/wiringPi-*.tar.gz ./ + tar xfz ./wiringPi-*.tar.gz + cd wiringPi-96344ff + ./build + cd "$HOME" + rm -rf ./wiringPi-* + + #Rotary encoder driver -------------------------------------------------------------------- + cp ./rel-stretch/other/rotenc/rotenc.c ./ + gcc -std=c99 rotenc.c -orotenc -lwiringPi + cp ./rotenc /usr/local/bin + rm ./rotenc* + + #Compile and install MPD ------------------------------------------------------------------ + # Installed via DietPi pre-built binaries. fi @@ -7746,46 +6874,44 @@ libusb-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libsbc1 libsbc Banner_Installing INSTALL_URL_ADDRESS='https://github.com/google/aiyprojects-raspbian.git' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - git clone "$INSTALL_URL_ADDRESS" "$FP_DIETPI_USERDATA_DIRECTORY"/voice-recognizer-raspi - cd "$FP_DIETPI_USERDATA_DIRECTORY"/voice-recognizer-raspi - - pip3 install --upgrade pip virtualenv - virtualenv --system-site-packages -p python3 env - env/bin/pip install -r requirements.txt + G_CHECK_URL "$INSTALL_URL_ADDRESS" - #??? ARMv7 only - if (( $HW_ARCH == 2 )); then + git clone -b voicekit "$INSTALL_URL_ADDRESS" "$G_FP_DIETPI_USERDATA"/voice-recognizer-raspi + cd "$G_FP_DIETPI_USERDATA"/voice-recognizer-raspi - env/bin/pip install google-assistant-library==0.0.3 + pip3 install --upgrade pip virtualenv + virtualenv --system-site-packages -p python3 env + env/bin/pip install -r requirements.txt - fi - - # - Services - sed -i "s#/home/pi#$FP_DIETPI_USERDATA_DIRECTORY#g" systemd/voice-recognizer.service - sed -i "/^User=/c\User=dietpi" systemd/voice-recognizer.service + #??? ARMv7 only + if (( $G_HW_ARCH == 2 )); then - cp systemd/voice-recognizer.service /etc/systemd/system/ - cp systemd/alsa-init.service /etc/systemd/system/ - #cp systemd/ntpdate.service /etc/systemd/system/ + env/bin/pip install google-assistant-library==0.0.3 - source env/bin/activate + fi - # - Enable default app for service start - cp src/assistant_library_with_button_demo.py src/main.py + # - Services + sed -i "s#/home/pi#$G_FP_DIETPI_USERDATA#g" systemd/voice-recognizer.service + sed -i "/^User=/c\User=dietpi" systemd/voice-recognizer.service - cd "$HOME" + cp systemd/voice-recognizer.service /etc/systemd/system/ + cp systemd/alsa-init.service /etc/systemd/system/ + #cp systemd/ntpdate.service /etc/systemd/system/ - else + source env/bin/activate - Error_NoConnection_NoInstall + # - Enable default app for service start + cp src/assistant_library_with_button_demo.py src/main.py - fi + cd "$HOME" fi + #------------------------------------------------------------------- + #Reset error handler (eg: for usermsg clear set in Banner_Installing) + G_ERROR_HANDLER_RESET + #------------------------------------------------------------------- + } Install_Linux_Software(){ @@ -7795,13 +6921,13 @@ libusb-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libsbc1 libsbc Banner_Installing - AGI alsa-utils + G_AGI alsa-utils #Apply soundcard - local soundcard=$(cat /DietPi/dietpi.txt | grep -m1 'soundcard=' | sed 's/.*=//') + local soundcard=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_SOUNDCARD=' | sed 's/.*=//') # - RPi enable internal HDMI+Analogue if currently set to 'none' - if (( $HW_MODEL < 10 )) && + if (( $G_HW_MODEL < 10 )) && [ "$soundcard" = "none" ] || [ "$soundcard" = "default" ]; then soundcard='rpi-bcm2835' @@ -7811,13 +6937,6 @@ libusb-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libsbc1 libsbc # - Apply /DietPi/dietpi/func/dietpi-set_hardware soundcard "$soundcard" - # - DietPi-JustBoom config panel Alias: - if (( ! $(cat /etc/bash.bashrc | grep -ci -m1 'dietpi-justboom=') )); then - - sed -i "/#DietPi Additions/a alias dietpi-justboom='/DietPi/dietpi/misc/dietpi-justboom'" /etc/bash.bashrc - - fi - fi INSTALLING_INDEX=6 @@ -7826,7 +6945,7 @@ libusb-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev libsbc1 libsbc Banner_Installing #Xserver Prereqs (ALL) - AGI xcompmgr xterm xinit xauth xserver-xorg dbus-x11 xfonts-base x11-xserver-utils x11-common x11-utils --no-install-recommends + G_AGI xcompmgr xterm xinit xauth xserver-xorg dbus-x11 xfonts-base x11-xserver-utils x11-common x11-utils --no-install-recommends #Improve performance on all desktops and devices (eg: removes window lag in desktops) by limiting compositions mkdir -p /etc/xdg/autostart @@ -7839,18 +6958,18 @@ Exec=xcompmgr -a _EOF_ #RPI - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then sleep 1 #Odroid C2 - elif (( $HW_MODEL == 12 )); then + elif (( $G_HW_MODEL == 12 )); then - AGI aml-libs-odroid mali450-odroid xf86-video-mali-odroid libump-odroid --no-install-recommends + G_AGI aml-libs-odroid mali450-odroid xf86-video-mali-odroid libump-odroid --no-install-recommends #cp /DietPi/dietpi/conf/xorg_c2.conf /etc/X11/xorg.conf # FBTURBO C2, provides much better desktop performance over Mali DDX: http://forum.odroid.com/viewtopic.php?f=138&t=19948&p=169808#p169808 - AGI xf86-video-fbturbo-odroid + G_AGI xf86-video-fbturbo-odroid cat << _EOF_ > /etc/X11/xorg.conf Section "Device" Identifier "FBTurbo" @@ -7862,37 +6981,34 @@ EndSection _EOF_ #Odroid XU4 - elif (( $HW_MODEL == 11 )); then + elif (( $G_HW_MODEL == 11 )); then - AGI firmware-samsung xf86-video-armsoc-odroid malit628-odroid --no-install-recommends + G_AGI firmware-samsung xf86-video-armsoc-odroid malit628-odroid --no-install-recommends cp /DietPi/dietpi/conf/xorg_xu4.conf /etc/X11/xorg.conf #Odroid C1 - elif (( $HW_MODEL == 10 )); then + elif (( $G_HW_MODEL == 10 )); then - AGI aml-libs-odroid xf86-video-mali-odroid libump-odroid mali450-odroid --no-install-recommends + G_AGI aml-libs-odroid xf86-video-mali-odroid libump-odroid mali450-odroid --no-install-recommends cp /DietPi/dietpi/conf/xorg_c1.conf /etc/X11/xorg.conf #Pine64 - elif (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then + elif (( $G_HW_MODEL == 40 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/all/libump_1-1_arm64.deb' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then + G_CHECK_URL "$INSTALL_URL_ADDRESS" - wget "$INSTALL_URL_ADDRESS" -O package.deb - dpkg -i package.deb - rm package.deb + wget "$INSTALL_URL_ADDRESS" -O package.deb + dpkg -i package.deb + rm package.deb - wget http://dietpi.com/downloads/binaries/all/xf86-video-fbturbo_1-1_arm64.deb -O package.deb - dpkg -i package.deb - rm package.deb + wget http://dietpi.com/downloads/binaries/all/xf86-video-fbturbo_1-1_arm64.deb -O package.deb + dpkg -i package.deb + rm package.deb - cat << _EOF_ > /etc/X11/xorg.conf + cat << _EOF_ > /etc/X11/xorg.conf Section "Device" Identifier "Allwinner A10/A13 FBDEV" Driver "fbturbo" @@ -7901,14 +7017,8 @@ Section "Device" EndSection _EOF_ - else - - Error_NoConnection_NoInstall - - fi - #Asus TB - # elif (( $HW_MODEL == 100 )); then + # elif (( $G_HW_MODEL == 52 )); then # cat << _EOF_ > /etc/X11/xorg.conf # Section "Device" @@ -7930,10 +7040,10 @@ _EOF_ Banner_Installing #Install - AGI nvidia-driver nvidia-xconfig + G_AGI nvidia-driver nvidia-xconfig # + i386 OpenGL - AGI libgl1-nvidia-glx:i386 + G_AGI libgl1-nvidia-glx:i386 fi @@ -7943,7 +7053,7 @@ _EOF_ Banner_Installing - AGI avahi-daemon + G_AGI avahi-daemon fi @@ -7951,7 +7061,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI build-essential make autoconf automake --no-install-recommends + G_AGI build-essential make autoconf automake --no-install-recommends fi @@ -7959,7 +7069,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI ntp + G_AGI ntp # Remove service, as DietPi ntpd-mode launches the binary with custom commands systemctl stop ntp @@ -7973,7 +7083,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI git --no-install-recommends + G_AGI git --no-install-recommends fi @@ -7981,7 +7091,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI vifm + G_AGI vifm fi @@ -7989,7 +7099,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI vim + G_AGI vim fi @@ -7997,7 +7107,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI vim-tiny + G_AGI vim-tiny fi @@ -8005,7 +7115,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI neovim + G_AGI neovim fi @@ -8013,7 +7123,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI emacs + G_AGI emacs fi @@ -8021,7 +7131,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI iperf + G_AGI iperf fi @@ -8029,7 +7139,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI mc + G_AGI mc fi @@ -8037,7 +7147,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI jed + G_AGI jed fi @@ -8045,7 +7155,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI iftop + G_AGI iftop fi @@ -8053,7 +7163,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI iptraf + G_AGI iptraf fi @@ -8061,7 +7171,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI mtr-tiny + G_AGI mtr-tiny fi @@ -8069,7 +7179,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI nload + G_AGI nload fi @@ -8077,7 +7187,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI tcpdump + G_AGI tcpdump fi @@ -8085,7 +7195,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI openssh-client + G_AGI openssh-client fi @@ -8097,7 +7207,7 @@ _EOF_ #Remove Information file rm /mnt/samba/readme.txt &> /dev/null - AGI smbclient cifs-utils --no-install-recommends + G_AGI smbclient cifs-utils --no-install-recommends fi @@ -8109,7 +7219,7 @@ _EOF_ #Remove information file rm /mnt/ftp_client/readme.txt &> /dev/null - AGI curlftpfs + G_AGI curlftpfs fi @@ -8121,7 +7231,7 @@ _EOF_ #Remove information file rm /mnt/nfs_client/readme.txt &> /dev/null - AGI nfs-common + G_AGI nfs-common fi @@ -8129,7 +7239,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI dropbear + G_AGI dropbear #set to start on next boot sed -i '/NO_START=1/c\NO_START=0' /etc/default/dropbear @@ -8140,7 +7250,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI openssh-server --no-install-recommends + G_AGI openssh-server --no-install-recommends # - Remove all references before adding the entry: https://github.com/Fourdee/DietPi/issues/604 @@ -8183,7 +7293,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI logrotate --no-install-recommends + G_AGI logrotate --no-install-recommends fi @@ -8191,7 +7301,7 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then Banner_Installing - AGI rsyslog --no-install-recommends + G_AGI rsyslog --no-install-recommends fi @@ -8201,29 +7311,22 @@ _EOF_ Banner_Installing #RPi + OpenMAX HW Encoding: https://github.com/Fourdee/DietPi/issues/869 - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/rpi/ffmpeg_rpi.7z' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then - - wget "$INSTALL_URL_ADDRESS" -O package.7z - 7z x -y package.7z -offmpeg_rpi - dpkg -i ffmpeg_rpi/*.deb - rm -R ffmpeg_rpi - rm package.7z - - else - - Error_NoConnection_NoInstall + G_CHECK_URL "$INSTALL_URL_ADDRESS" - fi + wget "$INSTALL_URL_ADDRESS" -O package.7z + 7z x -y package.7z -offmpeg_rpi + dpkg -i ffmpeg_rpi/*.deb + rm -R ffmpeg_rpi + rm package.7z #Everything else else - AGI ffmpeg + G_AGI ffmpeg fi @@ -8234,26 +7337,20 @@ _EOF_ Banner_Installing - # - Raspbian - if (( $HW_MODEL < 10 )); then + # On Jessie use backports repo: + if (( $G_DISTRO == 3 )); then - AGI oracle-java8-jdk - - # - Debian. Add repo - else - - cat << _EOF_ > /etc/apt/sources.list.d/webupd8team-java.list -deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main -deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main + cat << _EOF_ > /etc/apt/preferences.d/99-dietpi-openjdk-8-jdk +Package: openjdk-8-jdk +Pin: release a=jessie-backports +Pin-Priority: 990 _EOF_ - apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886 - apt-get update + G_AGI openjdk-8-jdk -t jessie-backports - # - Accept the license: https://github.com/Fourdee/DietPi/issues/298 - debconf-set-selections <<< "oracle-java8-installer shared/accepted-oracle-license-v1-1 boolean true" + else - AGI oracle-java8-installer + G_AGI openjdk-8-jdk fi @@ -8266,24 +7363,14 @@ _EOF_ #check, is online INSTALL_URL_ADDRESS='http://raw.githubusercontent.com/taaem/nodejs-linux-installer/master/node-install.sh' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - #Install - if (( $? == 0 )); then - - # - Preqs - wget "$INSTALL_URL_ADDRESS" -O node_install.sh - chmod +x node_install.sh - ./node_install.sh - - rm node_install.sh + G_CHECK_URL "$INSTALL_URL_ADDRESS" + # - Preqs + wget "$INSTALL_URL_ADDRESS" -O node_install.sh + chmod +x node_install.sh + ./node_install.sh - else - - Error_NoConnection_NoInstall - - fi + rm node_install.sh fi @@ -8293,24 +7380,16 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='https://bootstrap.pypa.io/get-pip.py' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" - if (( $? == 0 )); then + # - Preqs + G_AGI python python-dev - # - Preqs - AGI python python-dev + wget "$INSTALL_URL_ADDRESS" -O install.py + python ./install.py + rm install.py - wget "$INSTALL_URL_ADDRESS" -O install.py - python ./install.py - rm install.py - - AGI python-pip python3-pip - - else - - Error_NoConnection_NoInstall - - fi + G_AGI python-pip python3-pip fi @@ -8321,24 +7400,16 @@ _EOF_ Banner_Installing INSTALL_URL_ADDRESS='http://dietpi.com/downloads/binaries/rpi/sdl2_rpi.7z' - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" - - if (( $? == 0 )); then - - #AGI libxss1 #if using SDL2+rpi5 + G_CHECK_URL "$INSTALL_URL_ADDRESS" - wget "$INSTALL_URL_ADDRESS" -O package.7z - 7z x -y package.7z -osdl2_rpi - rm package.7z - - dpkg -i sdl2_rpi/no_opengl_x11/*.deb - rm -R sdl2_rpi - - else + #G_AGI libxss1 #if using SDL2+rpi5 - Error_NoConnection_NoInstall + wget "$INSTALL_URL_ADDRESS" -O package.7z + 7z x -y package.7z -osdl2_rpi + rm package.7z - fi + dpkg -i sdl2_rpi/no_opengl_x11/*.deb + rm -R sdl2_rpi fi @@ -8351,19 +7422,19 @@ _EOF_ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF #ARMv6 only available in raspbian repo: https://github.com/Fourdee/DietPi/issues/1023 - if (( $HW_ARCH == 1 )); then + if (( $G_HW_ARCH == 1 )); then - echo -e "deb http://download.mono-project.com/repo/debian raspbian$DISTRO_NAME main" > /etc/apt/sources.list.d/mono-xamarin.list + echo -e "deb http://download.mono-project.com/repo/debian raspbian$G_DISTRO_NAME main" > /etc/apt/sources.list.d/mono-xamarin.list else - echo -e "deb http://download.mono-project.com/repo/debian $DISTRO_NAME main" > /etc/apt/sources.list.d/mono-xamarin.list + echo -e "deb http://download.mono-project.com/repo/debian $G_DISTRO_NAME main" > /etc/apt/sources.list.d/mono-xamarin.list fi - apt-get update + G_AGUP - AGI mono-runtime + G_AGI mono-runtime fi @@ -8379,19 +7450,22 @@ _EOF_ HA_PYENV_ACTIVATION="export PATH=\"$HA_USERROOT/.pyenv/bin:\$PATH\"; eval \"\$(pyenv init -)\"; eval \"\$(pyenv virtualenv-init -)\"" HA_PYTHON_VERSION="3.6.3" - /DietPi/dietpi/func/dietpi-notify 2 "HA_USER: $HA_USER" - /DietPi/dietpi/func/dietpi-notify 2 "HA_USERROOT: $HA_USERROOT" - /DietPi/dietpi/func/dietpi-notify 2 "HA_SRVROOT: $HA_SRVROOT" - /DietPi/dietpi/func/dietpi-notify 2 "HA_PYENV_ACTIVATION: $HA_PYENV_ACTIVATION" - /DietPi/dietpi/func/dietpi-notify 2 "HA_PYTHON_VERSION: $HA_PYTHON_VERSION" + G_DIETPI-NOTIFY 2 "HA_USER: $HA_USER" + G_DIETPI-NOTIFY 2 "HA_USERROOT: $HA_USERROOT" + G_DIETPI-NOTIFY 2 "HA_SRVROOT: $HA_SRVROOT" + G_DIETPI-NOTIFY 2 "HA_PYENV_ACTIVATION: $HA_PYENV_ACTIVATION" + G_DIETPI-NOTIFY 2 "HA_PYTHON_VERSION: $HA_PYTHON_VERSION" # Install needed libraries - 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 - if (( $DISTRO == 3 )); then - AGI libmysqlclient-dev - fi - if (( $DISTRO == 4 )); then - AGI libmariadbclient-dev + 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 + if (( $G_DISTRO < 4 )); then + + G_AGI libmysqlclient-dev + + else + + G_AGI libmariadbclient-dev + fi # Setup the user account information @@ -8430,6 +7504,9 @@ _EOF_ fi #------------------------------------------------------------------- + #Reset error handler (eg: for usermsg clear set in Banner_Installing) + G_ERROR_HANDLER_RESET + #------------------------------------------------------------------- } @@ -8477,7 +7554,7 @@ _EOF_ fi #Inform user (From testing, stopping SSH server services does not disconnect user, however, just incase it does in the future) - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Software "Stopping SSH servers" + G_DIETPI-NOTIFY 3 DietPi-Software "Stopping SSH servers" #stop all SSH server services service ssh stop &> /dev/null @@ -8580,7 +7657,7 @@ _EOF_ Install_Apply_Permissions(){ #Not all permissions are listed here. - # - Only ones which are shared across programs, and/or located inside FP_DIETPI_USERDATA_DIRECTORY that require non-root permissions. + # - Only ones which are shared across programs, and/or located inside G_FP_DIETPI_USERDATA that require non-root permissions. #- /var/www / www-data chown -R www-data:www-data /var/www @@ -8591,42 +7668,51 @@ _EOF_ chmod -R 777 /var/www/ompd/stream #(required for streaming files) chmod -R 777 /var/www/ompd/cache #(required for downloading files) - #Apply non-root permissions for files and folders in FP_DIETPI_USERDATA_DIRECTORY + #Apply non-root permissions for files and folders in G_FP_DIETPI_USERDATA # - dietpi user chown -R dietpi:dietpi /home/dietpi - chown -R dietpi:dietpi "$FP_DIETPI_USERDATA_DIRECTORY" - chmod -R 775 "$FP_DIETPI_USERDATA_DIRECTORY" + chown -R dietpi:dietpi "$G_FP_DIETPI_USERDATA" + chmod -R 775 "$G_FP_DIETPI_USERDATA" # + for symlinked locations - chown -R dietpi:dietpi "$FP_DIETPI_USERDATA_DIRECTORY"/* - chmod -R 775 "$FP_DIETPI_USERDATA_DIRECTORY"/* + chown -R dietpi:dietpi "$G_FP_DIETPI_USERDATA"/* + chmod -R 775 "$G_FP_DIETPI_USERDATA"/* # - MPD - chown -R mpd:audio "$FP_DIETPI_USERDATA_DIRECTORY"/.mpd_cache + chown -R mpd:audio "$G_FP_DIETPI_USERDATA"/.mpd_cache # - MySQL data store - chown -R mysql:mysql "$FP_DIETPI_USERDATA_DIRECTORY"/mysql - chmod -R 770 "$FP_DIETPI_USERDATA_DIRECTORY"/mysql + chown -R mysql:mysql "$G_FP_DIETPI_USERDATA"/mysql + chmod -R 770 "$G_FP_DIETPI_USERDATA"/mysql - chown -R mineos:mineos "$FP_DIETPI_USERDATA_DIRECTORY"/mineos/serverdata - chown -R urbackup:urbackup "$FP_DIETPI_USERDATA_DIRECTORY"/urbackup - #chown -R couchpotato:couchpotato "$FP_DIETPI_USERDATA_DIRECTORY"/couchpotato + chown -R mineos:mineos "$G_FP_DIETPI_USERDATA"/mineos/serverdata + chown -R urbackup:urbackup "$G_FP_DIETPI_USERDATA"/urbackup + #chown -R couchpotato:couchpotato "$G_FP_DIETPI_USERDATA"/couchpotato # - www-data - chown -R www-data:www-data "$FP_DIETPI_USERDATA_DIRECTORY"/dietpicam - chown -R www-data:www-data "$FP_DIETPI_USERDATA_DIRECTORY"/pydio_data - chown -R www-data:www-data "$FP_DIETPI_USERDATA_DIRECTORY"/owncloud_data - chown -R www-data:www-data "$FP_DIETPI_USERDATA_DIRECTORY"/nextcloud_data + chown -R www-data:www-data "$G_FP_DIETPI_USERDATA"/dietpicam + chown -R www-data:www-data "$G_FP_DIETPI_USERDATA"/pydio_data + + local datadir=$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_OWNCLOUD_DATADIR=' | sed 's/.*=//') + [ ! -n "$datadir" ] && datadir="$G_FP_DIETPI_USERDATA/owncloud_data" + chown -R www-data:www-data "$datadir" + + datadir=$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_NEXTCLOUD_DATADIR=' | sed 's/.*=//') + [ ! -n "$datadir" ] && datadir="$G_FP_DIETPI_USERDATA/nextcloud_data" + chown -R www-data:www-data "$datadir" # - Home Assistant Permissions #chown -R homeassistant:dietpi /home/homeassistant/.homeassistant - #chown -R dietpi:dietpi "$FP_DIETPI_USERDATA_DIRECTORY"/homeassistant + #chown -R dietpi:dietpi "$G_FP_DIETPI_USERDATA"/homeassistant # - Minio - chown -R minio-user:minio-user "$FP_DIETPI_USERDATA_DIRECTORY"/minio-data + chown -R minio-user:minio-user "$G_FP_DIETPI_USERDATA"/minio-data # - FuguHub - chown -R bd:bd "$FP_DIETPI_USERDATA_DIRECTORY"/fuguhub-data/ + chown -R bd:bd "$G_FP_DIETPI_USERDATA"/fuguhub-data/ + + # - Nodered + chown -R nodered:nodered "$G_FP_DIETPI_USERDATA"/node-red } @@ -8657,7 +7743,7 @@ _EOF_ # Create_Desktop_Shared_Items # # #Odroid C2, define default pulseaudio sink: https://github.com/Fourdee/DietPi/issues/415 - # if (( $HW_MODEL == 12 && + # if (( $G_HW_MODEL == 12 && # ! $(cat /etc/pulse/default.pa | grep -ci -m1 '^set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo') )); then # # echo -e "set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo" >> /etc/pulse/default.pa @@ -8676,6 +7762,8 @@ _EOF_ INSTALLING_INDEX=23 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Remove Lxrandr Menu item (monitor configuration tool as we set res in dietpi-config) rm /usr/share/applications/lxrandr.desktop &> /dev/null @@ -8706,13 +7794,15 @@ _EOF_ INSTALLING_INDEX=24 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - 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 (( $HW_MODEL == 12 && + if (( $G_HW_MODEL == 12 && ! $(cat /etc/pulse/default.pa | grep -ci -m1 '^set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo') )); then echo -e "set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo" >> /etc/pulse/default.pa @@ -8725,6 +7815,8 @@ _EOF_ INSTALLING_INDEX=26 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + Create_Desktop_Shared_Items fi @@ -8733,6 +7825,8 @@ _EOF_ INSTALLING_INDEX=25 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + Create_Desktop_Shared_Items fi @@ -8741,6 +7835,8 @@ _EOF_ INSTALLING_INDEX=83 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #create www directory mkdir -p /var/www @@ -8758,7 +7854,7 @@ _EOF_ cat << _EOF_ > /etc/apache2/mods-available/mpm_event.conf -StartServers $CPU_CORES_TOTAL +StartServers $G_HW_CPU_CORES MinSpareThreads 1 MaxSpareThreads 8 ThreadLimit 16 @@ -8770,9 +7866,9 @@ _EOF_ cat << _EOF_ > /etc/apache2/mods-available/mpm_prefork.conf -StartServers $CPU_CORES_TOTAL +StartServers $G_HW_CPU_CORES MinSpareServers 1 -MaxSpareServers $CPU_CORES_TOTAL +MaxSpareServers $G_HW_CPU_CORES MaxRequestWorkers 50 MaxConnectionsPerChild 0 @@ -8780,7 +7876,7 @@ _EOF_ cat << _EOF_ > /etc/apache2/mods-available/mpm_worker.conf -StartServers $CPU_CORES_TOTAL +StartServers $G_HW_CPU_CORES MinSpareThreads 1 MaxSpareThreads 8 ThreadLimit 16 @@ -8804,6 +7900,8 @@ _EOF_ INSTALLING_INDEX=85 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #create www directory mkdir -p /var/www @@ -8812,17 +7910,17 @@ _EOF_ cp /DietPi/dietpi/conf/nginx.conf /etc/nginx/nginx.conf # - Stretch , set php7.0 - if (( $DISTRO >= 4 )); then + if (( $G_DISTRO >= 4 )); then sed -i "s#/run/php5-fpm.sock#/run/php/php7.0-fpm.sock#g" /etc/nginx/nginx.conf fi # - CPU core count - sed -i "/worker_processes/c\worker_processes $CPU_CORES_TOTAL;" /etc/nginx/nginx.conf + sed -i "/worker_processes/c\worker_processes $G_HW_CPU_CORES;" /etc/nginx/nginx.conf #Default site cp /DietPi/dietpi/conf/nginx.site-available-default /etc/nginx/sites-available/default # - Stretch , set php7.0 - if (( $DISTRO >= 4 )); then + if (( $G_DISTRO >= 4 )); then sed -i "s#/run/php5-fpm.sock#/run/php/php7.0-fpm.sock#g" /etc/nginx/sites-available/default fi @@ -8835,6 +7933,8 @@ _EOF_ INSTALLING_INDEX=84 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #create www directory mkdir -p /var/www @@ -8843,8 +7943,10 @@ _EOF_ #Configure fastcgi for PHP-FPM local fp_php_fpm_sock='/var/run/php/php7.0-fpm.sock' - if (( $DISTRO == 3 )); then + if (( $G_DISTRO == 3 )); then + fp_php_fpm_sock='/var/run/php5-fpm.sock' + fi cat << _EOF_ > /etc/lighttpd/conf-available/15-fastcgi-php.conf @@ -8876,6 +7978,8 @@ _EOF_ INSTALLING_INDEX=89 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - Apache2 has its own PHP module if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then @@ -8891,10 +7995,10 @@ _EOF_ sed -i '/cgi.fix_pathinfo=/c\cgi.fix_pathinfo=1' "$FP_PHP_BASE_DIR"/fpm/php.ini # - PHP-FPM optimizations based on total cores - sed -i "/pm.max_children = /c\pm.max_children = $CPU_CORES_TOTAL" "$FP_PHP_BASE_DIR"/fpm/pool.d/www.conf - sed -i "/pm.start_servers = /c\pm.start_servers = $CPU_CORES_TOTAL" "$FP_PHP_BASE_DIR"/fpm/pool.d/www.conf - sed -i "/pm.min_spare_servers = /c\pm.min_spare_servers = $CPU_CORES_TOTAL" "$FP_PHP_BASE_DIR"/fpm/pool.d/www.conf - sed -i "/pm.max_spare_servers = /c\pm.max_spare_servers = $CPU_CORES_TOTAL" "$FP_PHP_BASE_DIR"/fpm/pool.d/www.conf + sed -i "/pm.max_children = /c\pm.max_children = $(( $G_HW_CPU_CORES * 3 ))" "$FP_PHP_BASE_DIR"/fpm/pool.d/www.conf + sed -i "/pm.start_servers = /c\pm.start_servers = $G_HW_CPU_CORES" "$FP_PHP_BASE_DIR"/fpm/pool.d/www.conf + sed -i "/pm.min_spare_servers = /c\pm.min_spare_servers = $G_HW_CPU_CORES" "$FP_PHP_BASE_DIR"/fpm/pool.d/www.conf + sed -i "/pm.max_spare_servers = /c\pm.max_spare_servers = $G_HW_CPU_CORES" "$FP_PHP_BASE_DIR"/fpm/pool.d/www.conf # - Enviroment PHP settings: sed -i "/env\[HOSTNAME\]/c\env\[HOSTNAME\] = \$HOSTNAME" "$FP_PHP_BASE_DIR"/fpm/pool.d/www.conf @@ -9006,46 +8110,33 @@ _EOF_ fi - #WEBSERVER_MYSQL - INSTALLING_INDEX=86 + #WEBSERVER_MARIADB + INSTALLING_INDEX=88 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - #Optimize for reduced memory use: https://github.com/Fourdee/DietPi/issues/605#issue-188930987 - cat << _EOF_ > /etc/mysql/conf.d/reduce_resources.cnf -[mysqld] -key_buffer_size=8M -max_connections=30 -query_cache_size=8M -query_cache_limit=512K -thread_stack=128K -_EOF_ - - fi - - #MariaDB + MySQL | Move SQL store to userdata location: https://github.com/Fourdee/DietPi/issues/672 - if (( ${aSOFTWARE_INSTALL_STATE[86]} == 1 || - ${aSOFTWARE_INSTALL_STATE[88]} == 1 )); then + Banner_Configuration - if [ "$(readlink /var/lib/mysql)" != "$FP_DIETPI_USERDATA_DIRECTORY/mysql" ]; then + # Move SQL store to userdata location: https://github.com/Fourdee/DietPi/issues/672 + if [ "$(readlink /var/lib/mysql)" != "$G_FP_DIETPI_USERDATA/mysql/" ]; then - systemctl stop mysql + G_RUN_CMD systemctl stop mysql # - Create target dir - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/mysql + mkdir -p "$G_FP_DIETPI_USERDATA"/mysql # - copy - cp -R /var/lib/mysql/* "$FP_DIETPI_USERDATA_DIRECTORY"/mysql/ + cp -a /var/lib/mysql/* "$G_FP_DIETPI_USERDATA"/mysql/ if (( $? != 0 )); then - /DietPi/dietpi/func/dietpi-notify 1 "Moving of MySQL data store failed to $FP_DIETPI_USERDATA_DIRECTORY/mysql. DietPi-Software will now exit" + G_DIETPI-NOTIFY 1 "Moving of MySQL data store failed to $G_FP_DIETPI_USERDATA/mysql. DietPi-Software will now exit" Exit_Destroy fi - rm -R /var/lib/mysql + rm -R /var/lib/mysql &> /dev/null || rm /var/lib/mysql &> /dev/null # - Symlink - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/mysql /var/lib/mysql + ln -sf "$G_FP_DIETPI_USERDATA"/mysql /var/lib/mysql chown mysql:mysql /var/lib/mysql @@ -9054,12 +8145,36 @@ _EOF_ fi + # On Jessie assure unix_socket authentication: + if (( $G_DISTRO < 4 )); then + + G_RUN_CMD systemctl start mysql + mysql -e "install plugin unix_socket soname 'auth_socket';" &> /dev/null + mysql -e "grant all privileges on *.* to 'root'@'localhost' identified via unix_socket with grant option;flush privileges" + # Drop unnecessary root user children. + mysql -e "drop user 'root'@'dietpi';drop user 'root'@'127.0.0.1';drop user 'root'@'::1'" &> /dev/null + + fi + + ### Also for MariaDB? + # Optimize for reduced memory use: https://github.com/Fourdee/DietPi/issues/605#issue-188930987 + #cat << _EOF_ > /etc/mysql/conf.d/reduce_resources.cnf +#[mysqld] +#key_buffer_size=8M +#max_connections=30 +#query_cache_size=8M +#query_cache_limit=512K +#thread_stack=128K +#_EOF_ + fi #WEBSERVER_MYADMINPHP INSTALLING_INDEX=90 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #NGINX LIGHTTPD symlink to var www if (( ${aSOFTWARE_INSTALL_STATE[84]} >= 1 || ${aSOFTWARE_INSTALL_STATE[85]} >= 1 )); then @@ -9068,12 +8183,19 @@ _EOF_ fi + # Due to MariaDB unix_socket authentication, "root" cannot be used to login the web ui. + # Thus default "phpmyadmin" user need to be used, who on Jessie does not have all privileges: + # http://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=54#p54 + mysql -e "grant all privileges on *.* to phpmyadmin@localhost with grant option" + fi #WEBSERVER_REDIS INSTALLING_INDEX=91 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # Enable redis php module, if installed: "$PHP_APT_PACKAGE_NAME"enmod redis 2> /dev/null @@ -9083,6 +8205,8 @@ _EOF_ INSTALLING_INDEX=58 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - service cat << _EOF_ > /etc/systemd/system/openbazaar.service [Unit] @@ -9103,6 +8227,8 @@ _EOF_ INSTALLING_INDEX=133 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + chmod +x -R /etc/yacy cat << _EOF_ > /etc/systemd/system/yacy.service @@ -9129,10 +8255,12 @@ _EOF_ INSTALLING_INDEX=47 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - # Enable necessary PHP modules: https://doc.owncloud.org/server/latest/admin_manual/installation/source_installation.html#php-extensions - ${PHP_APT_PACKAGE_NAME}enmod curl gd intl json pdo_mysql opcache apcu redis + Banner_Configuration + + G_DIETPI-NOTIFY 2 'Enabling needed PHP modules: https://doc.owncloud.org/server/latest/admin_manual/installation/source_installation.html#php-extensions' + "$PHP_APT_PACKAGE_NAME"enmod curl gd intl json pdo_mysql opcache apcu redis # Following modules are switchable since Stretch: - if (( $DISTRO > 3 )); then + if (( $G_DISTRO > 3 )); then phpenmod ctype dom fileinfo iconv mbstring posix simplexml xmlwriter xmlreader zip exif @@ -9141,100 +8269,106 @@ _EOF_ # APCu configuration: To prevent cli (cron.php) producing ownCloud log entries. grep -q 'apc.enable_cli=' $FP_PHP_BASE_DIR/mods-available/apcu.ini && sed -i '/apc.enable_cli=/c\apc.enable_cli=1' $FP_PHP_BASE_DIR/mods-available/apcu.ini || echo 'apc.enable_cli=1' >> $FP_PHP_BASE_DIR/mods-available/apcu.ini - # Create ownCloud specific webserver config. - # Apache: https://doc.owncloud.org/server/latest/admin_manual/installation/source_installation.html#configure-apache-web-server if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then - a2enmod rewrite headers env dir mime &> /dev/null + G_DIETPI-NOTIFY 2 'Apache webserver found, enable ownCloud specific configuration: "https://doc.owncloud.org/server/latest/admin_manual/installation/source_installation.html#configure-apache-web-server"' + a2enmod rewrite headers env dir mime 1> /dev/null local owncloud_conf='/etc/apache2/sites-available/owncloud.conf' - # Do not overwrite existing config. if [ -f $owncloud_conf ]; then - owncloud_conf='/etc/apache2/sites-available/owncloud.conf.new' + G_DIETPI-NOTIFY 2 'Existing ownCloud configuration found, will save the new one for review and comparison to: /etc/apache2/sites-available/owncloud.conf.dietpi-new' + owncloud_conf='/etc/apache2/sites-available/owncloud.conf.dietpi-new' fi cp /DietPi/dietpi/conf/apache.ownnextcloud.conf $owncloud_conf - sed -i "s/nextcloud/owncloud/g" $owncloud_conf - # OPCache adjustment is just forced by Nextcloud - sed -i "s/php_admin_value/#php_admin_value/" $owncloud_conf - a2ensite owncloud &> /dev/null + sed -i 's/nextcloud/owncloud/g' $owncloud_conf + # OPcache adjustment is just needed by Nextcloud + sed -i 's/php_admin_value/#php_admin_value/' $owncloud_conf + a2ensite owncloud 1> /dev/null fi - # NGINX: https://doc.owncloud.org/server/latest/admin_manual/installation/nginx_configuration.html#owncloud-in-a-subdir-of-nginx if (( ${aSOFTWARE_INSTALL_STATE[85]} >= 1 )); then + G_DIETPI-NOTIFY 2 'Nginx webserver found, enable ownCloud specific configuration: "https://doc.owncloud.org/server/latest/admin_manual/installation/nginx_configuration.html#owncloud-in-a-subdir-of-nginx"' local owncloud_config='/etc/nginx/sites-dietpi/owncloud.config' - # Do not overwrite existing config. if [ -f $owncloud_config ]; then - owncloud_config='/etc/nginx/sites-dietpi/owncloud.config.new' + G_DIETPI-NOTIFY 2 'Existing ownCloud configuration found, will save the new one for review and comparison to: /etc/nginx/sites-dietpi/owncloud.config.dietpi-new' + owncloud_config='/etc/nginx/sites-dietpi/owncloud.config.dietpi-new' fi cp /DietPi/dietpi/conf/nginx.sites-dietpi.owncloud.config $owncloud_config # Stretch: Use PHP7.0 socket and set 'fastcgi_request_buffering off'; - if (( $DISTRO > 3 )); then + if (( $G_DISTRO > 3 )); then - sed -i "s#/run/php5-fpm.sock#/run/php/php7.0-fpm.sock#g" $owncloud_config - sed -i "s/#fastcgi_request_buffering off;/fastcgi_request_buffering off;/g" $owncloud_config + sed -i 's|/run/php5-fpm.sock|/run/php/php7.0-fpm.sock|g' $owncloud_config + sed -i 's/#fastcgi_request_buffering off;/fastcgi_request_buffering off;/g' $owncloud_config fi # Set HTTPS on, if SSL connection is available, even with self-signed/untrusted certificate. - DietPi/dietpi/func/check_connection https://localhost &> /dev/null + wget -q --spider --timeout=10 --tries=2 https://localhost &> /dev/null if (( $? == 0 || $? == 5)); then - sed -i "s/#fastcgi_param HTTPS on;/fastcgi_param HTTPS on;/g" $owncloud_config + sed -i 's/#fastcgi_param HTTPS on;/fastcgi_param HTTPS on;/g' $owncloud_config fi fi - # Enable MySQL 4-byte support: https://doc.owncloud.org/server/latest/admin_manual/configuration/database/linux_database_configuration.html#configure-mysql-for-4-byte-unicode-support - cat << _EOF_ > /etc/mysql/conf.d/99-dietpi-4bit.cnf + # 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 + cat << _EOF_ > /etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf [mysqld] innodb_large_prefix=1 innodb_file_format=barracuda innodb_file_per_table=1 _EOF_ - # Check if we really do fresh installation: - local oc_is_fresh=1 - if [ -d '/mnt/dietpi_userdata/mysql/owncloud' ]; then - - oc_is_fresh=0 - - fi + G_RUN_CMD systemctl restart mysql - # Add occ command shortcut: - echo -e '#!/bin/bash\nsudo -u www-data php /var/www/owncloud/occ $*' > /usr/local/bin/occ - chmod +x /usr/local/bin/occ + # Reload dietpi-globals to enable occ command shortcut: + . /DietPi/dietpi/func/dietpi-globals # Adjusting config file: local config_php='/var/www/owncloud/config/config.php' - # Terminal installation: - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/owncloud_data + local datadir="$(grep -m1 '^[[:blank:]]*SOFTWARE_OWNCLOUD_DATADIR=' /DietPi/dietpi.txt | sed 's/^.*=//')" + [ -n "$datadir" ] || datadir="$G_FP_DIETPI_USERDATA/owncloud_data" + mkdir -p "$datadir" Install_Apply_Permissions &> /dev/null - local username=$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_nextcloud_username=' | sed 's/.*=//') - if [ ! -n "$username" ]; then - username='admin' + if [ -d "$G_FP_DIETPI_USERDATA"/mysql/owncloud ]; then - fi - systemctl start mysql - # For MariaDB, temporary database admin user needs to be created, as 'root' uses unix_socket login, which cannot be accessed by sudo -u www-data. - mysql -uroot -p"$GLOBAL_PW" -e "grant all privileges on *.* to 'tmp_root'@'localhost' identified by '$GLOBAL_PW' with grant option" - grep -q "'installed' => true," $config_php 2>/dev/null || occ maintenance:install --no-interaction --database "mysql" --database-name "owncloud" --database-user "tmp_root" --database-pass "$GLOBAL_PW" --admin-user "$username" --admin-pass "$GLOBAL_PW" --data-dir "$FP_DIETPI_USERDATA_DIRECTORY/owncloud_data" - mysql -uroot -p"$GLOBAL_PW" -e "drop user 'tmp_root'@'localhost'" + G_DIETPI-NOTIFY 2 'ownCloud database found, will NOT overwrite.' + + else + + if [ -f "$datadir"/dietpi-owncloud-database-backup.sql ]; then + + G_DIETPI-NOTIFY 2 'ownCloud database backup found, starting recovery...' + local dbuser=$(grep -m1 "^[[:blank:]]*'dbuser'" $config_php | awk '{print $3}' | sed "s/[',]//g") + local dbpass=$(grep -m1 "^[[:blank:]]*'dbpassword'" $config_php | awk '{print $3}' | sed "s/[',]//g") + /DietPi/dietpi/func/create_mysql_db owncloud "$dbuser" "$dbpass" + mysql -uroot owncloud < "$datadir"/dietpi-owncloud-database-backup.sql + + else - # Enable MySQL 4-byte support for new installations only, to prevent risky database conversion tasks: - if (( $oc_is_fresh == 1 )); then + local username="$(cat /DietPi/dietpi.txt | grep -m1 '^[[:blank:]]*SOFTWARE_OWNCLOUD_NEXTCLOUD_USERNAME=' | sed 's/^.*=//')" + [ -n "$username" ] || username='admin' - grep -q "'mysql.utf8mb4' => " $config_php || sed -i "/'dbpassword'/a \ \ 'mysql.utf8mb4' => true," $config_php + # For MariaDB, temporary database admin user needs to be created, as 'root' uses unix_socket login, which cannot be accessed by sudo -u www-data. + mysql -e "grant all privileges on *.* to 'tmp_root'@'localhost' identified by '$GLOBAL_PW' with grant option" + grep -q "'installed' => true," $config_php 2>/dev/null || occ maintenance:install --no-interaction --database "mysql" --database-name "owncloud" --database-user "tmp_root" --database-pass "$GLOBAL_PW" --admin-user "$username" --admin-pass "$GLOBAL_PW" --data-dir "$datadir" + mysql -e "drop user 'tmp_root'@'localhost'" + + fi fi + # Enable ownCloud to use 4-byte database + grep -q "^[[:blank:]]*'mysql.utf8mb4'" $config_php || sed -i "/^[[:blank:]]*'dbpassword'/a \ \ 'mysql.utf8mb4' => true," $config_php + # Add local IP and hostname to trusted domains. # If "1 => '" does not exist, the config.php is not copied e.g. from older instance, so we add entries. if (( ! $(cat $config_php | grep -ci -m1 "1 => '") )); then @@ -9245,20 +8379,26 @@ _EOF_ fi # Set CLI URL to ownCloud sub directory: - sed -i "s#'http://localhost'#'http://localhost/owncloud'#g" $config_php + sed -i "s|'http://localhost'|'http://localhost/owncloud'|g" $config_php - # APCu Memcache - if (( ! $(cat $config_php | grep -ci -m1 "'memcache.local'") )); then + # Set pretty URLs (without /index.php/) on Apache: + if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then - sed -i "/'version'/a 'memcache.local' => '\\\OC\\\Memcache\\\APCu'," $config_php + grep -q "^[[:blank:]]*'htaccess.RewriteBase'" $config_php || sed -i "/^[[:blank:]]*'overwrite.cli.url'/a \ \ 'htaccess.RewriteBase' => '/owncloud'," $config_php + occ maintenance:update:htaccess fi + # APCu Memcache + grep -q "^[[:blank:]]*'memcache.local'" $config_php || sed -i "/^[[:blank:]]*'version'/a \ \ 'memcache.local' => '\\\OC\\\Memcache\\\APCu'," $config_php + # Redis for transactional file locking: # https://doc.owncloud.org/server/latest/admin_manual/configuration/server/caching_configura$ # - Enable Redis socket and grant www-data access to it: - sed -i "\#unixsocket /#c\unixsocket /var/run/redis/redis.sock" /etc/redis/redis*.conf - sed -i "\#unixsocketperm#c\unixsocketperm 770" /etc/redis/redis*.conf + local redis_conf="/etc/redis/redis*.conf" + grep -q "^[[:blank:]]*unixsocket /" $redis_conf || grep -q '^[[:blank:]]*#unixsocket /' $redis_conf && sed -i 's|^[[:blank:]]*#unixsocket /|unixsocket /|' $redis_conf || echo 'unixsocket /var/run/redis/redis.sock' >> $redis_conf + grep -q "^[[:blank:]]*#?unixsocketperm " $redis_conf && sed -i "/^[[:blank:]]*#?unixsocketperm /c\unixsocketperm 770" $redis_conf || echo 'unixsocketperm 770' >> $redis_conf + local redis_sock=$(grep "^[[:blank:]]*unixsocket /" $redis_conf | sed "s/^[[:blank:]]*unixsocket //") usermod -a -G redis www-data # - Enable ownCloud to use Redis socket: if (( ! $(cat $config_php | grep -ci -m1 "'memcache.locking'") )); then @@ -9266,28 +8406,18 @@ _EOF_ sed -i "\#'memcache.local'#a \ \ 'filelocking.enabled' => true,\n\ 'memcache.locking' => '\\\OC\\\Memcache\\\Redis',\n\ 'redis' => [\n\ - 'host' => '/var/run/redis/redis.sock',\n\ + 'host' => '$redis_sock',\n\ 'port' => 0,\n\ ]," $config_php fi - # ownCloud/Nextcloud ignores system wide php.ini settings. Use their own config. - # Set max upload size - local php_max_upload_size="$(( $(php -r 'print(PHP_INT_MAX);') / 1024 / 1024))M" - sed -i "/upload_max_filesize=/c\upload_max_filesize=$php_max_upload_size" /var/www/owncloud/.user.ini - sed -i "/post_max_size=/c\post_max_size=$php_max_upload_size" /var/www/owncloud/.user.ini - - # Set memory limit: total / 4 - local memory_limit_max="$(( $RAM_TOTAL / 4 ))M" - sed -i "/memory_limit=/c\memory_limit=$memory_limit_max" /var/www/owncloud/.user.ini - # Enable ownCloud background cron job: crontab -u www-data -l 2>/dev/null | grep -q '/var/www/owncloud/cron.php' || ( crontab -u www-data -l 2>/dev/null ; echo "*/15 * * * * php /var/www/owncloud/cron.php" ) | crontab -u www-data - occ background:cron # Enable maintenance mode to allow handling by dietpi-services: - grep -q "'maintenance' => true," $config_php &>/dev/null || occ maintenance:mode --on + grep -q "^[[:blank:]]*'maintenance' => true," $config_php || occ maintenance:mode --on fi @@ -9295,10 +8425,12 @@ _EOF_ INSTALLING_INDEX=114 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - # Enable necessary PHP modules: https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation - ${PHP_APT_PACKAGE_NAME}enmod curl gd intl json pdo_mysql opcache apcu redis + Banner_Configuration + + G_DIETPI-NOTIFY 2 'Enabling needed PHP modules: https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation' + "$PHP_APT_PACKAGE_NAME"enmod curl gd intl json pdo_mysql opcache apcu redis # Following modules are switchable since Stretch: - if (( $DISTRO > 3 )); then + if (( $G_DISTRO > 3 )); then phpenmod ctype dom fileinfo iconv mbstring posix simplexml xmlwriter xmlreader zip exif @@ -9315,97 +8447,121 @@ _EOF_ grep -q 'opcache.save_comments=' $FP_PHP_BASE_DIR/mods-available/opcache.ini && sed -i '/opcache.save_comments=/c\opcache.save_comments=1' $FP_PHP_BASE_DIR/mods-available/opcache.ini || echo 'opcache.save_comments=1' >> $FP_PHP_BASE_DIR/mods-available/opcache.ini grep -q 'opcache.revalidate_freq=' $FP_PHP_BASE_DIR/mods-available/opcache.ini && sed -i '/opcache.revalidate_freq=/c\opcache.revalidate_freq=1' $FP_PHP_BASE_DIR/mods-available/opcache.ini || echo 'opcache.revalidate_freq=1' >> $FP_PHP_BASE_DIR/mods-available/opcache.ini - # Create Nextcloud specific webserver config. - # Apache: https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html#apache-web-server-configuration if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then - a2enmod rewrite headers env dir mime &> /dev/null + G_DIETPI-NOTIFY 2 'Apache webserver found, enable Nextcloud specific configuration: "https://docs.nextcloud.com/server/12/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/nextcloud.conf' - # Do not overwrite existing config. if [ -f $nextcloud_conf ]; then - nextcloud_conf='/etc/apache2/sites-available/nextcloud.conf.new' + G_DIETPI-NOTIFY 2 'Existing Nextcloud configuration found, will save the new one for review and comparison to: /etc/apache2/sites-available/nextcloud.conf.dietpi-new' + nextcloud_conf='/etc/apache2/sites-available/nextcloud.conf.dietpi-new' fi cp /DietPi/dietpi/conf/apache.ownnextcloud.conf $nextcloud_conf - a2ensite nextcloud &> /dev/null + a2ensite nextcloud 1> /dev/null fi - # Nginx: https://docs.nextcloud.com/server/12/admin_manual/installation/nginx.html#nextcloud-in-a-subdir-of-nginx if (( ${aSOFTWARE_INSTALL_STATE[85]} >= 1 )); then + G_DIETPI-NOTIFY 2 'Nginx webserver found, enable Nextcloud specific configuration: "https://docs.nextcloud.com/server/12/admin_manual/installation/nginx.html#nextcloud-in-a-subdir-of-nginx"' local nextcloud_config='/etc/nginx/sites-dietpi/nextcloud.config' - # Do not overwrite existing config. if [ -f $nextcloud_config ]; then - nextcloud_config='/etc/nginx/sites-dietpi/nextcloud.config.new' + G_DIETPI-NOTIFY 2 'Existing Nextcloud configuration found, will save the new one for review and comparison to: /etc/nginx/sites-dietpi/nextcloud.config.dietpi-new' + nextcloud_config='/etc/nginx/sites-dietpi/nextcloud.config.dietpi-new' fi cp /DietPi/dietpi/conf/nginx.sites-dietpi.nextcloud.config $nextcloud_config # Stretch: Use PHP7.0 socket and set 'fastcgi_request_buffering off'; - if (( $DISTRO > 3 )); then + if (( $G_DISTRO > 3 )); then - sed -i "s#/run/php5-fpm.sock#/run/php/php7.0-fpm.sock#g" $nextcloud_config - sed -i "s/#fastcgi_request_buffering off;/fastcgi_request_buffering off;/g" $nextcloud_config + sed -i 's|/run/php5-fpm.sock|/run/php/php7.0-fpm.sock|g' $nextcloud_config + sed -i 's/#fastcgi_request_buffering off;/fastcgi_request_buffering off;/g' $nextcloud_config fi # Set HTTPS on, if SSL connection is available, even with self-signed/untrusted certificate. - DietPi/dietpi/func/check_connection https://localhost &> /dev/null + wget -q --spider --timeout=10 --tries=2 https://localhost &> /dev/null if (( $? == 0 || $? == 5)); then - sed -i "s/#fastcgi_param HTTPS on;/fastcgi_param HTTPS on;/g" $nextcloud_config + sed -i 's/#fastcgi_param HTTPS on;/fastcgi_param HTTPS on;/g' $nextcloud_config fi fi - # Enable MySQL 4-byte support: https://docs.nextcloud.com/server/12/admin_manual/configuration_database/mysql_4byte_support.html - cat << _EOF_ > /etc/mysql/conf.d/99-dietpi-4bit.cnf + if (( ${aSOFTWARE_INSTALL_STATE[84]} >= 1 )); then + + G_DIETPI-NOTIFY 2 'Lighttpd webserver found, enable Nextcloud specific configuration.' + local lighttpd_conf='/etc/lighttpd/lighttpd.conf' + + # Enable mod_setenv + grep -q '^[[:blank:]]*"mod_setenv",' $lighttpd_conf || + grep -q '^[[:blank:]#;]*"mod_setenv",' $lighttpd_conf && + sed -i '/^[[:blank:]#;]*"mod_setenv",/c\ "mod_setenv",' $lighttpd_conf || + sed -i '/^[[:blank:]]*server.modules = (/a\ "mod_setenv",' $lighttpd_conf + + # Move Nextcloud configuration file in place and activate it + [ ! -f /etc/lighttpd/conf-available/99-dietpi-nextcloud.conf ] && cp /DietPi/dietpi/conf/lighttpd.nextcloud.conf /etc/lighttpd/conf-available/99-dietpi-nextcloud.conf + lighttpd-enable-mod dietpi-nextcloud + service lighttpd force-reload + + fi + + # Enable 4-byte support for MariaDB: https://docs.nextcloud.com/server/12/admin_manual/configuration_database/mysql_4byte_support.html + cat << _EOF_ > /etc/mysql/mariadb.conf.d/99-dietpi-4byte.cnf [mysqld] innodb_large_prefix=1 innodb_file_format=barracuda innodb_file_per_table=1 _EOF_ - # Check if we really do fresh installation: - local nc_is_fresh=1 - if [ -d '/mnt/dietpi_userdata/mysql/nextcloud' ]; then - - nc_is_fresh=0 - - fi + G_RUN_CMD systemctl restart mysql - # Add occ command shortcut, use 'ncc' as 'occ' is reserved for ownCloud: - echo -e '#!/bin/bash\nsudo -u www-data php /var/www/nextcloud/occ $*' > /usr/local/bin/ncc - chmod +x /usr/local/bin/ncc + # Reload dietpi-globals to enable ncc command shortcut: + . /DietPi/dietpi/func/dietpi-globals # Adjusting config file: local config_php='/var/www/nextcloud/config/config.php' - # Terminal installation: - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/nextcloud_data + local datadir="$(grep -m1 '^[[:blank:]]*SOFTWARE_NEXTCLOUD_DATADIR=' /DietPi/dietpi.txt | sed 's/^.*=//')" + [ -n "$datadir" ] || datadir="$G_FP_DIETPI_USERDATA/nextcloud_data" + mkdir -p "$datadir" Install_Apply_Permissions &> /dev/null - local username=$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_nextcloud_username=' | sed 's/.*=//') - if [ ! -n "$username" ]; then - username='admin' + if [ -d "$G_FP_DIETPI_USERDATA"/mysql/nextcloud ]; then - fi - systemctl start mysql - # For MariaDB, temporary database admin user needs to be created, as 'root' uses unix_socket login, which cannot be accessed by sudo -u www-data. - mysql -uroot -p"$GLOBAL_PW" -e "grant all privileges on *.* to 'tmp_root'@'localhost' identified by '$GLOBAL_PW' with grant option" - grep -q "'installed' => true," $config_php 2>/dev/null || ncc maintenance:install --no-interaction --database "mysql" --database-name "nextcloud" --database-user "tmp_root" --database-pass "$GLOBAL_PW" --admin-user "$username" --admin-pass "$GLOBAL_PW" --data-dir "$FP_DIETPI_USERDATA_DIRECTORY/nextcloud_data" - mysql -uroot -p"$GLOBAL_PW" -e "drop user 'tmp_root'@'localhost'" + G_DIETPI-NOTIFY 2 'Nextcloud database found, will NOT overwrite.' + + else - # Enable MySQL 4-byte support for new installations only, to prevent risky database conversion tasks: - if (( $nc_is_fresh == 1 )); then + if [ -f "$datadir"/dietpi-nextcloud-database-backup.sql ]; then - grep -q "'mysql.utf8mb4' => " $config_php || sed -i "/'dbpassword'/a \ \ 'mysql.utf8mb4' => true," $config_php + G_DIETPI-NOTIFY 2 'Nextcloud database backup found, starting recovery...' + local dbuser=$(grep -m1 "^[[:blank:]]*'dbuser'" $config_php | awk '{print $3}' | sed "s/[',]//g") + local dbpass=$(grep -m1 "^[[:blank:]]*'dbpassword'" $config_php | awk '{print $3}' | sed "s/[',]//g") + /DietPi/dietpi/func/create_mysql_db nextcloud "$dbuser" "$dbpass" + mysql -uroot nextcloud < "$datadir"/dietpi-nextcloud-database-backup.sql + + else + + local username="$(grep -m1 '^[[:blank:]]*SOFTWARE_OWNCLOUD_NEXTCLOUD_USERNAME=' /DietPi/dietpi.txt | sed 's/^.*=//')" + [ -n "$username" ] || username='admin' + + # For MariaDB, temporary database admin user needs to be created, as 'root' uses unix_socket login, which cannot be accessed by sudo -u www-data. + mysql -e "grant all privileges on *.* to 'tmp_root'@'localhost' identified by '$GLOBAL_PW' with grant option" + grep -q "'installed' => true," $config_php 2>/dev/null || ncc maintenance:install --no-interaction --database "mysql" --database-name "nextcloud" --database-user "tmp_root" --database-pass "$GLOBAL_PW" --admin-user "$username" --admin-pass "$GLOBAL_PW" --data-dir "$datadir" + mysql -e "drop user 'tmp_root'@'localhost'" + + fi fi + # Enable Nextcloud to use 4-byte database + grep -q "^[[:blank:]]*'mysql.utf8mb4'" $config_php || sed -i "/^[[:blank:]]*'dbpassword'/a \ \ 'mysql.utf8mb4' => true," $config_php + # Disable trusted_domains. if (( ! $(cat $config_php | grep -ci -m1 "1 => '*'") )); then @@ -9414,20 +8570,26 @@ _EOF_ fi # Set CLI URL to Nextcloud sub directory: - sed -i "s#'http://localhost'#'http://localhost/nextcloud'#g" $config_php + sed -i "s|'http://localhost'|'http://localhost/nextcloud'|g" $config_php - # APCu Memcache - if (( ! $(cat $config_php | grep -ci -m1 "'memcache.local'") )); then + # Set pretty URLs (without /index.php/) on Apache: + if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then - sed -i "/'version'/a 'memcache.local' => '\\\OC\\\Memcache\\\APCu'," $config_php + grep -q "^[[:blank:]]*'htaccess.RewriteBase'" $config_php || sed -i "/^[[:blank:]]*'overwrite.cli.url'/a \ \ 'htaccess.RewriteBase' => '/nextcloud'," $config_php + ncc maintenance:update:htaccess fi + # APCu Memcache + grep -q "^[[:blank:]]*'memcache.local'" $config_php || sed -i "/^[[:blank:]]*'version'/a \ \ 'memcache.local' => '\\\OC\\\Memcache\\\APCu'," $config_php + # Redis for transactional file locking: # https://docs.nextcloud.com/server/12/admin_manual/configuration_files/files_locking_transactional.html # - Enable Redis socket and grant www-data access to it: - sed -i "\#unixsocket /#c\unixsocket /var/run/redis/redis.sock" /etc/redis/redis*.conf - sed -i "\#unixsocketperm#c\unixsocketperm 770" /etc/redis/redis*.conf + local redis_conf="/etc/redis/redis*.conf" + grep -q "^[[:blank:]]*unixsocket /" $redis_conf || grep -q '^[[:blank:]]*#unixsocket /' $redis_conf && sed -i 's|^[[:blank:]]*#unixsocket /|unixsocket /|' $redis_conf || echo 'unixsocket /var/run/redis/redis.sock' >> $redis_conf + grep -q "^[[:blank:]]*#?unixsocketperm " $redis_conf && sed -i "/^[[:blank:]]*#?unixsocketperm /c\unixsocketperm 770" $redis_conf || echo 'unixsocketperm 770' >> $redis_conf + local redis_sock=$(grep "^[[:blank:]]*unixsocket /" $redis_conf | sed "s/^[[:blank:]]*unixsocket //") usermod -a -G redis www-data # - Enable Nextloud to use Redis socket: if (( ! $(cat $config_php | grep -ci -m1 "'memcache.locking'") )); then @@ -9435,28 +8597,18 @@ _EOF_ sed -i "\#'memcache.local'#a \ \ 'filelocking.enabled' => true,\n\ 'memcache.locking' => '\\\OC\\\Memcache\\\Redis',\n\ 'redis' => array(\n\ - 'host' => '/var/run/redis/redis.sock',\n\ + 'host' => '$redis_sock',\n\ 'port' => 0,\n\ )," $config_php fi - # ownCloud/Nextcloud ignores system wide php.ini settings. Use their own config. - # Set max upload size - local php_max_upload_size="$(( $(php -r 'print(PHP_INT_MAX);') / 1024 / 1024))M" - sed -i "/upload_max_filesize=/c\upload_max_filesize=$php_max_upload_size" /var/www/nextcloud/.user.ini - sed -i "/post_max_size=/c\post_max_size=$php_max_upload_size" /var/www/nextcloud/.user.ini - - # Set memory limit: total / 4 - local memory_limit_max="$(( $RAM_TOTAL / 4 ))M" - sed -i "/memory_limit=/c\memory_limit=$memory_limit_max" /var/www/nextcloud/.user.ini - # Enable Nextcloud background cron job: crontab -u www-data -l 2>/dev/null | grep -q '/var/www/nextcloud/cron.php' || ( crontab -u www-data -l 2>/dev/null ; echo "*/15 * * * * php /var/www/nextcloud/cron.php" ) | crontab -u www-data - ncc background:cron # Enable maintenance mode to allow handling by dietpi-services: - grep -q "'maintenance' => true," $config_php &>/dev/null || ncc maintenance:mode --on + grep -q "^[[:blank:]]*'maintenance' => true," $config_php || ncc maintenance:mode --on fi @@ -9464,6 +8616,8 @@ _EOF_ INSTALLING_INDEX=44 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Jessie, Transmission uses my systemd service: https://github.com/Fourdee/DietPi/issues/350#issuecomment-220828884 rm /etc/init.d/transmission-daemon rm /etc/systemd/system/transmission-daemon.service @@ -9498,7 +8652,7 @@ _EOF_ "blocklist-url": "http://www.example.com/blocklist", "cache-size-mb": 48, "dht-enabled": true, - "download-dir": "$FP_DIETPI_USERDATA_DIRECTORY/downloads", + "download-dir": "$G_FP_DIETPI_USERDATA/downloads", "download-limit": 100, "download-limit-enabled": false, "download-queue-enabled": true, @@ -9506,7 +8660,7 @@ _EOF_ "encryption": 2, "idle-seeding-limit": 1, "idle-seeding-limit-enabled": true, - "incomplete-dir": "$FP_DIETPI_USERDATA_DIRECTORY/bt-inprogress", + "incomplete-dir": "$G_FP_DIETPI_USERDATA/bt-inprogress", "incomplete-dir-enabled": false, "lpd-enabled": false, "max-peers-global": 8, @@ -9570,7 +8724,9 @@ _EOF_ INSTALLING_INDEX=54 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - /DietPi/dietpi/func/create_mysql_db phpbb3 "$GLOBAL_PW" root "$GLOBAL_PW" + Banner_Configuration + + /DietPi/dietpi/func/create_mysql_db phpbb3 phpbb3 "$GLOBAL_PW" fi @@ -9578,6 +8734,8 @@ _EOF_ INSTALLING_INDEX=128 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Create MPD env (based on moOde) #useradd mpd useradd -r -M mpd -G audio -s /usr/bin/nologin @@ -9598,7 +8756,7 @@ _EOF_ chown -R mpd:audio /var/log/mpd # cache - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/.mpd_cache + mkdir -p "$G_FP_DIETPI_USERDATA"/.mpd_cache #MPD service/confs cat << _EOF_ > /etc/default/mpd @@ -9631,7 +8789,7 @@ _EOF_ chmod 0666 /etc/mpd.conf #JustBoom specials - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^soundcard=justboom') )); then + if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^CONFIG_SOUNDCARD=justboom') )); then # - Name displayed in YMPD sound button local justboom_soundcard_desc='JustBoom DietPi' @@ -9659,9 +8817,11 @@ _EOF_ INSTALLING_INDEX=94 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + sed -i "/root/c\#root" /etc/ftpusers cp /DietPi/dietpi/conf/proftpd.conf /etc/proftpd/proftpd.conf - sed -i "/DefaultRoot /c\DefaultRoot $FP_DIETPI_USERDATA_DIRECTORY" /etc/proftpd/proftpd.conf + sed -i "/DefaultRoot /c\DefaultRoot $G_FP_DIETPI_USERDATA" /etc/proftpd/proftpd.conf fi @@ -9669,10 +8829,12 @@ _EOF_ INSTALLING_INDEX=96 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + echo -e "dietpi\ndietpi" | smbpasswd -s -a root cp /DietPi/dietpi/conf/smb.conf /etc/samba/smb.conf - sed -i "/path = /c\path = $FP_DIETPI_USERDATA_DIRECTORY" /etc/samba/smb.conf + sed -i "/path = /c\path = $G_FP_DIETPI_USERDATA" /etc/samba/smb.conf fi @@ -9680,10 +8842,12 @@ _EOF_ INSTALLING_INDEX=95 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + sed -i '/root/c\#root' /etc/ftpusers cp /DietPi/dietpi/conf/vsftpd.conf /etc/vsftpd.conf - sed -i "/^local_root=/c\local_root=$FP_DIETPI_USERDATA_DIRECTORY" /etc/vsftpd.conf + sed -i "/^local_root=/c\local_root=$G_FP_DIETPI_USERDATA" /etc/vsftpd.conf fi @@ -9691,8 +8855,10 @@ _EOF_ INSTALLING_INDEX=109 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/exports -$FP_DIETPI_USERDATA_DIRECTORY *(rw,async,no_root_squash,fsid=0,crossmnt,no_subtree_check) +$G_FP_DIETPI_USERDATA *(rw,async,no_root_squash,fsid=0,crossmnt,no_subtree_check) _EOF_ fi @@ -9701,6 +8867,8 @@ _EOF_ INSTALLING_INDEX=32 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #YMPD service cat << _EOF_ > /etc/systemd/system/ympd.service [Unit] @@ -9722,20 +8890,22 @@ _EOF_ INSTALLING_INDEX=121 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/roon + Banner_Configuration + + mkdir -p "$G_FP_DIETPI_USERDATA"/roon cp /DietPi/dietpi/conf/roonbridge.service /etc/systemd/system/roonbridge.service # - Move logfiles to /var/log/ (dietpi-ramlog) # Remove any previous folders to clear for symlink - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/roon/RoonBridge/Logs &> /dev/null - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/roon/RAATServer/Logs &> /dev/null + rm -R "$G_FP_DIETPI_USERDATA"/roon/RoonBridge/Logs &> /dev/null + rm -R "$G_FP_DIETPI_USERDATA"/roon/RAATServer/Logs &> /dev/null - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/roon/RoonBridge - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/roon/RAATServer + mkdir -p "$G_FP_DIETPI_USERDATA"/roon/RoonBridge + mkdir -p "$G_FP_DIETPI_USERDATA"/roon/RAATServer - ln -sf /var/log "$FP_DIETPI_USERDATA_DIRECTORY"/roon/RoonBridge/Logs - ln -sf /var/log "$FP_DIETPI_USERDATA_DIRECTORY"/roon/RAATServer/Logs + ln -sf /var/log "$G_FP_DIETPI_USERDATA"/roon/RoonBridge/Logs + ln -sf /var/log "$G_FP_DIETPI_USERDATA"/roon/RAATServer/Logs fi @@ -9743,7 +8913,11 @@ _EOF_ INSTALLING_INDEX=122 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/node-red + Banner_Configuration + + mkdir -p "$G_FP_DIETPI_USERDATA"/node-red + + adduser nodered --system --group --no-create-home --shell=/bin/nologin cat << _EOF_ > /etc/systemd/system/node-red.service [Unit] @@ -9751,15 +8925,15 @@ Description=Node-Red [Service] Type=simple -User=root -ExecStart=/usr/local/bin/node-red -u $FP_DIETPI_USERDATA_DIRECTORY/node-red +User=nodered +ExecStart=/usr/local/bin/node-red -u $G_FP_DIETPI_USERDATA/node-red [Install] WantedBy=multi-user.target _EOF_ #Symlink to home dir: https://github.com/Fourdee/DietPi/issues/1256 - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/node-red "$HOME"/.node-red + ln -sf "$G_FP_DIETPI_USERDATA"/node-red "$HOME"/.node-red fi @@ -9767,29 +8941,9 @@ _EOF_ INSTALLING_INDEX=125 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - # - Possible locations for Java - # sed -i "/JAVA_HOME=/c\JAVA_HOME=$(which java)" /etc/default/tomcat8 # This doesnt work... | c2=/usr/bin/java/bin/java (Not a directory) | RPi = /usr/bin/java/bin/java (Not a directory) - local afp_java=( - - '/usr/lib/jvm/java-7-oracle' - '/usr/lib/jvm/java-8-oracle' - '/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt' #Rasbian - - ) - - for ((i=0; i<${#afp_java[@]}; i++)) - do - - if [ -d "${afp_java[$i]}" ]; then - - sed -i "/JAVA_HOME=/c\JAVA_HOME=${afp_java[$i]}" /etc/default/tomcat8 - break - - fi - - done + Banner_Configuration - unset afp_java + sed -i "/JAVA_HOME=/c\JAVA_HOME=$(find \/usr\/lib\/jvm\/ -name java-8-openjdk*)" /etc/default/tomcat8 fi @@ -9797,6 +8951,8 @@ _EOF_ INSTALLING_INDEX=119 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - Cava conf mkdir -p "$HOME"/.config/cava cp /DietPi/dietpi/conf/cava.conf "$HOME"/.config/cava/config @@ -9829,18 +8985,20 @@ _EOF_ INSTALLING_INDEX=118 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + sed -i "/User=/c\User=root" /lib/systemd/system/mopidy.service # - conf - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/mopidy/cache - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/mopidy/data + mkdir -p "$G_FP_DIETPI_USERDATA"/mopidy/cache + mkdir -p "$G_FP_DIETPI_USERDATA"/mopidy/data mkdir -p ~/.config/mopidy cat << _EOF_ > ~/.config/mopidy/mopidy.conf [core] -cache_dir = $FP_DIETPI_USERDATA_DIRECTORY/mopidy/cache +cache_dir = $G_FP_DIETPI_USERDATA/mopidy/cache config_dir = /etc/mopidy -data_dir = $FP_DIETPI_USERDATA_DIRECTORY/mopidy/data +data_dir = $G_FP_DIETPI_USERDATA/mopidy/data [logging] config_file = /etc/mopidy/logging.conf @@ -9890,6 +9048,8 @@ _EOF_ INSTALLING_INDEX=31 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Remove Kodi user (Whilst waving) userdel -r kodi &> /dev/null @@ -9906,19 +9066,14 @@ _EOF_ wget http://dietpi.com/downloads/conf/desktop/kodi.desktop -O /usr/share/applications/kodi.desktop ln -sf /usr/share/applications/kodi.desktop "$HOME"/Desktop/kodi.desktop - #startkodi alias. - if (( $(cat /etc/bash.bashrc | grep -ci -m1 'startkodi') == 0 )); then - - echo -e "alias startkodi='/DietPi/dietpi/misc/start_kodi'" >> /etc/bash.bashrc - - fi - fi #MINIDLNA INSTALLING_INDEX=39 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Run as root sed -i '/USER=m/c\USER=root' /etc/init.d/minidlna # + SystemD @@ -9929,7 +9084,7 @@ _EOF_ cp /DietPi/dietpi/conf/minidlna.conf /etc/minidlna.conf #Setup data directories - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/.MiniDLNA_Cache + mkdir -p "$G_FP_DIETPI_USERDATA"/.MiniDLNA_Cache fi @@ -9938,6 +9093,8 @@ _EOF_ INSTALLING_INDEX=67 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #noip2 service file cat << _EOF_ > /etc/systemd/system/noip2.service [Unit] @@ -9961,69 +9118,71 @@ _EOF_ INSTALLING_INDEX=108 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Allow binary execution chmod -R +x /etc/amiberry #Create userdata/rom directories and symlink from /etc/amiberry/ - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry + mkdir -p "$G_FP_DIETPI_USERDATA"/amiberry #Copy default configs, then setup symlinks from Uae4ARM folders to userdata. # - Conf - cp -R /etc/amiberry/conf "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/ + cp -R /etc/amiberry/conf "$G_FP_DIETPI_USERDATA"/amiberry/ rm -R /etc/amiberry/conf &> /dev/null - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/conf /etc/amiberry/conf + ln -sf "$G_FP_DIETPI_USERDATA"/amiberry/conf /etc/amiberry/conf # - Disks rm -R /etc/amiberry/disks &> /dev/null - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/disks - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/disks /etc/amiberry/disks + mkdir -p "$G_FP_DIETPI_USERDATA"/amiberry/disks + ln -sf "$G_FP_DIETPI_USERDATA"/amiberry/disks /etc/amiberry/disks # - floppy_images rm -R /etc/amiberry/floppy_images &> /dev/null - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/floppy_images - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/floppy_images /etc/amiberry/floppy_images - cat << _EOF_ > "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/floppy_images/dir.txt + mkdir -p "$G_FP_DIETPI_USERDATA"/amiberry/floppy_images + ln -sf "$G_FP_DIETPI_USERDATA"/amiberry/floppy_images /etc/amiberry/floppy_images + cat << _EOF_ > "$G_FP_DIETPI_USERDATA"/amiberry/floppy_images/dir.txt Put your Amiga floopy images (*.adf) in this directory. _EOF_ # - HDF rm -R /etc/amiberry/hdf &> /dev/null - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/hdf - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/hdf /etc/amiberry/hdf + mkdir -p "$G_FP_DIETPI_USERDATA"/amiberry/hdf + ln -sf "$G_FP_DIETPI_USERDATA"/amiberry/hdf /etc/amiberry/hdf # - Kickstarts rm -R /etc/amiberry/kickstarts &> /dev/null - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/kickstarts - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/kickstarts /etc/amiberry/kickstarts - cat << _EOF_ > "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/kickstarts/dir.txt + mkdir -p "$G_FP_DIETPI_USERDATA"/amiberry/kickstarts + ln -sf "$G_FP_DIETPI_USERDATA"/amiberry/kickstarts /etc/amiberry/kickstarts + cat << _EOF_ > "$G_FP_DIETPI_USERDATA"/amiberry/kickstarts/dir.txt Put your Kickstart Roms (*.rom) in this directory. They should be named accordingly depending on version: kick12.rom , kick13.rom , kick20.rom, kick31.rom _EOF_ # - Savestates rm -R /etc/amiberry/savestates &> /dev/null - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/savestates - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/savestates /etc/amiberry/savestates - cat << _EOF_ > "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/savestates/dir.txt + mkdir -p "$G_FP_DIETPI_USERDATA"/amiberry/savestates + ln -sf "$G_FP_DIETPI_USERDATA"/amiberry/savestates /etc/amiberry/savestates + cat << _EOF_ > "$G_FP_DIETPI_USERDATA"/amiberry/savestates/dir.txt Saved states will be stored here. _EOF_ # - Screenshots rm -R /etc/amiberry/screenshots &> /dev/null - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/screenshots - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/screenshots /etc/amiberry/screenshots - cat << _EOF_ > "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/screenshots/dir.txt + mkdir -p "$G_FP_DIETPI_USERDATA"/amiberry/screenshots + ln -sf "$G_FP_DIETPI_USERDATA"/amiberry/screenshots /etc/amiberry/screenshots + cat << _EOF_ > "$G_FP_DIETPI_USERDATA"/amiberry/screenshots/dir.txt Screenshots will be stored here. _EOF_ #Uae4arm does not support browsing symlinks (https://github.com/Fourdee/DietPi/issues/474#issuecomment-242973839) # So we need to change config file default paths to actual userdata location: - local fp_userdata_actual=$(readlink "$FP_DIETPI_USERDATA_DIRECTORY") # Only returns a value if symlink exists (eg: off SDcard) + local fp_userdata_actual=$(readlink "$G_FP_DIETPI_USERDATA") # Only returns a value if symlink exists (eg: off SDcard) if [ -n "$fp_userdata_actual" ]; then - sed -i "s:$FP_DIETPI_USERDATA_DIRECTORY:$fp_userdata_actual:g" "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/conf/adfdir.conf - sed -i "s:$FP_DIETPI_USERDATA_DIRECTORY:$fp_userdata_actual:g" "$FP_DIETPI_USERDATA_DIRECTORY"/amiberry/conf/autostart.uae + sed -i "s:$G_FP_DIETPI_USERDATA:$fp_userdata_actual:g" "$G_FP_DIETPI_USERDATA"/amiberry/conf/adfdir.conf + sed -i "s:$G_FP_DIETPI_USERDATA:$fp_userdata_actual:g" "$G_FP_DIETPI_USERDATA"/amiberry/conf/autostart.uae fi @@ -10031,12 +9190,12 @@ _EOF_ local amiberry_filename='amiberry-rpi' # - RPi 3 - if (( $HW_MODEL == 3 )); then + if (( $G_HW_MODEL == 3 )); then amiberry_filename+='3' # - RPi 2 - elif (( $HW_MODEL == 2 )); then + elif (( $G_HW_MODEL == 2 )); then amiberry_filename+='2' @@ -10117,30 +9276,25 @@ _EOF_ INSTALLING_INDEX=112 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Symlink savegames to root # - Remove existing syslinks rm -R "$HOME"/.d1x-rebirth &> /dev/null rm -R "$HOME"/.d2x-rebirth &> /dev/null - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/dxx-rebirth/descent_1_profiles "$HOME"/.d1x-rebirth - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/dxx-rebirth/descent_2_profiles "$HOME"/.d2x-rebirth + ln -sf "$G_FP_DIETPI_USERDATA"/dxx-rebirth/descent_1_profiles "$HOME"/.d1x-rebirth + ln -sf "$G_FP_DIETPI_USERDATA"/dxx-rebirth/descent_2_profiles "$HOME"/.d2x-rebirth #+exe - chmod +x -R "$FP_DIETPI_USERDATA_DIRECTORY"/dxx-rebirth/* - - #Alias - if (( ! $(cat /etc/bash.bashrc | grep -ci -m1 'dxx-rebirth') )); then - - sed -i "/#DietPi Additions/a alias dxx-rebirth='$FP_DIETPI_USERDATA_DIRECTORY/dxx-rebirth/run.sh'" /etc/bash.bashrc - - fi + chmod +x -R "$G_FP_DIETPI_USERDATA"/dxx-rebirth/* #Create .Desktop SymLinks mkdir -p "$HOME"/Desktop mkdir -p /usr/share/applications - ln -s "$FP_DIETPI_USERDATA_DIRECTORY"/dxx-rebirth/dxx-rebirth.desktop "$HOME"/Desktop/dxx-rebirth.desktop - ln -s "$FP_DIETPI_USERDATA_DIRECTORY"/dxx-rebirth/dxx-rebirth.desktop /usr/share/applications/dxx-rebirth.desktop + ln -s "$G_FP_DIETPI_USERDATA"/dxx-rebirth/dxx-rebirth.desktop "$HOME"/Desktop/dxx-rebirth.desktop + ln -s "$G_FP_DIETPI_USERDATA"/dxx-rebirth/dxx-rebirth.desktop /usr/share/applications/dxx-rebirth.desktop fi @@ -10148,6 +9302,8 @@ _EOF_ INSTALLING_INDEX=51 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Copy the DietPi run file for OpenTyrian cp /DietPi/dietpi/conf/opentyrian_run /usr/local/games/opentyrian/run chmod +x /usr/local/games/opentyrian/run @@ -10164,6 +9320,8 @@ _EOF_ INSTALLING_INDEX=59 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - raspimjpeg conf chmod +x /etc/raspimjpeg ln -s /etc/raspimjpeg /var/www/dietpicam/raspimjpeg @@ -10174,10 +9332,10 @@ _EOF_ usermod -a -G video www-data # - raspimjpeg/php schedule startup and control script - cp /DietPi/dietpi/conf/raspimjpeg.service /etc/dietpi/dietpi-software/services/raspimjpeg.service + cp /DietPi/dietpi/conf/raspimjpeg.service /var/lib/dietpi/dietpi-software/services/raspimjpeg.service # - Setup Data directory - local dietpicam_media_directory=$FP_DIETPI_USERDATA_DIRECTORY + local dietpicam_media_directory=$G_FP_DIETPI_USERDATA mkdir -p "$dietpicam_media_directory"/dietpicam rm -R /var/www/dietpicam/media @@ -10192,8 +9350,10 @@ _EOF_ INSTALLING_INDEX=45 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #copy init - cp /DietPi/dietpi/conf/deluge.service /etc/dietpi/dietpi-software/services/deluge.service + cp /DietPi/dietpi/conf/deluge.service /var/lib/dietpi/dietpi-software/services/deluge.service #Generate deluge default config deluged @@ -10224,6 +9384,8 @@ _EOF_ INSTALLING_INDEX=106 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Setup login file mkdir -p /etc/raspcontrol @@ -10243,6 +9405,8 @@ _EOF_ INSTALLING_INDEX=93 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - Create a symlink so users can use http://ip/pihole ln -sf /var/www/html/admin /var/www/pihole @@ -10272,10 +9436,12 @@ _EOF_ fi #SUBSONIC 5/6 - #INSTALLING_INDEX=33/34 + INSTALLING_INDEX=34 if (( ${aSOFTWARE_INSTALL_STATE[33]} == 1 || ${aSOFTWARE_INSTALL_STATE[34]} == 1 )); then + Banner_Configuration + #Optimize memory limit local subsonic_memory_max=$(( $RAM_TOTAL / 5 )) #Minimum cap 150mb @@ -10287,7 +9453,7 @@ _EOF_ cat << _EOF_ > /etc/default/subsonic SUBSONIC_USER=root -SUBSONIC_ARGS="--quiet --pidfile=/run/subsonic.pid --max-memory=$subsonic_memory_max --default-music-folder=$FP_DIETPI_USERDATA_DIRECTORY/$FOLDER_MUSIC --default-podcast-folder=$FP_DIETPI_USERDATA_DIRECTORY/$FOLDER_MUSIC --default-playlist-folder=$FP_DIETPI_USERDATA_DIRECTORY/$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_ #Grab our test media for user @@ -10295,7 +9461,7 @@ _EOF_ #Symlink ffmpeg to subsonic transcoder #rpi armv6 jessie (using compiled ffmpeg) - if (( $HW_MODEL < 2 )); then + if (( $G_HW_MODEL < 2 )); then ln -fs /usr/local/bin/ffmpeg /var/subsonic/transcode @@ -10312,6 +9478,8 @@ _EOF_ INSTALLING_INDEX=71 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #auto start update-rc.d webiopi defaults @@ -10322,16 +9490,11 @@ _EOF_ INSTALLING_INDEX=62 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Enable DietPi-Cloudshell autostart /DietPi/dietpi/dietpi-autostart 5 - #add alias - if (( $(cat /etc/bash.bashrc | grep -ci -m1 'dietpi-cloudshell=' ) == 0 )); then - - sed -i "/#DietPi Additions/a alias dietpi-cloudshell='/DietPi/dietpi/dietpi-cloudshell'" /etc/bash.bashrc - - fi - #Service cat << _EOF_ > /etc/systemd/system/dietpi-cloudshell.service [Unit] @@ -10347,7 +9510,7 @@ ExecStartPre=/usr/bin/setterm --term linux --blank 0 --powersave off --cursor of ExecStart=/bin/bash -c '/DietPi/dietpi/dietpi-cloudshell 1' ExecStop=/usr/bin/setterm --reset -ExecStop=/bin/bash -c '/DietPi/dietpi/func/dietpi-notify 0 DietPi-Cloudshell terminated, have a nice day!' +ExecStop=/bin/bash -c 'G_DIETPI-NOTIFY 0 DietPi-Cloudshell terminated, have a nice day!' [Install] WantedBy=multi-user.target @@ -10360,6 +9523,8 @@ _EOF_ INSTALLING_INDEX=98 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Create jail directory mkdir -p /var/lib/haproxy @@ -10449,12 +9614,14 @@ _EOF_ INSTALLING_INDEX=35 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Remove service update-rc.d logitechmediaserver remove rm /etc/init.d/logitechmediaserver #DietPi-Services init - cp /DietPi/dietpi/conf/squeezeboxserver.service /etc/dietpi/dietpi-software/services/squeezeboxserver.service + cp /DietPi/dietpi/conf/squeezeboxserver.service /var/lib/dietpi/dietpi-software/services/squeezeboxserver.service #Grab our test media for user Download_Test_Media @@ -10465,8 +9632,10 @@ _EOF_ INSTALLING_INDEX=55 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Create mysql DB - /DietPi/dietpi/func/create_mysql_db wordpress "$GLOBAL_PW" root "$GLOBAL_PW" + /DietPi/dietpi/func/create_mysql_db wordpress wordpress "$GLOBAL_PW" fi @@ -10476,8 +9645,10 @@ _EOF_ ${aSOFTWARE_INSTALL_STATE[28]} == 1 || ${aSOFTWARE_INSTALL_STATE[120]} == 1 )); then + #Banner_Configuration + #User, enter PW - if (( $USER_INPUTS )); then + if (( $G_USER_INPUTS )); then local entering_pw=1 local loop_count=0 @@ -10543,11 +9714,11 @@ VNC_INSTALLED=0 BINARY_FP=0 SHARED_MODE=0 -WIDTH=\$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_vncserver_width=' | sed 's/.*=//') -HEIGHT=\$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_vncserver_height=' | sed 's/.*=//') -DEPTH=\$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_vncserver_depth=' | sed 's/.*=//') -DISPLAY=\$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_vncserver_display=' | sed 's/.*=//') -SHARED_MODE=\$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_vncserver_shared_desktop=' | sed 's/.*=//') +WIDTH=\$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_VNCSERVER_WIDTH=' | sed 's/.*=//') +HEIGHT=\$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_VNCSERVER_HEIGHT=' | sed 's/.*=//') +DEPTH=\$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_VNCSERVER_DEPTH=' | sed 's/.*=//') +DISPLAY=\$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_VNCSERVER_DISPLAY_INDEX=' | sed 's/.*=//') +SHARED_MODE=\$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_VNCSERVER_SHARE_DESKTOP=' | sed 's/.*=//') #RealVNC | Slightly different launch method to VNC4server REALVNC=0 @@ -10629,7 +9800,7 @@ _EOF_ fi # - Stretch + TigerVNC: Disable Localhost only by default - if (( $DISTRO >= 4 )); then + if (( $G_DISTRO >= 4 )); then echo -e '$localhost = "no";' >> /etc/vnc.conf @@ -10642,6 +9813,8 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} >= 1 || ${aSOFTWARE_INSTALL_STATE[120]} >= 1 )); then + Banner_Configuration + local cmd_launch_desktop='' #DESKTOP_LXDE if (( ${aSOFTWARE_INSTALL_STATE[23]} >= 1 )); then @@ -10683,6 +9856,8 @@ _EOF_ INSTALLING_INDEX=73 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/fail2ban/fail2ban.conf [Definition] # loglevel #1=error #2=warn #3=info @@ -10700,6 +9875,8 @@ _EOF_ INSTALLING_INDEX=64 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #conf cp /DietPi/dietpi/conf/phpsysinfo.ini /var/www/phpsysinfo/phpsysinfo.ini @@ -10709,6 +9886,8 @@ _EOF_ INSTALLING_INDEX=56 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Get test images mkdir -p /var/www/gallery/DietPi wget http://dietpi.com/images/dietpi-logo_256.png -O /var/www/gallery/DietPi/logo_256.png @@ -10730,19 +9909,21 @@ _EOF_ INSTALLING_INDEX=40 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + Download_Test_Media #create/insert our pre-made ampache sql db - wget http://dietpi.com/downloads/mysql_databases/ampache_mysql_3.8.2-v113.zip -O sql.zip + G_RUN_CMD wget http://dietpi.com/downloads/mysql_databases/ampache_mysql_3.8.2-v6.0.zip -O sql.zip unzip -o sql.zip rm sql.zip - /DietPi/dietpi/func/create_mysql_db ampache "$GLOBAL_PW" root "$GLOBAL_PW" - mysql -u root -p"$GLOBAL_PW" ampache < ampache.sql + /DietPi/dietpi/func/create_mysql_db ampache ampache "$GLOBAL_PW" + mysql ampache < ampache.sql rm ampache.sql #Grab config - wget http://dietpi.com/downloads/conf/ampache.cfg.php_3.8.2-v113 -O /var/www/ampache/config/ampache.cfg.php + G_RUN_CMD wget http://dietpi.com/downloads/conf/ampache.cfg.php_3.8.2-v6.0 -O /var/www/ampache/config/ampache.cfg.php fi @@ -10750,6 +9931,8 @@ _EOF_ INSTALLING_INDEX=97 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + local key_size=1024 #Start Cert/Key generation. @@ -10767,7 +9950,7 @@ export KEY_NAME="DietPi_OpenVPN_Server" _EOF_ #Create Server Cert Auth - /DietPi/dietpi/func/dietpi-notify 2 "Generating unique OpenVPN certificates and keys. Please wait...\n" + G_DIETPI-NOTIFY 2 "Generating unique OpenVPN certificates and keys. Please wait...\n" openssl dhparam -out /etc/openvpn/dh"$key_size".pem "$key_size" #Build Server certs/keys @@ -10857,7 +10040,7 @@ _EOF_ echo '' >> /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn #Copy client file to userdata location - cp /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn "$FP_DIETPI_USERDATA_DIRECTORY"/ + cp /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn "$G_FP_DIETPI_USERDATA"/ # - and /boot partition cp /etc/openvpn/easy-rsa/keys/DietPi_OpenVPN_Client.ovpn /boot/ @@ -10873,6 +10056,8 @@ _EOF_ INSTALLING_INDEX=60 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + local eth_index=$(sed -n 1p /DietPi/dietpi/.network) local wifi_index=$(sed -n 2p /DietPi/dietpi/.network) @@ -10924,14 +10109,14 @@ _EOF_ cat << _EOF_ > /etc/hostapd/hostapd.conf interface=wlan$wifi_index driver=nl80211 -ssid=$(cat /DietPi/dietpi.txt | grep -m1 '^wifi_hotspot_ssid=' | sed 's/.*=//') +ssid=$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_WIFI_HOTSPOT_SSID=' | sed 's/.*=//') hw_mode=g -channel=$(cat /DietPi/dietpi.txt | grep -m1 '^wifi_hotspot_channel=' | sed 's/.*=//') +channel=$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_WIFI_HOTSPOT_CHANNEL=' | sed 's/.*=//') macaddr_acl=0 auth_algs=1 ignore_broadcast_ssid=0 wpa=2 -wpa_passphrase=$(cat /DietPi/dietpi.txt | grep -m1 '^wifi_hotspot_key=' | sed 's/.*=//') +wpa_passphrase=$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_WIFI_HOTSPOT_KEY=' | sed 's/.*=//') wpa_key_mgmt=WPA-PSK wpa_pairwise=TKIP rsn_pairwise=CCMP @@ -10962,7 +10147,7 @@ _EOF_ iptables-save > /etc/iptables.ipv4.nat # - RPi 3 - onboard wifi, enable N - if (( $HW_MODEL == 3 && ! $WIFIHOTSPOT_RTL8188C_DEVICE )); then + if (( $G_HW_MODEL == 3 && ! $WIFIHOTSPOT_RTL8188C_DEVICE )); then # - Add Wireless N support echo -e "ieee80211n=1" >> /etc/hostapd/hostapd.conf @@ -10975,7 +10160,9 @@ _EOF_ INSTALLING_INDEX=61 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then -# - Tor config + Banner_Configuration + + # - Tor config cat << _EOF_ > /etc/tor/torrc Log notice file /var/log/tor/notices.log VirtualAddrNetwork 10.192.0.0/10 @@ -11014,6 +10201,8 @@ _EOF_ INSTALLING_INDEX=37 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Enable SOXR by default: cat << _EOF_ > /usr/local/etc/shairport-sync.conf general = @@ -11054,9 +10243,11 @@ _EOF_ INSTALLING_INDEX=38 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Copy configs and services cp /DietPi/dietpi/conf/brutefir_config /etc/BruteFIR/ - cp /DietPi/dietpi/conf/brutefir.service /etc/dietpi/dietpi-software/services/brutefir.service + cp /DietPi/dietpi/conf/brutefir.service /var/lib/dietpi/dietpi-software/services/brutefir.service #Modules echo -e "snd-aloop" > /etc/modules-load.d/brutefir-alsa-loopback.conf @@ -11095,6 +10286,8 @@ _EOF_ INSTALLING_INDEX=48 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Configure apache2 # - Disable php output_buffering = sed -i '/output_buffering = /c\output_buffering = Off/' "$FP_PHP_BASE_DIR"/apache2/php.ini @@ -11107,10 +10300,10 @@ _EOF_ a2enmod rewrite #Create Mysql DB - /DietPi/dietpi/func/create_mysql_db pydio "$GLOBAL_PW" root "$GLOBAL_PW" + /DietPi/dietpi/func/create_mysql_db pydio pydio "$GLOBAL_PW" #Setup Data directory - local target_data_dir="$FP_DIETPI_USERDATA_DIRECTORY/pydio_data" + local target_data_dir="$G_FP_DIETPI_USERDATA/pydio_data" # - Generate user data dir mkdir -p "$target_data_dir" @@ -11127,6 +10320,8 @@ _EOF_ INSTALLING_INDEX=36 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - Replace Sysinit service with SystemD echo -e "#This file is no longer used as service has been upgraded to SystemD.\n#Please see /etc/systemd/system/squeezelite.service to set start options" > /etc/default/squeezelite rm /etc/init.d/squeezelite @@ -11140,6 +10335,8 @@ _EOF_ INSTALLING_INDEX=99 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - Copy configs cp /etc/emonhub/conf/default/emonhub /etc/default/emonhub @@ -11151,7 +10348,7 @@ _EOF_ chmod +x -R /etc/emonhub #RPI 3 - Must disable BCM BT to recover UART 0 - if (( $HW_MODEL == 3 )); then + if (( $G_HW_MODEL == 3 )); then # - Add DToverlay to disable bluetooth if (( $(cat /DietPi/config.txt | grep -ci -m1 '=pi3-disable-bt') == 0 )); then @@ -11175,7 +10372,7 @@ _EOF_ /DietPi/dietpi/func/dietpi-set_hardware serialconsole disable # - Apply user API KEY - USER_EMONHUB_APIKEY_CURRENT=$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_emonhub_apikey=' | sed 's/.*=//') + USER_EMONHUB_APIKEY_CURRENT=$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_EMONHUB_APIKEY=' | sed 's/.*=//') sed -i "/apikey/c\ apikey = $USER_EMONHUB_APIKEY_CURRENT" /etc/emonhub/conf/emonhub.conf fi @@ -11184,6 +10381,8 @@ _EOF_ INSTALLING_INDEX=66 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - Update apt package stats /usr/share/rpimonitor/scripts/updatePackagesStatus.pl @@ -11234,6 +10433,8 @@ _EOF_ INSTALLING_INDEX=65 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - service cp /DietPi/dietpi/conf/netdata.service /etc/systemd/system/netdata.service @@ -11256,6 +10457,8 @@ _EOF_ INSTALLING_INDEX=57 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + Install_Apply_Permissions &> /dev/null # - install/run composer | Also run for ampache. Move this to a global function.... @@ -11270,7 +10473,7 @@ _EOF_ cd ~/ # - Mysql DB - /DietPi/dietpi/func/create_mysql_db baikal "$GLOBAL_PW" root "$GLOBAL_PW" + /DietPi/dietpi/func/create_mysql_db baikal baikal "$GLOBAL_PW" fi @@ -11278,8 +10481,10 @@ _EOF_ INSTALLING_INDEX=43 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Cap total connections - local max_users=$(( $CPU_CORES_TOTAL * 8 )) + local max_users=$(( $G_HW_CPU_CORES * 8 )) sed -i "/users=/c\users=$max_users" /etc/mumble-server.ini #Name the root channel @@ -11297,6 +10502,8 @@ _EOF_ INSTALLING_INDEX=41 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + Download_Test_Media fi @@ -11305,12 +10512,14 @@ _EOF_ INSTALLING_INDEX=42 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + Download_Test_Media #For all ARM devices: # - en_US.UTF8 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 (( $USER_INPUTS && - $HW_ARCH < 10 && ! $(locale | grep -ci -m1 'en_US.UTF-8') )); then + if (( $G_USER_INPUTS && + $G_HW_ARCH < 10 && ! $(locale | grep -ci -m1 '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 @@ -11328,6 +10537,8 @@ _EOF_ INSTALLING_INDEX=52 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/systemd/system/cuberite.service [Unit] Description=Cuberite Server @@ -11362,22 +10573,24 @@ _EOF_ INSTALLING_INDEX=53 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Stop mineos from running while we config it. When we didnt do this, the program would constantly overwrite our symlink from (/var/games/minecraft). /DietPi/dietpi/dietpi-services stop killall -w supervisord &> /dev/null killall -w node &> /dev/null killall -w nodejs &> /dev/null - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/mineos/minecraft/mineos_console.js /usr/local/bin/mineos + ln -sf "$G_FP_DIETPI_USERDATA"/mineos/minecraft/mineos_console.js /usr/local/bin/mineos - cp "$FP_DIETPI_USERDATA_DIRECTORY"/mineos/minecraft/mineos.conf /etc/mineos.conf + cp "$G_FP_DIETPI_USERDATA"/mineos/minecraft/mineos.conf /etc/mineos.conf # - setup SSL cert - cd "$FP_DIETPI_USERDATA_DIRECTORY"/mineos/minecraft + cd "$G_FP_DIETPI_USERDATA"/mineos/minecraft ./generate-sslcert.sh # - Supervisor service - cp "$FP_DIETPI_USERDATA_DIRECTORY"/mineos/minecraft/init/supervisor_conf /etc/supervisor/conf.d/mineos.conf + cp "$G_FP_DIETPI_USERDATA"/mineos/minecraft/init/supervisor_conf /etc/supervisor/conf.d/mineos.conf cd "$HOME" @@ -11386,20 +10599,20 @@ _EOF_ echo -e "dietpi\ndietpi\n" | passwd mineos # - Move server data storage to userdata dir (High disk writes) - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/mineos/serverdata + mkdir -p "$G_FP_DIETPI_USERDATA"/mineos/serverdata mkdir -p /var/games #sometimes this is not created by mineos after installation... Ensures symlink creation does not fail. - cp -R /var/games/minecraft/* "$FP_DIETPI_USERDATA_DIRECTORY"/mineos/serverdata/ #Folder does not exist during installation, as of 18/09/16 + cp -R /var/games/minecraft/* "$G_FP_DIETPI_USERDATA"/mineos/serverdata/ #Folder does not exist during installation, as of 18/09/16 rm -R /var/games/minecraft - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/mineos/serverdata /var/games/minecraft + ln -sf "$G_FP_DIETPI_USERDATA"/mineos/serverdata /var/games/minecraft chown -R mineos:mineos /var/games/minecraft # - correct the node filepath for supervisor mineos sed -i '/^command=/c\command=/usr/local/bin/node webui.js' /etc/supervisor/conf.d/mineos.conf - # - Set directory to FP_DIETPI_USERDATA_DIRECTORY - sed -i "/^directory=/c\directory=$FP_DIETPI_USERDATA_DIRECTORY/mineos/minecraft" /etc/supervisor/conf.d/mineos.conf + # - Set directory to G_FP_DIETPI_USERDATA + sed -i "/^directory=/c\directory=$G_FP_DIETPI_USERDATA/mineos/minecraft" /etc/supervisor/conf.d/mineos.conf supervisorctl reload @@ -11409,11 +10622,13 @@ _EOF_ INSTALLING_INDEX=49 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - Data storage / user data - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/gogs-repo + mkdir -p "$G_FP_DIETPI_USERDATA"/gogs-repo # - sqldb - /DietPi/dietpi/func/create_mysql_db gogs "$GLOBAL_PW" root "$GLOBAL_PW" + /DietPi/dietpi/func/create_mysql_db gogs gogs "$GLOBAL_PW" # - service (couldnt get this to run as a new thread with systemD (&). so bash script ftw. cat << _EOF_ > /etc/gogs/start.sh @@ -11448,6 +10663,8 @@ _EOF_ INSTALLING_INDEX=46 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - conf. mkdir -p "$HOME"/.config/qBittorrent cat << _EOF_ > "$HOME"/.config/qBittorrent/qBittorrent.conf @@ -11468,9 +10685,9 @@ Bittorrent\MaxUploadsPerTorrent=$(Optimize_BitTorrent 3) WebUI\Port=1340 WebUI\Enabled=true General\Locale=en_GB -Downloads\SavePath=$FP_DIETPI_USERDATA_DIRECTORY/downloads +Downloads\SavePath=$G_FP_DIETPI_USERDATA/downloads Downloads\TempPathEnabled=false -Downloads\TempPath=$FP_DIETPI_USERDATA_DIRECTORY/downloads +Downloads\TempPath=$G_FP_DIETPI_USERDATA/downloads Downloads\ScanDirs=@Invalid() Downloads\DownloadInScanDirs=@Invalid() Downloads\TorrentExportDir= @@ -11518,7 +10735,8 @@ DynDNS\Service=0 DynDNS\Username= DynDNS\Password= DynDNS\DomainName=changeme.dyndns.org -WebUI\Password_ha1=@ByteArray(5e434b0004be6970cf8878fcf929baba) +WebUI\Password_ha1=@ByteArray($(echo -ne "$GLOBAL_PW" | md5sum | awk '{print $1}')) + [LegalNotice] Accepted=true @@ -11553,6 +10771,8 @@ _EOF_ INSTALLING_INDEX=107 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Create username/password for rutorrent based on webserver type. # - Apache2 if (( ${aSOFTWARE_INSTALL_STATE[83]} >= 1 )); then @@ -11564,7 +10784,7 @@ _EOF_ a2enmod rewrite #install scgi module - AGI libapache2-mod-scgi + G_AGI libapache2-mod-scgi htpasswd -cb /etc/.rutorrent-htaccess root "$GLOBAL_PW" cat << _EOF_ > /var/www/rutorrent/.htaccess @@ -11649,7 +10869,7 @@ _EOF_ chmod 400 /etc/.rutorrent-htaccess # - Session folder - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/downloads/.session + mkdir -p "$G_FP_DIETPI_USERDATA"/downloads/.session # - Service using screen | '/usr/bin/rtorrent &> /var/log/rtorrent.log &' doesnt work, hangs program after 5 seconds cat << _EOF_ > /etc/systemd/system/rtorrent.service @@ -11699,12 +10919,12 @@ download_rate = 0 upload_rate = 0 # Default directory to save the downloaded torrents. -directory = $FP_DIETPI_USERDATA_DIRECTORY/downloads +directory = $G_FP_DIETPI_USERDATA/downloads # Default session directory. Make sure you don't run multiple instance # of rtorrent using the same session directory. Perhaps using a # relative path? -session = $FP_DIETPI_USERDATA_DIRECTORY/downloads/.session +session = $G_FP_DIETPI_USERDATA/downloads/.session # Close torrents when diskspace is low. schedule = low_diskspace,5,60,close_low_diskspace=1000M @@ -11797,29 +11017,31 @@ _EOF_ INSTALLING_INDEX=132 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/systemd/system/aria2.service [Unit] Description=DietPi Aria2 [Service] Type=simple -ExecStart=/usr/local/bin/aria2c --enable-rpc --rpc-listen-all --rpc-secret=$GLOBAL_PW --dir=$FP_DIETPI_USERDATA_DIRECTORY/$FOLDER_DOWNLOADS +ExecStart=$(which aria2c) --enable-rpc --rpc-listen-all --rpc-secret=$GLOBAL_PW --dir=$G_FP_DIETPI_USERDATA/$FOLDER_DOWNLOADS [Install] WantedBy=multi-user.target _EOF_ - systemctl daemon-reload - fi #SYNCTHING INSTALLING_INDEX=50 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - Generate dir's - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/syncthing - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/syncthing_data + mkdir -p "$G_FP_DIETPI_USERDATA"/syncthing + mkdir -p "$G_FP_DIETPI_USERDATA"/syncthing_data # Logs/Binary mkdir -p /var/log/syncthing @@ -11828,22 +11050,22 @@ _EOF_ chown -R dietpi:dietpi /etc/syncthing # - run syncthing to create cert/config and exit - /etc/syncthing/syncthing -generate="$FP_DIETPI_USERDATA_DIRECTORY"/syncthing + /etc/syncthing/syncthing -generate="$G_FP_DIETPI_USERDATA"/syncthing # - Disable automatic upgrades - sed -i '/<\/autoUpgradeIntervalH>/c\ 0<\/autoUpgradeIntervalH>' "$FP_DIETPI_USERDATA_DIRECTORY"/syncthing/config.xml + sed -i '/<\/autoUpgradeIntervalH>/c\ 0<\/autoUpgradeIntervalH>' "$G_FP_DIETPI_USERDATA"/syncthing/config.xml # - Allow external access (LAN). - sed -i '/:8384<\/address>/c\
0.0.0.0:8384<\/address>' "$FP_DIETPI_USERDATA_DIRECTORY"/syncthing/config.xml + sed -i '/:8384<\/address>/c\
0.0.0.0:8384<\/address>' "$G_FP_DIETPI_USERDATA"/syncthing/config.xml # - Set default folder - sed -i '/label=\"Default Folder/c\ ' "$FP_DIETPI_USERDATA_DIRECTORY"/syncthing/config.xml + sed -i '/label=\"Default Folder/c\ ' "$G_FP_DIETPI_USERDATA"/syncthing/config.xml # - Disable browser starting - sed -i '/<\/startBrowser>/c\ false<\/startBrowser>' "$FP_DIETPI_USERDATA_DIRECTORY"/syncthing/config.xml + sed -i '/<\/startBrowser>/c\ false<\/startBrowser>' "$G_FP_DIETPI_USERDATA"/syncthing/config.xml # - Enable filesystem watcher (previously inotify) - sed -i 's/fsWatcherEnabled=\"false\"/fsWatcherEnabled=\"true\"/g' "$FP_DIETPI_USERDATA_DIRECTORY"/syncthing/config.xml + sed -i 's/fsWatcherEnabled=\"false\"/fsWatcherEnabled=\"true\"/g' "$G_FP_DIETPI_USERDATA"/syncthing/config.xml #services cat << _EOF_ > /etc/systemd/system/syncthing.service @@ -11853,7 +11075,7 @@ After=network.target [Service] Type=simple -ExecStart=/etc/syncthing/syncthing -logfile=/var/log/syncthing/syncthing.log -logflags=3 -home=$FP_DIETPI_USERDATA_DIRECTORY/syncthing +ExecStart=/etc/syncthing/syncthing -logfile=/var/log/syncthing/syncthing.log -logflags=3 -home=$G_FP_DIETPI_USERDATA/syncthing User=dietpi [Install] @@ -11869,7 +11091,9 @@ _EOF_ INSTALLING_INDEX=111 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/urbackup/urbackup_tmp_files + Banner_Configuration + + mkdir -p "$G_FP_DIETPI_USERDATA"/urbackup/urbackup_tmp_files #As we have /tmp mounted to RAM, change tmp locations sed -i '/DAEMON_TMPDIR=/c\DAEMON_TMPDIR="/var/tmp"' /etc/default/urbackupsrv @@ -11883,7 +11107,9 @@ _EOF_ INSTALLING_INDEX=116 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/sickrage + Banner_Configuration + + mkdir -p "$G_FP_DIETPI_USERDATA"/sickrage cat << _EOF_ > /etc/systemd/system/sickrage.service [Unit] @@ -11895,7 +11121,7 @@ User=root Group=root Type=forking GuessMainPID=no -ExecStart=/usr/bin/python /etc/sickrage/SickBeard.py -q --daemon --nolaunch --datadir=$FP_DIETPI_USERDATA_DIRECTORY/sickrage +ExecStart=/usr/bin/python /etc/sickrage/SickBeard.py -q --daemon --nolaunch --datadir=$G_FP_DIETPI_USERDATA/sickrage #ExecStop=/usr/bin/killall -w SickBeard.py [Install] @@ -11904,23 +11130,23 @@ _EOF_ #Grab our premade config: # SickRage must be run at least once, or it will simply overwrite our config - /DietPi/dietpi/func/dietpi-notify 2 "Configuring SickRage, please wait..." + G_DIETPI-NOTIFY 2 "Configuring SickRage, please wait..." systemctl start sickrage # Wait for SickRage to generate its default config.ini, else, it will just overwrite our config.ini. local max_loops=10 local current_loop=0 - while [ ! -f "$FP_DIETPI_USERDATA_DIRECTORY/sickrage/config.ini" ] + while [ ! -f "$G_FP_DIETPI_USERDATA/sickrage/config.ini" ] do - /DietPi/dietpi/func/dietpi-notify 2 "Waiting for SickRage to finish 1st run prep, please wait..." + G_DIETPI-NOTIFY 2 "Waiting for SickRage to finish 1st run prep, please wait..." sleep 1 ((current_loop++)) if (( $current_loop >= $max_loops )); then - /DietPi/dietpi/func/dietpi-notify 1 "Timed-out waiting for SickRage to generate config.ini" + G_DIETPI-NOTIFY 1 "Timed-out waiting for SickRage to generate config.ini" break fi @@ -11929,8 +11155,8 @@ _EOF_ systemctl stop sickrage - cp "$FP_DIETPI_USERDATA_DIRECTORY"/sickrage/config.ini "$FP_DIETPI_USERDATA_DIRECTORY"/sickrage/config.ini.default - wget http://dietpi.com/downloads/conf/sickrage_dietpi_config.ini -O "$FP_DIETPI_USERDATA_DIRECTORY"/sickrage/config.ini + cp "$G_FP_DIETPI_USERDATA"/sickrage/config.ini "$G_FP_DIETPI_USERDATA"/sickrage/config.ini.default + wget http://dietpi.com/downloads/conf/sickrage_dietpi_config.ini -O "$G_FP_DIETPI_USERDATA"/sickrage/config.ini fi @@ -11938,6 +11164,8 @@ _EOF_ INSTALLING_INDEX=134 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #service cat << _EOF_ > /etc/systemd/system/tonido.service [Unit] @@ -11954,18 +11182,18 @@ WantedBy=multi-user.target _EOF_ # - userdirs - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/tonido/sync - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/tonido/syncdata + mkdir -p "$G_FP_DIETPI_USERDATA"/tonido/sync + mkdir -p "$G_FP_DIETPI_USERDATA"/tonido/syncdata # symlink - cp -R "$HOME"/tonido "$FP_DIETPI_USERDATA_DIRECTORY"/ + cp -R "$HOME"/tonido "$G_FP_DIETPI_USERDATA"/ rm -R "$HOME"/tonido - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/tonido "$HOME"/tonido - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/tonido/sync "$HOME"/TonidoSync - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/tonido/syncdata "$HOME"/TonidoSyncData + ln -sf "$G_FP_DIETPI_USERDATA"/tonido "$HOME"/tonido + ln -sf "$G_FP_DIETPI_USERDATA"/tonido/sync "$HOME"/TonidoSync + ln -sf "$G_FP_DIETPI_USERDATA"/tonido/syncdata "$HOME"/TonidoSyncData # - armv7 switch - if (( $HW_ARCH == 2 )); then + if (( $G_HW_ARCH == 2 )); then sed -i 's/armv6l/armv7l/' /etc/tonido/manifest.xml sed -i 's/armv6l/armv7l/' /etc/tonido/plugins/*/manifest.xml @@ -11978,14 +11206,16 @@ _EOF_ INSTALLING_INDEX=113 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Allow root, start maximized and disable sandbox under root (blank screen without) local export_options="export CHROMIUM_FLAGS=\"\$CHROMIUM_FLAGS --no-sandbox --temp-profile --start-maximized --user-data-dir " #RPi - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then # OpenGL - if (( $HW_MODEL >= 2 )); then + if (( $G_HW_MODEL >= 2 )); then #Hangs xinit: https://github.com/Fourdee/DietPi/issues/834 #/DietPi/dietpi/func/dietpi-set_hardware rpi-opengl enable @@ -11994,7 +11224,7 @@ _EOF_ fi #OpenGL - elif (( $HW_MODEL == 21 )); then + elif (( $G_HW_MODEL == 21 )); then echo 0 &> /dev/null @@ -12025,6 +11255,8 @@ _EOF_ INSTALLING_INDEX=126 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + omv-initsystem fi @@ -12033,12 +11265,14 @@ _EOF_ INSTALLING_INDEX=129 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - sed -i "/'mysqli_user'/c \$cfg[\'mysqli_user\'] = \'root\';" /var/www/ompd/include/config.inc.php + Banner_Configuration + + sed -i "/'mysqli_user'/c \$cfg[\'mysqli_user\'] = \'ompd\';" /var/www/ompd/include/config.inc.php sed -i "/'mysqli_password'/c \$cfg[\'mysqli_password\'] = \'$GLOBAL_PW\';" /var/www/ompd/include/config.inc.php sed -i "/'media_dir'/c \$cfg[\'media_dir\'] = \'/var/lib/mpd/music/\';" /var/www/ompd/include/config.inc.php sed -i "/'ignore_media_dir_access_error'/c \$cfg[\'ignore_media_dir_access_error\'] = \'true';" /var/www/ompd/include/config.inc.php - /DietPi/dietpi/func/create_mysql_db ompd "$GLOBAL_PW" root "$GLOBAL_PW" + /DietPi/dietpi/func/create_mysql_db ompd ompd "$GLOBAL_PW" fi @@ -12046,6 +11280,8 @@ _EOF_ INSTALLING_INDEX=135 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #icecast set passwords: sed -i '/\/c\\dietpi\<\/source-password\>' /etc/icecast2/icecast.xml sed -i '/\/c\\dietpi\<\/relay-password\>' /etc/icecast2/icecast.xml @@ -12093,7 +11329,7 @@ description = DarkIce on DietPi url = http://localhost genre = none public = no -#localDumpFile = $FP_DIETPI_USERDATA_DIRECTORY/darkice_recording.ogg +#localDumpFile = $G_FP_DIETPI_USERDATA/darkice_recording.ogg _EOF_ #SystemD service for Darkice @@ -12118,13 +11354,15 @@ _EOF_ INSTALLING_INDEX=131 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - service local fp_java_binary=$(which java) - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/blynk + mkdir -p "$G_FP_DIETPI_USERDATA"/blynk CONFIG_FILE_URL_ADDRESS='https://raw.githubusercontent.com/blynkkk/blynk-server/master/server/core/src/main/resources/server.properties' - wget "$CONFIG_URL_ADDRESS" -O "$FP_DIETPI_USERDATA_DIRECTORY"/blynk/server.properties - sed -i "/data.folder=/c\data.folder=$FP_DIETPI_USERDATA_DIRECTORY/blynk" "$FP_DIETPI_USERDATA_DIRECTORY"/blynk/server.properties + wget "$CONFIG_FILE_URL_ADDRESS" -O "$G_FP_DIETPI_USERDATA"/blynk/server.properties + sed -i "/data.folder=/c\data.folder=$G_FP_DIETPI_USERDATA/blynk" "$G_FP_DIETPI_USERDATA"/blynk/server.properties cat << _EOF_ > /etc/systemd/system/blynkserver.service [Unit] @@ -12133,7 +11371,7 @@ After=network.target [Service] Type=simple -ExecStart=$fp_java_binary -jar /etc/blynkserver/server.jar -serverConfig $FP_DIETPI_USERDATA_DIRECTORY/blynk/server.properties +ExecStart=$fp_java_binary -jar /etc/blynkserver/server.jar -serverConfig $G_FP_DIETPI_USERDATA/blynk/server.properties [Install] WantedBy=multi-user.target @@ -12145,8 +11383,10 @@ _EOF_ INSTALLING_INDEX=136 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Enable RPi cam - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then /DietPi/dietpi/func/dietpi-set_hardware rpi-camera enable @@ -12155,8 +11395,8 @@ _EOF_ mkdir -p /etc/motioneye cp /usr/local/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/motioneye - sed -i "/^media_path/c\media_path $FP_DIETPI_USERDATA_DIRECTORY/motioneye" /etc/motioneye/motioneye.conf + mkdir -p "$G_FP_DIETPI_USERDATA"/motioneye + sed -i "/^media_path/c\media_path $G_FP_DIETPI_USERDATA/motioneye" /etc/motioneye/motioneye.conf # service cp /usr/local/share/motioneye/extra/motioneye.systemd-unit-local /etc/systemd/system/motioneye.service @@ -12167,6 +11407,8 @@ _EOF_ INSTALLING_INDEX=137 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - Enable web admin cupsctl --remote-admin usermod -a -G lpadmin root @@ -12177,6 +11419,8 @@ _EOF_ INSTALLING_INDEX=138 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/systemd/system/virtualhere.service [Unit] Description=VirtualHere DietPi service @@ -12200,6 +11444,8 @@ _EOF_ INSTALLING_INDEX=139 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/systemd/system/sabnzbd.service [Unit] Description=sabnzbd DietPi @@ -12219,7 +11465,7 @@ _EOF_ rm /etc/sabnzbd/sabnzbd.ini &> /dev/null systemctl start sabnzbd - /DietPi/dietpi/func/dietpi-notify 2 "Generating initial config, please wait..." + G_DIETPI-NOTIFY 2 "Generating initial config, please wait..." while [ ! -f /etc/sabnzbd/sabnzbd.ini ] do @@ -12233,10 +11479,10 @@ _EOF_ sleep 2 #additional wait, config being overwritten after below changes: http://dietpi.com/phpbb/viewtopic.php?f=11&t=1848&p=7085#p7082 - sed -i "/^download_dir =/c\download_dir = $FP_DIETPI_USERDATA_DIRECTORY/downloads/incomplete" /etc/sabnzbd/sabnzbd.ini - sed -i "/^complete_dir =/c\complete_dir = $FP_DIETPI_USERDATA_DIRECTORY/downloads/complete" /etc/sabnzbd/sabnzbd.ini - sed -i "/^nzb_backup_dir =/c\nzb_backup_dir = $FP_DIETPI_USERDATA_DIRECTORY/downloads/sabnzbd_nzb_backup" /etc/sabnzbd/sabnzbd.ini - sed -i "/^admin_dir =/c\admin_dir = $FP_DIETPI_USERDATA_DIRECTORY/downloads/sabnzbd_admin" /etc/sabnzbd/sabnzbd.ini + sed -i "/^download_dir =/c\download_dir = $G_FP_DIETPI_USERDATA/downloads/incomplete" /etc/sabnzbd/sabnzbd.ini + sed -i "/^complete_dir =/c\complete_dir = $G_FP_DIETPI_USERDATA/downloads/complete" /etc/sabnzbd/sabnzbd.ini + sed -i "/^nzb_backup_dir =/c\nzb_backup_dir = $G_FP_DIETPI_USERDATA/downloads/sabnzbd_nzb_backup" /etc/sabnzbd/sabnzbd.ini + sed -i "/^admin_dir =/c\admin_dir = $G_FP_DIETPI_USERDATA/downloads/sabnzbd_admin" /etc/sabnzbd/sabnzbd.ini sed -i "/^log_dir =/c\log_dir = /var/log" /etc/sabnzbd/sabnzbd.ini sed -i "/^log_level =/c\log_level = 0" /etc/sabnzbd/sabnzbd.ini #err only sed -i "/^refresh_rate =/c\refresh_rate = 2" /etc/sabnzbd/sabnzbd.ini @@ -12248,6 +11494,8 @@ _EOF_ INSTALLING_INDEX=141 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/systemd/system/spotify-connect-web.service [Unit] Description=spotify-connect-web @@ -12255,8 +11503,8 @@ After=sound.target [Service] Type=simple -WorkingDirectory=$FP_DIETPI_USERDATA_DIRECTORY/spotify-connect-web -ExecStart=$FP_DIETPI_USERDATA_DIRECTORY/spotify-connect-web/spotify-connect-web +WorkingDirectory=$G_FP_DIETPI_USERDATA/spotify-connect-web +ExecStart=$G_FP_DIETPI_USERDATA/spotify-connect-web/spotify-connect-web [Install] WantedBy=multi-user.target @@ -12268,13 +11516,15 @@ _EOF_ INSTALLING_INDEX=142 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cp /etc/couchpotato/init/ubuntu.default /etc/default/couchpotato sed -i "/CP_USER=/c\CP_USER=root" /etc/default/couchpotato sed -i "/CP_HOME=/c\CP_HOME=/etc/couchpotato" /etc/default/couchpotato - sed -i "/CP_DATA=/c\CP_DATA=$FP_DIETPI_USERDATA_DIRECTORY/couchpotato" /etc/default/couchpotato + sed -i "/CP_DATA=/c\CP_DATA=$G_FP_DIETPI_USERDATA/couchpotato" /etc/default/couchpotato - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/couchpotato - #useradd -d "$FP_DIETPI_USERDATA_DIRECTORY"/couchpotato couchpotato + mkdir -p "$G_FP_DIETPI_USERDATA"/couchpotato + #useradd -d "$G_FP_DIETPI_USERDATA"/couchpotato couchpotato cp /etc/couchpotato/init/ubuntu /etc/init.d/couchpotato @@ -12284,16 +11534,18 @@ _EOF_ INSTALLING_INDEX=143 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + Download_Test_Media - /DietPi/dietpi/func/create_mysql_db koel "$GLOBAL_PW" root "$GLOBAL_PW" + /DietPi/dietpi/func/create_mysql_db koel koel "$GLOBAL_PW" cd /var/www/koel sed -i '/DB_CONNECTION=/c\DB_CONNECTION=mysql' .env sed -i '/DB_HOST=/c\DB_HOST=127.0.0.1' .env sed -i '/DB_DATABASE=/c\DB_DATABASE=koel' .env - sed -i '/DB_USERNAME=/c\DB_USERNAME=root' .env + sed -i '/DB_USERNAME=/c\DB_USERNAME=koel' .env sed -i "/DB_PASSWORD=/c\DB_PASSWORD=$GLOBAL_PW" .env sed -i '/ADMIN_EMAIL=/c\ADMIN_EMAIL=dietpi@dietpi.com' .env @@ -12303,6 +11555,7 @@ _EOF_ sed -i "/FFMPEG_PATH=/c\FFMPEG_PATH=$(which ffmpeg)" .env php artisan koel:init + #php artisan db:seed --force cd "$HOME" @@ -12326,6 +11579,8 @@ _EOF_ INSTALLING_INDEX=144 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/systemd/system/sonarr.service [Unit] Description=Sonarr (NzbDrone) Daemon @@ -12349,6 +11604,8 @@ _EOF_ INSTALLING_INDEX=145 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/systemd/system/radarr.service [Unit] Description=Radarr Daemon @@ -12372,14 +11629,16 @@ _EOF_ INSTALLING_INDEX=146 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/plexpy + Banner_Configuration + + mkdir -p "$G_FP_DIETPI_USERDATA"/plexpy cat << _EOF_ > /etc/systemd/system/plexpy.service [Unit] Description=PlexPy - Stats for Plex Media Server usage [Service] -ExecStart=/opt/plexpy/PlexPy.py --quiet --daemon --nolaunch --config /opt/plexpy/config.ini --datadir $FP_DIETPI_USERDATA_DIRECTORY/plexpy +ExecStart=/opt/plexpy/PlexPy.py --quiet --daemon --nolaunch --config /opt/plexpy/config.ini --datadir $G_FP_DIETPI_USERDATA/plexpy GuessMainPID=no Type=forking User=root @@ -12395,6 +11654,8 @@ _EOF_ INSTALLING_INDEX=147 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/systemd/system/jackett.service [Unit] Description=Jackett Daemon @@ -12418,27 +11679,29 @@ _EOF_ INSTALLING_INDEX=149 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - sed -i "/MainDir=/c\MainDir=$FP_DIETPI_USERDATA_DIRECTORY/downloads" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf - sed -i "/DestDir=/c\DestDir=$FP_DIETPI_USERDATA_DIRECTORY/downloads/complete" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf + Banner_Configuration + + sed -i "/MainDir=/c\MainDir=$G_FP_DIETPI_USERDATA/downloads" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf + sed -i "/DestDir=/c\DestDir=$G_FP_DIETPI_USERDATA/downloads/complete" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf - sed -i "/LogFile=/c\LogFile=/var/log/nzbget.log" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf + sed -i "/LogFile=/c\LogFile=/var/log/nzbget.log" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf - sed -i "/ControlUsername=/c\ControlUsername=root" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf - sed -i "/ControlPassword=/c\ControlPassword=$GLOBAL_PW" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf + sed -i "/ControlUsername=/c\ControlUsername=root" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf + sed -i "/ControlPassword=/c\ControlPassword=$GLOBAL_PW" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf # Optimizations - sed -i "/Server1.Cipher=/c\Server1.Cipher=RC4-MD5" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf - sed -i "/CrcCheck=/c\CrcCheck=no" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf - sed -i "/ParScan=/c\ParScan=limited" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf - sed -i "/ParThreads=/c\ParThreads=$CPU_CORES_TOTAL" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf + sed -i "/Server1.Cipher=/c\Server1.Cipher=RC4-MD5" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf + sed -i "/CrcCheck=/c\CrcCheck=no" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf + sed -i "/ParScan=/c\ParScan=limited" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf + sed -i "/ParThreads=/c\ParThreads=$G_HW_CPU_CORES" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf - sed -i "/DebugTarget=/c\DebugTarget=none" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf - sed -i "/CrashTrace=/c\CrashTrace=no" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf - sed -i "/DetailTarget=/c\DetailTarget=none" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf + sed -i "/DebugTarget=/c\DebugTarget=none" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf + sed -i "/CrashTrace=/c\CrashTrace=no" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf + sed -i "/DetailTarget=/c\DetailTarget=none" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf - sed -i "/ParBuffer=/c\ParBuffer=$(Optimize_BitTorrent 0)" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf - sed -i "/ArticleCache=/c\ArticleCache=$(Optimize_BitTorrent 0)" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf - sed -i "/WriteBuffer=/c\WriteBuffer=$(Optimize_BitTorrent 0)" "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget/nzbget.conf + sed -i "/ParBuffer=/c\ParBuffer=$(Optimize_BitTorrent 0)" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf + sed -i "/ArticleCache=/c\ArticleCache=$(Optimize_BitTorrent 0)" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf + sed -i "/WriteBuffer=/c\WriteBuffer=$(Optimize_BitTorrent 0)" "$G_FP_DIETPI_USERDATA"/nzbget/nzbget.conf cat << _EOF_ > /etc/systemd/system/nzbget.service [Unit] @@ -12447,8 +11710,8 @@ Description=NZBget [Service] Type=forking User=root -WorkingDirectory=$FP_DIETPI_USERDATA_DIRECTORY/nzbget -ExecStart=$FP_DIETPI_USERDATA_DIRECTORY/nzbget/nzbget -D +WorkingDirectory=$G_FP_DIETPI_USERDATA/nzbget +ExecStart=$G_FP_DIETPI_USERDATA/nzbget/nzbget -D [Install] WantedBy=multi-user.target @@ -12460,6 +11723,8 @@ _EOF_ INSTALLING_INDEX=155 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/systemd/system/htpc-manager.service [Unit] Description=HTPC Manager @@ -12467,7 +11732,7 @@ After=network.target [Service] Type=simple -ExecStart=/usr/bin/python $FP_DIETPI_USERDATA_DIRECTORY/htpc-manager/Htpc.py +ExecStart=/usr/bin/python $G_FP_DIETPI_USERDATA/htpc-manager/Htpc.py [Install] WantedBy=multi-user.target @@ -12479,6 +11744,8 @@ _EOF_ INSTALLING_INDEX=153 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/systemd/system/octoprint.service [Unit] Description=OctoPrint @@ -12498,6 +11765,8 @@ _EOF_ INSTALLING_INDEX=154 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/systemd/system/roonserver.service [Unit] Description=Roon Server @@ -12506,8 +11775,8 @@ After=network.target [Service] Type=simple User=root -Environment=ROON_DATAROOT=/mnt/dietpi_userdata/roonserver -ExecStart=/mnt/dietpi_userdata/roonserver/start.sh +Environment=ROON_DATAROOT=$G_FP_DIETPI_USERDATA/roonserver +ExecStart=$G_FP_DIETPI_USERDATA/roonserver/start.sh [Install] WantedBy=multi-user.target @@ -12519,11 +11788,13 @@ _EOF_ INSTALLING_INDEX=156 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - mkdir -p "$FP_DIETPI_USERDATA_DIRECTORY"/steam - mv "$HOME"/.steam/* "$FP_DIETPI_USERDATA_DIRECTORY"/steam/ + Banner_Configuration + + mkdir -p "$G_FP_DIETPI_USERDATA"/steam + mv "$HOME"/.steam/* "$G_FP_DIETPI_USERDATA"/steam/ rm -R "$HOME"/.steam - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/steam "$HOME"/.steam + ln -sf "$G_FP_DIETPI_USERDATA"/steam "$HOME"/.steam fi @@ -12531,6 +11802,8 @@ _EOF_ INSTALLING_INDEX=157 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cat << _EOF_ > /etc/systemd/system/home-assistant.service [Unit] Description=Home Assistant @@ -12549,8 +11822,8 @@ _EOF_ # Link to the default ha location for the homeassistant user, this makes # the configuration avaliable for the user to edit. Configuration generated # when service is started at /home/homeassistant/.homeassistant - mkdir "$FP_DIETPI_USERDATA_DIRECTORY"/homeassistant - ln -sf "$FP_DIETPI_USERDATA_DIRECTORY"/homeassistant /home/homeassistant/.homeassistant + mkdir "$G_FP_DIETPI_USERDATA"/homeassistant + ln -sf "$G_FP_DIETPI_USERDATA"/homeassistant /home/homeassistant/.homeassistant fi #------------------------------------------------------------------- @@ -12559,10 +11832,12 @@ _EOF_ INSTALLING_INDEX=158 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # Create simple mandatory default configuration file cat << _EOF_ >> /etc/default/minio # Default file path -MINIO_VOLUMES="/mnt/dietpi_userdata/minio-data" +MINIO_VOLUMES="$G_FP_DIETPI_USERDATA/minio-data" # Use if you want to run Minio on a custom port. # MINIO_OPTS="--address :9199" # Access Key of the server. @@ -12580,14 +11855,16 @@ _EOF_ INSTALLING_INDEX=162 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # Create directory for docker containers - mkdir "$FP_DIETPI_USERDATA_DIRECTORY"/docker-data + mkdir "$G_FP_DIETPI_USERDATA"/docker-data # stop service systemctl stop docker.service # Set container(s) locations in /lib/systemd/system/docker.service - sed -i "/ExecStart=\/usr\/bin\/dockerd/c\ExecStart=\/usr\/bin\/dockerd -g $FP_DIETPI_USERDATA_DIRECTORY\/docker-data -H fd:\/\/" /lib/systemd/system/docker.service + sed -i "/ExecStart=\/usr\/bin\/dockerd/c\ExecStart=\/usr\/bin\/dockerd -g $G_FP_DIETPI_USERDATA\/docker-data -H fd:\/\/" /lib/systemd/system/docker.service fi @@ -12596,23 +11873,25 @@ _EOF_ INSTALLING_INDEX=161 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # Setup Filestore DietPi appropriate # IF already present just create symlink - if [ ! -f "$FP_DIETPI_USERDATA_DIRECTORY"/fuguhub-data/ ]; then + if [ ! -f "$G_FP_DIETPI_USERDATA"/fuguhub-data/ ]; then # Move installed filestore to dietpi folder - mkdir "$FP_DIETPI_USERDATA_DIRECTORY"/fuguhub-data/ - mv /home/bd/disk/* "$FP_DIETPI_USERDATA_DIRECTORY"/fuguhub-data/ + mkdir "$G_FP_DIETPI_USERDATA"/fuguhub-data/ + mv /home/bd/disk/* "$G_FP_DIETPI_USERDATA"/fuguhub-data/ # Removed 'actual' folder to make way for symlink rm -r /home/bd/disk # Create symlink - ln -s "$FP_DIETPI_USERDATA_DIRECTORY"/fuguhub-data /home/bd/disk + ln -s "$G_FP_DIETPI_USERDATA"/fuguhub-data /home/bd/disk # Set permissions - # setfacl -R -m u:bd:rwx "$FP_DIETPI_USERDATA_DIRECTORY"/fuguhub-data/ + # setfacl -R -m u:bd:rwx "$G_FP_DIETPI_USERDATA"/fuguhub-data/ else # Removed 'actual' folder to make way for symlink rm -r /home/bd/disk # Create symlink - ln -s "$FP_DIETPI_USERDATA_DIRECTORY"/fuguhub-data /home/bd/disk + ln -s "$G_FP_DIETPI_USERDATA"/fuguhub-data /home/bd/disk fi fi @@ -12621,6 +11900,9 @@ _EOF_ #Nukkit Config INSTALLING_INDEX=164 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + + Banner_Configuration + # Conig file to autostart -- english default wget -O /usr/local/bin/nukkit/nukkit.yml https://github.com/Nukkit/Languages/raw/master/eng/nukkit.yml # create systemd file @@ -12642,6 +11924,8 @@ _EOF_ INSTALLING_INDEX=165 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - service cat << _EOF_ > /etc/systemd/system/gitea.service @@ -12651,9 +11935,9 @@ Description=Gitea (Git with a cup of tea) [Service] Type=simple User=dietpi -WorkingDirectory=$FP_DIETPI_USERDATA_DIRECTORY/gitea/gitea-repositories -ExecStart=$FP_DIETPI_USERDATA_DIRECTORY/gitea/gitea web -Environment=USER=dietpi HOME=$FP_DIETPI_USERDATA_DIRECTORY/gitea +WorkingDirectory=$G_FP_DIETPI_USERDATA/gitea/gitea-repositories +ExecStart=$G_FP_DIETPI_USERDATA/gitea/gitea web +Environment=USER=dietpi HOME=$G_FP_DIETPI_USERDATA/gitea [Install] WantedBy=multi-user.target @@ -12664,7 +11948,7 @@ _EOF_ chown -R dietpi:dietpi /var/log/gitea # - sqldb - /DietPi/dietpi/func/create_mysql_db gitea "$GLOBAL_PW" root "$GLOBAL_PW" + /DietPi/dietpi/func/create_mysql_db gitea gitea "$GLOBAL_PW" fi @@ -12674,8 +11958,10 @@ _EOF_ if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 || ${aSOFTWARE_INSTALL_STATE[160]} == 1 )); then - /DietPi/dietpi/func/create_mysql_db allo_db dietpi root dietpi - mysql -u root -pdietpi allo_db < /var/www/allo_db.sql + Banner_Configuration + + /DietPi/dietpi/func/create_mysql_db allo_db allo_db "$GLOBAL_PW" + mysql allo_db < /var/www/allo_db.sql rm /var/www/allo_db.sql # - Redirect to web interface by default: @@ -12693,7 +11979,7 @@ _EOF_ #HW specific changes # - SPARKY ONLY - Auto detect eth adapter - if (( $HW_MODEL == 70 )); then + if (( $G_HW_MODEL == 70 )); then # - Disable onboard ETH if adapter found cat << _EOF_ > /etc/systemd/system/sparky_eth_controller.service @@ -12748,6 +12034,8 @@ _EOF_ INSTALLING_INDEX=163 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + cp /DietPi/dietpi/conf/gmrender.service /etc/systemd/system/gmrender.service fi @@ -12756,9 +12044,11 @@ _EOF_ INSTALLING_INDEX=166 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then - mkdir -p /etc/dietpi/audiophonics/pi-spc + Banner_Configuration + + mkdir -p /var/lib/dietpi/dietpi-software/installed/pi-spc - cat << _EOF_ > /etc/dietpi/audiophonics/pi-spc/sds.sh + cat << _EOF_ > /var/lib/dietpi/dietpi-software/installed/pi-spc/sds.sh #!/bin/bash #DietPi version PATH=/usr/bin:/home/pi/wiringPi/gpio:/usr/local/bin @@ -12783,7 +12073,7 @@ do if (( \$(gpio -g read 17) == 1 )); then - /DietPi/dietpi/func/dietpi-notify 0 "AudioPhonics Pi-SPC: Power off requested. Shutting down system." + G_DIETPI-NOTIFY 0 "AudioPhonics Pi-SPC: Power off requested. Shutting down system." sudo poweroff #sudo shutdown -h -P now break @@ -12797,7 +12087,7 @@ done exit 0 _EOF_ - chmod +x /etc/dietpi/audiophonics/pi-spc/sds.sh + chmod +x /var/lib/dietpi/dietpi-software/installed/pi-spc/sds.sh cat << _EOF_ > /etc/systemd/system/pi-spc.service [Unit] @@ -12808,7 +12098,7 @@ Type=simple StandardOutput=tty User=root -ExecStart=/bin/bash -c '/etc/dietpi/audiophonics/pi-spc/sds.sh' +ExecStart=/bin/bash -c '/var/lib/dietpi/dietpi-software/installed/pi-spc/sds.sh' [Install] WantedBy=multi-user.target @@ -12820,6 +12110,8 @@ _EOF_ INSTALLING_INDEX=168 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + #Create moOde runtime environment --------------------------------------------------------- # Create Pi user, does not exist on DietPi systems. # - Required for some moOde bash scripts which live in /home/pi @@ -12975,7 +12267,7 @@ _EOF_ while [ ! -f /DietPi/.ramdisk ] do - /DietPi/dietpi/func/dietpi-notify 2 "Waiting for DietPi-RAMDISK to finish mounting DietPi to RAM..." + G_DIETPI-NOTIFY 2 "Waiting for DietPi-RAMDISK to finish mounting DietPi to RAM..." sleep 1 done @@ -13032,8 +12324,10 @@ _EOF_ INSTALLING_INDEX=169 if (( ${aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]} == 1 )); then + Banner_Configuration + # - Symlink userdata location for assistant.json - ln -sf /mnt/dietpi_userdata/voice-recognizer-raspi/assistant.json /home/dietpi/assistant.json + ln -sf "$G_FP_DIETPI_USERDATA"/voice-recognizer-raspi/assistant.json /home/dietpi/assistant.json # - Generate cache dir mkdir -p /home/dietpi/.cache/voice-recognizer @@ -13089,7 +12383,7 @@ _EOF_ if (( $gpu_memory > 0 )); then #RPi - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then /DietPi/dietpi/func/dietpi-set_hardware gpumemsplit $gpu_memory @@ -13100,19 +12394,19 @@ _EOF_ if (( $gpu_enabled )); then #RPi - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then - sed -i "/rpi_hdmi_output=/c\rpi_hdmi_output=1" /DietPi/dietpi.txt + sed -i "/CONFIG_HDMI_OUTPUT=/c\CONFIG_HDMI_OUTPUT=1" /DietPi/dietpi.txt #odroid C1 - elif (( $HW_MODEL == 10 )); then + 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 (( $HW_MODEL == 12 )); then + elif (( $G_HW_MODEL == 12 )); then sed -i '/setenv nographics /c\setenv nographics "0"' /DietPi/boot.ini @@ -13142,19 +12436,21 @@ _EOF_ #NB: systemctl daemon-reload is executed after this func in Uninstall_Software_Finalize() + local index=$1 + #---------------------------------------------------------------------- #Inform User - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Software "Uninstall" + G_DIETPI-NOTIFY 3 DietPi-Software "Uninstall" echo -e "" - /DietPi/dietpi/func/dietpi-notify 0 "Uninstalling ${aSOFTWARE_WHIP_NAME[$1]}: ${aSOFTWARE_WHIP_DESC[$1]}\n" + G_DIETPI-NOTIFY 0 "Uninstalling ${aSOFTWARE_WHIP_NAME[$index]}: ${aSOFTWARE_WHIP_DESC[$index]}\n" #Was a uninstall event trigged? local valid_input=1 #---------------------------------------------------------------------- #DIETPI SOFTWARE - if (( $1 == 100 )); then + if (( $index == 100 )); then grasshopper_directory='/var/www' rm -R "$grasshopper_directory"/documentation @@ -13176,216 +12472,237 @@ _EOF_ update-rc.d grasshopper remove rm /etc/init.d/grasshopper - elif (( $1 == 23 )); then + elif (( $index == 23 )); then - AGP lxde lxde-* upower policykit-1 iceweasel p7zip-full + G_AGP lxde lxde-* upower policykit-1 iceweasel p7zip-full - elif (( $1 == 24 )); then + elif (( $index == 24 )); then - AGP mate-desktop-environment-extras upower policykit-1 iceweasel p7zip-full + G_AGP mate-desktop-environment-extras upower policykit-1 iceweasel p7zip-full - elif (( $1 == 26 )); then + elif (( $index == 26 )); then - AGP x-window-system-core wmaker gnustep gnustep-devel gnustep-games upower policykit-1 iceweasel p7zip-full + G_AGP x-window-system-core wmaker gnustep gnustep-devel gnustep-games upower policykit-1 iceweasel p7zip-full - elif (( $1 == 25 )); then + elif (( $index == 25 )); then - AGP xfce4 gnome-icon-theme tango-icon-theme iceweasel p7zip-full + G_AGP xfce4 gnome-icon-theme tango-icon-theme iceweasel p7zip-full - elif (( $1 == 22 )); then + elif (( $index == 22 )); then - AGP quiterss + G_AGP quiterss - elif (( $1 == 30 )); then + elif (( $index == 30 )); then - AGP nomachine + G_RUN_CMD dpkg -P nomachine - elif (( $1 == 29 )); then + elif (( $index == 29 )); then - AGP xrdp + G_AGP xrdp - elif (( $1 == 44 )); then + elif (( $index == 44 )); then - AGP transmission-daemon + G_AGP transmission-daemon rm /etc/init.d/transmission-daemon &> /dev/null rm /etc/systemd/system/transmission-daemon.service &> /dev/null - elif (( $1 == 83 )); then + elif (( $index == 47 )); then + #ownCloud + # Remove background cron job + crontab -u www-data -l | grep -v '/var/www/owncloud/cron.php' | crontab -u www-data - + # Disable and remove webserver configs + a2dissite owncloud 2>/dev/null + rm /etc/apache2/sites-available/owncloud.conf 2>/dev/null + rm /etc/nginx/sites-dietpi/owncloud.config 2>/dev/null + # Find datadir for backups + G_DIETPI-NOTIFY 2 "DietPi will perform an automated backup of your ownCloud database and installation directory, which will be stored inside your ownCloud data directory.\nThe data directory won't be removed. So you can at any time recover your whole ownCloud instance.\nRemove the data directory manually, if you don't need it anymore." + local datadir=$(grep -m1 "'datadirectory'" /var/www/owncloud/config/config.php | awk '{print $3}' | sed "s/[',]//g") + [ -n "$datadir" ] || datadir="$G_FP_DIETPI_USERDATA/owncloud_data" + # Drop MariaDB user and database + systemctl start mysql + mysql -e "drop user $(grep -m1 "'dbuser'" /var/www/owncloud/config/config.php | awk '{print $3}' | sed "s/,//")@$(grep -m1 "'dbhost'" /var/www/owncloud/config/config.php | awk '{print $3}' | sed "s/,//")" + mysql -e "drop user $(grep -m1 "'dbuser'" /var/www/owncloud/config/config.php | awk '{print $3}' | sed "s/,//")" 2> /dev/null + [ -d "$G_FP_DIETPI_USERDATA"/mysql/owncloud ] && mysqldump owncloud > "$datadir"/dietpi-owncloud-database-backup.sql + mysqladmin drop owncloud -f + # Backup ownCloud installation folder + cp -a /var/www/owncloud/. "$datadir"/dietpi-owncloud-installation-backup + # Remove ownCloud installation folder + rm -R /var/www/owncloud + + elif (( $index == 114 )); then + #Nextcloud + crontab -u www-data -l | grep -v '/var/www/nextcloud/cron.php' | crontab -u www-data - + # Disable and remove webserver configs + a2dissite nextcloud 2>/dev/null + rm /etc/apache2/sites-available/nextcloud.conf 2>/dev/null + rm /etc/nginx/sites-dietpi/nextcloud.config 2>/dev/null + lighttpd-disable-mod dietpi-nextcloud 2>/dev/null + rm /etc/lighttpd/conf-available/99-dietpi-nextcloud.conf 2>/dev/null + # Find datadir for backups + G_DIETPI-NOTIFY 2 "DietPi will perform an automated backup of your Nextcloud database and installation directory, which will be stored inside your Nextcloud data directory.\nThe data directory won't be removed. So you can at any time recover your whole Nextcloud instance.\nRemove the data directory manually, if you don't need it anymore." + local datadir=$(grep -m1 "'datadirectory'" /var/www/nextcloud/config/config.php | awk '{print $3}' | sed "s/[',]//g") + [ -n "$datadir" ] || datadir="$G_FP_DIETPI_USERDATA/nextcloud_data" + # Drop MariaDB user and database + systemctl start mysql + mysql -e "drop user $(grep -m1 "'dbuser'" /var/www/nextcloud/config/config.php | awk '{print $3}' | sed "s/,//")@$(grep -m1 "'dbhost'" /var/www/nextcloud/config/config.php | awk '{print $3}' | sed "s/,//")" + mysql -e "drop user $(grep -m1 "'dbuser'" /var/www/nextcloud/config/config.php | awk '{print $3}' | sed "s/,//")" 2> /dev/null + [ -d "$G_FP_DIETPI_USERDATA"/mysql/nextcloud ] && mysqldump nextcloud > "$datadir"/dietpi-nextcloud-database-backup.sql + mysqladmin drop nextcloud -f + # Backup Nextcloud installation folder + cp -a /var/www/nextcloud/. "$datadir"/dietpi-nextcloud-installation-backup + # Remove Nextcloud installation folder + rm -R /var/www/nextcloud - AGP apache2 + elif (( $index == 83 )); then - elif (( $1 == 85 )); then + G_AGP apache2 - AGP nginx + elif (( $index == 85 )); then - elif (( $1 == 84 )); then + G_AGP nginx - AGP lighttpd + elif (( $index == 84 )); then - elif (( $1 == 86 || $i == 88 )); then + G_AGP lighttpd - AGP mysql-server + elif (( $index == 88 )); then - AGP mariadb-server mariadb-client + G_AGP mariadb-server + ### Also for MariaDB? # - custom confs - rm /etc/mysql/conf.d/reduce_resources.cnf - - # - Remove debian flag generated by mariaDB install that prevents mysql 5.5 being installed. - rm /var/lib/mysql/debian-* + #rm /etc/mysql/conf.d/reduce_resources.cnf # - SQL store - rm -R /var/lib/mysql - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/mysql + rm /var/lib/mysql &> /dev/null || rm -R /var/lib/mysql &> /dev/null #in case of symlink or folder + rm -R "$G_FP_DIETPI_USERDATA"/mysql - elif (( $1 == 87 )); then + elif (( $index == 87 )); then - AGP sqlite3 + G_AGP sqlite3 - elif (( $1 == 91 )); then + elif (( $index == 91 )); then - AGP "$PHP_APT_PACKAGE_NAME"-redis redis-server redis-tools + G_AGP "$PHP_APT_PACKAGE_NAME"-redis redis-server redis-tools - elif (( $1 == 89 )); then + elif (( $index == 89 )); then rm "$FP_PHP_BASE_DIR"/fpm/pool.d/www.conf rm "$FP_PHP_BASE_DIR"/mods-available/dietpi.ini 2> /dev/null - AGP "$PHP_APT_PACKAGE_NAME"-* libapache2-mod-"$PHP_APT_PACKAGE_NAME" + G_AGP "$PHP_APT_PACKAGE_NAME"-* libapache2-mod-"$PHP_APT_PACKAGE_NAME" rm /var/www/phpinfo.php rm /var/www/apc.php rm /var/www/opcache.php # temp php uploads, if it was created rm -R /var/tmp/php_upload_tmp 2> /dev/null - elif (( $1 == 90 )); then - - AGP phpmyadmin - - elif (( $1 == 54 )); then + elif (( $index == 90 )); then systemctl start mysql - mysqladmin -u root -p"$GLOBAL_PW" drop phpbb3 -f - rm -R /var/www/phpBB3 + mysqladmin drop phpmyadmin -f + mysql -e "drop user 'phpmyadmin'@'localhost'" + G_AGP phpmyadmin - elif (( $1 == 47 )); then - #ownCloud - # Remove occ command binary - rm /usr/local/bin/occ - # Remove background cron job - crontab -u www-data -l | grep -v '/var/www/owncloud/cron.php' | crontab -u www-data - - # Disable and remove webservier configs - a2dissite owncloud 2>/dev/null - rm /etc/apache2/sites-available/owncloud.conf 2>/dev/null - rm /etc/nginx/sites-dietpi/owncloud.config 2>/dev/null - # Drop MySQL/MariaDB user and database - systemctl start mysql - mysql -uroot -p"$GLOBAL_PW" -e "drop user $(grep -m1 "'dbuser'" /var/www/owncloud/config/config.php | awk '{print $3}' | sed "s/,//")@$(grep -m1 "'dbhost'" /var/www/owncloud/config/config.php | awk '{print $3}' | sed "s/,//")" - mysql -uroot -p"$GLOBAL_PW" -e "drop user $(grep -m1 "'dbuser'" /var/www/owncloud/config/config.php | awk '{print $3}' | sed "s/,//")" - mysqldump --lock-tables -uroot -p"$GLOBAL_PW" owncloud > "$FP_DIETPI_USERDATA_DIRECTORY"/owncloud_data/mysql_backup.sql - mysqladmin -u root -p"$GLOBAL_PW" drop owncloud -f - # Purge APT package - AGP owncloud-files owncloud owncloud-deps - # Remove ownCloud installation folder - rm -R /var/www/owncloud - # Remove ownCloud repo - rm /etc/apt/sources.list.d/owncloud.list 2> /dev/null + elif (( $index == 54 )); then - elif (( $1 == 114 )); then - #Nextcloud - # Remove occ command binary - rm /usr/local/bin/ncc - # Remove background cron job - crontab -u www-data -l | grep -v '/var/www/nextcloud/cron.php' | crontab -u www-data - - # Disable and remove webservier configs - a2dissite nextcloud 2>/dev/null - rm /etc/apache2/sites-available/nextcloud.conf 2>/dev/null - rm /etc/nginx/sites-dietpi/nextcloud.config 2>/dev/null - # Drop MySQL/MariaDB user and database systemctl start mysql - mysql -uroot -p"$GLOBAL_PW" -e "drop user $(grep -m1 "'dbuser'" /var/www/nextcloud/config/config.php | awk '{print $3}' | sed "s/,//")@$(grep -m1 "'dbhost'" /var/www/nextcloud/config/config.php | awk '{print $3}' | sed "s/,//")" - mysql -uroot -p"$GLOBAL_PW" -e "drop user $(grep -m1 "'dbuser'" /var/www/nextcloud/config/config.php | awk '{print $3}' | sed "s/,//")" - mysqldump --lock-tables -uroot -p"$GLOBAL_PW" nextcloud > "$FP_DIETPI_USERDATA_DIRECTORY"/nextcloud_data/mysql_backup.sql - mysqladmin -u root -p"$GLOBAL_PW" drop nextcloud -f - # Remove Nextcloud installation folder - rm -R /var/www/nextcloud + mysqladmin drop phpbb3 -f + mysql -e "drop user phpbb3@localhost" + rm -R /var/www/phpBB3 - elif (( $1 == 115 )); then + elif (( $index == 115 )); then - AGP webmin + G_RUN_CMD dpkg -P webmin - elif (( $1 == 32 )); then + elif (( $index == 32 )); then rm /usr/bin/ympd rm /etc/systemd/system/ympd.service - elif (( $1 == 128 )); then + elif (( $index == 128 )); then - AGP mpd libmpdclient2 + #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_DISTRO == 3 && $G_HW_ARCH != 3 )) && G_AGP mpd libmpdclient2 || G_RUN_CMD dpkg -P mpd libmpdclient2 userdel -f mpd &> /dev/null rm /lib/systemd/system/mpd.service - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/.mpd_cache + rm -R "$G_FP_DIETPI_USERDATA"/.mpd_cache - elif (( $1 == 121 )); then + elif (( $index == 121 )); then rm /etc/systemd/system/roonbridge.service rm -R /etc/roonbridge - elif (( $1 == 122 )); then + elif (( $index == 122 )); then rm /etc/systemd/system/node-red.service rm "$HOME"/.node-red - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/node-red + rm -R "$G_FP_DIETPI_USERDATA"/node-red + + userdel -f nodered - elif (( $1 == 123 )); then + elif (( $index == 123 )); then - AGP mosquitto - rm /etc/apt/sources.list.d/mosquitto-*.list + if (( $G_DISTRO > 4 )); then - elif (( $1 == 124 )); then + G_AGP mosquitto - AGP networkaudiod + else + + #apt-mark auto libssl1.0.0 + dpkg -P mosquitto + + fi - elif (( $1 == 125 )); then + elif (( $index == 124 )); then - AGP tomcat8 + #apt-mark auto gcc-6-base libstdc++6 &> /dev/null + G_RUN_CMD dpkg -P networkaudiod - elif (( $1 == 126 )); then + elif (( $index == 125 )); then - AGP openmediavault + G_AGP tomcat8 + + elif (( $index == 126 )); then + + G_AGP openmediavault rm /etc/apt/sources.list.d/openmediavault.list - elif (( $1 == 129 )); then + elif (( $index == 129 )); then rm -R /var/www/ompd systemctl start mysql - mysqladmin -u root -p"$GLOBAL_PW" drop ompd -f + mysqladmin drop ompd -f + mysql -e "drop user ompd@localhost" - elif (( $1 == 130 )); then + elif (( $index == 130 )); then - AGP python-pip python3-pip + G_AGP python-pip python3-pip - elif (( $1 == 131 )); then + elif (( $index == 131 )); then rm /etc/systemd/system/blynkserver.service rm -R /etc/blynkserver - elif (( $1 == 132 )); then + elif (( $index == 132 )); then rm /etc/systemd/system/aria2.service - rm /usr/local/bin/aria2c - rm -R /var/www/aria2 - elif (( $1 == 133 )); then + G_AGP aria2 + + elif (( $index == 133 )); then rm /etc/systemd/system/yacy.service rm -R /etc/yacy - elif (( $1 == 134 )); then + elif (( $index == 134 )); then + + #apt-mark auto libjpeg8 libpng12-0 libfontconfig1 &> /dev/null rm /etc/systemd/system/tonido.service @@ -13395,15 +12712,16 @@ _EOF_ rm "$HOME"/TonidoSync rm "$HOME"/TonidoSyncData - elif (( $1 == 135 )); then + elif (( $index == 135 )); then - AGP darkice icecast2 + G_AGP darkice icecast2 rm /etc/systemd/system/darkice.service - elif (( $1 == 136 )); then + elif (( $index == 136 )); then - AGP motion + #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 + (( $G_DISTRO > 3 )) && G_AGP motion || G_RUN_CMD dpkg -P motion rm -R /etc/motioneye @@ -13411,204 +12729,205 @@ _EOF_ pip uninstall -y motioneye - elif (( $1 == 137 )); then + elif (( $index == 137 )); then - AGP cloudprint-service - if (( $DISTRO == 3 )); then + G_AGP cloudprint-service + if (( $G_DISTRO == 3 )); then rm /etc/apt/sources.list.d/cloudprint.list - apt-get update + G_AGUP fi - elif (( $1 == 138 )); then + elif (( $index == 138 )); then rm -R /etc/vhusbd rm /etc/systemd/system/virtualhere.service - elif (( $1 == 139 )); then + elif (( $index == 139 )); then rm -R /etc/sabnzbd rm /etc/systemd/system/sabnzbd.service - elif (( $1 == 140 )); then + elif (( $index == 140 )); then - AGP libsdl2 libsdl2-image libsdl2-mixer libsdl2-net libsdl2-ttf libsmpeg2 + G_RUN_CMD dpkg -P libsdl2 libsdl2-image libsdl2-mixer libsdl2-net libsdl2-ttf libsmpeg2 - elif (( $1 == 141 )); then + elif (( $index == 141 )); then - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/spotify-connect-web + rm -R "$G_FP_DIETPI_USERDATA"/spotify-connect-web rm /etc/systemd/system/spotify-connect-web.service - elif (( $1 == 142 )); then + elif (( $index == 142 )); then rm -R /etc/couchpotato - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/couchpotato + rm -R "$G_FP_DIETPI_USERDATA"/couchpotato rm /etc/init.d/couchpotato #userdel -f couchpotato - elif (( $1 == 143 )); then + elif (( $index == 143 )); then systemctl start mysql - mysqladmin -u root -p"$GLOBAL_PW" drop koel -f + mysqladmin drop koel -f + mysql -e "drop user koel@localhost" rm -R /var/www/koel rm /etc/systemd/system/koel.service - elif (( $1 == 144 )); then + elif (( $index == 144 )); then - AGP nzbdrone + G_AGP nzbdrone rm /etc/systemd/system/sonarr.service rm /etc/apt/sources.list.d/sonarr.list - apt-get update + G_AGUP - elif (( $1 == 145 )); then + elif (( $index == 145 )); then rm -R /opt/Radarr rm /etc/systemd/system/radarr.service - elif (( $1 == 146 )); then + elif (( $index == 146 )); then rm -R /opt/plexpy - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/plexpy + rm -R "$G_FP_DIETPI_USERDATA"/plexpy rm /etc/systemd/system/plexpy.service - elif (( $1 == 147 )); then + elif (( $index == 147 )); then rm -R /opt/jackett rm /etc/systemd/system/jackett.service - elif (( $1 == 148 )); then + elif (( $index == 148 )); then - AGP mediacenter22 + G_AGP mediacenter22 - elif (( $1 == 149 )); then + elif (( $index == 149 )); then - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/nzbget + rm -R "$G_FP_DIETPI_USERDATA"/nzbget rm /etc/systemd/system/nzbget.service - elif (( $1 == 155 )); then + elif (( $index == 155 )); then - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/htpc-manager + rm -R "$G_FP_DIETPI_USERDATA"/htpc-manager rm /etc/systemd/system/htpc-manager.service - elif (( $1 == 150 )); then + elif (( $index == 150 )); then - #AGP mono-runtime #shared lib + #G_AGP mono-runtime #shared lib rm /etc/apt/sources.list.d/mono-xamarin.list - apt-get update + G_AGUP - elif (( $1 == 151 )); then + elif (( $index == 151 )); then - AGP nvidia-driver nvidia-xconfig libgl1-nvidia-glx:i386 + G_AGP nvidia-driver nvidia-xconfig libgl1-nvidia-glx:i386 - elif (( $1 == 152 )); then + elif (( $index == 152 )); then - AGP avahi-daemon + G_AGP avahi-daemon - elif (( $1 == 153 )); then + elif (( $index == 153 )); then - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/octoprint + rm -R "$G_FP_DIETPI_USERDATA"/octoprint rm $(which octoprint) rm -R "$HOME"/.octoprint rm /etc/systemd/system/octoprint.service - elif (( $1 == 154 )); then + elif (( $index == 154 )); then - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/roonserver + rm -R "$G_FP_DIETPI_USERDATA"/roonserver rm /etc/systemd/system/roonserver.service - elif (( $1 == 156 )); then + elif (( $index == 156 )); then - AGP steam + G_AGP steam rm -R "$HOME"/.steam - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/steam + rm -R "$G_FP_DIETPI_USERDATA"/steam - elif (( $1 == 119 )); then + elif (( $index == 119 )); then - AGP cava + G_AGP cava rm "$HOME/.config/cava/config" rm "$HOME/cava.psf" - elif (( $1 == 118 )); then + elif (( $index == 118 )); then - AGP mopidy + G_AGP mopidy rm /etc/apt/sources.list.d/mopidy.list pip uninstall -y Mopidy-MusicBox-Webclient Mopidy-Local-Images - elif (( $1 == 31 )); then + elif (( $index == 31 )); then - AGP kodi + G_AGP kodi #+Odroids - AGP kodi-odroid + G_AGP kodi-odroid rm /usr/share/applications/kodi.desktop rm ~/Desktop/kodi.desktop - elif (( $1 == 39 )); then + elif (( $index == 39 )); then - AGP minidlna + G_AGP minidlna - elif (( $1 == 51 )); then + elif (( $index == 51 )); then - AGP ibsdl1.2debian libsdl-net1.2 + G_AGP ibsdl1.2debian libsdl-net1.2 rm -R /usr/local/games/opentyrian rm /usr/share/applications/opentyrian.desktop rm ~/Desktop/opentyrian.desktop - elif (( $1 == 59 )); then + elif (( $index == 59 )); then - AGP gpac + G_AGP gpac rm -R /var/www/dietpicam rm /opt/vc/bin/raspimjpeg rm /usr/bin/raspimjpeg - rm /etc/dietpi/dietpi-software/services/raspimjpeg.service + rm /var/lib/dietpi/dietpi-software/services/raspimjpeg.service rm /etc/raspimjpeg - elif (( $1 == 45 )); then + elif (( $index == 45 )); then - AGP deluged deluge-web deluge-webui deluge-console - rm /etc/dietpi/dietpi-software/services/deluge.service + G_AGP deluged deluge-web deluge-webui deluge-console + rm /var/lib/dietpi/dietpi-software/services/deluge.service rm -R ~/.config/deluge - elif (( $1 == 94 )); then + elif (( $index == 94 )); then - AGP proftpd-basic + G_AGP proftpd-basic - elif (( $1 == 96 )); then + elif (( $index == 96 )); then - AGP samba samba-common-bin + G_AGP samba samba-common-bin - elif (( $1 == 95 )); then + elif (( $index == 95 )); then - AGP vsftpd + G_AGP vsftpd - elif (( $1 == 109 )); then + elif (( $index == 109 )); then - AGP nfs-kernel-server + G_AGP nfs-kernel-server - elif (( $1 == 67 )); then + elif (( $index == 67 )); then rm /usr/local/bin/noip2 rm /etc/systemd/system/noip2.service - elif (( $1 == 106 )); then + elif (( $index == 106 )); then rm -R /var/www/raspcontrol rm -R /etc/raspcontrol - elif (( $1 == 63 )); then + elif (( $index == 63 )); then rm -R /var/www/linuxdash - elif (( $1 == 93 )); then + elif (( $index == 93 )); then - AGP dnsmasq + G_AGP dnsmasq pihole uninstall #https://github.com/Fourdee/DietPi/issues/753 @@ -13622,12 +12941,12 @@ _EOF_ rm /var/www/pihole rm /var/www/admin - elif (( $1 == 33 || $1 == 34 )); then + elif (( $index == 33 || $index == 34 )); then - AGP subsonic + G_RUN_CMD dpkg -P subsonic rm -R /var/subsonic - elif (( $1 == 71 )); then + elif (( $index == 71 )); then update-rc.d webiopi remove rm -R /etc/webiopi @@ -13635,7 +12954,7 @@ _EOF_ rm /usr/bin/webiopi rm /etc/init.d/webiopi - elif (( $1 == 68 )); then + elif (( $index == 68 )); then # <= v150 (weaved) rm -R /etc/weaved @@ -13643,9 +12962,9 @@ _EOF_ rm "$HOME"/weaved_setup.bin # Remot3.it - AGP weavedconnectd + G_RUN_CMD dpkg -P weavedconnectd - elif (( $1 == 62 )); then + elif (( $index == 62 )); then #Kill systemctl stop dietpi-cloudshell @@ -13657,10 +12976,7 @@ _EOF_ #Disable auto login, revert boot index to console /DietPi/dietpi/dietpi-autostart 0 - #Remove alias - sed -i '/dietpi-cloudshell=/d' /etc/bash.bashrc - - elif (( $1 == 98 )); then + elif (( $index == 98 )); then update-rc.d haproxy remove rm /etc/init.d/haproxy @@ -13668,26 +12984,31 @@ _EOF_ rm -r /etc/haproxy #Shared dev libraries. Leave these installed - #AGP libpcre3-dev libssl-dev + #G_AGP libpcre3-dev libssl-dev - elif (( $1 == 35 )); then + elif (( $index == 35 )); then - AGP logitechmediaserver - rm /etc/dietpi/dietpi-software/services/squeezeboxserver.service + #apt-mark auto libxml-parser-perl zlib1g-dev libjpeg-dev libpng-dev libjpeg62-turbo-dev &> /dev/null + G_RUN_CMD dpkg -P logitechmediaserver + rm /var/lib/dietpi/dietpi-software/services/squeezeboxserver.service rm -R /var/lib/squeezeboxserver rm -R /usr/share/squeezeboxserver - elif (( $1 == 55 )); then + elif (( $index == 55 )); then + + systemctl start mysql + mysqladmin drop wordpress -f + mysql -e "drop user wordpress@localhost" rm -R /var/www/wordpress - elif (( $1 == 27 || $1 == 28 || $1 == 120 )); then + elif (( $index == 27 || $index == 28 || $index == 120 )); then - AGP tightvncserver - AGP vnc4server - AGP x11vnc - AGP realvnc-vnc-server - AGP tigervnc-* + G_AGP tightvncserver + G_AGP vnc4server + G_AGP x11vnc + G_AGP realvnc-vnc-server + G_AGP tigervnc-* rm /etc/systemd/system/vncserver.service rm /etc/init.d/vncserver @@ -13700,66 +13021,68 @@ _EOF_ systemctl disable vncserver-x11-serviced.service systemctl disable vncserver-virtuald.service - elif (( $1 == 73 )); then + elif (( $index == 73 )); then - AGP fail2ban + G_AGP fail2ban - elif (( $1 == 64 )); then + elif (( $index == 64 )); then rm -R /var/www/phpsysinfo - elif (( $1 == 56 )); then + elif (( $index == 56 )); then rm /var/www/gallery/index.php rm -R /var/www/gallery/_sfpg_data - elif (( $1 == 40 )); then + elif (( $index == 40 )); then rm -R /var/www/ampache #drop database systemctl start mysql - mysqladmin -u root -p"$GLOBAL_PW" drop ampache -f + mysqladmin drop ampache -f + mysql -e "drop user ampache@localhost" - elif (( $1 == 117 )); then + elif (( $index == 117 )); then rm /etc/apt/sources.list.d/swupdate.openvpn.net.list pivpn -u userdel -f pivpn - elif (( $1 == 97 )); then + elif (( $index == 97 )); then - AGP openvpn + G_AGP openvpn rm -R /etc/openvpn &> /dev/null - elif (( $1 == 92 )); then + elif (( $index == 92 )); then - if (( $DISTRO >= 4 )); then + if (( $G_DISTRO >= 4 )); then - AGP python-certbot-apache python-certbot-nginx certbot + G_AGP python-certbot-apache python-certbot-nginx certbot fi rm -R /etc/letsencrypt_scripts &>/dev/null rm -R /etc/certbot_scripts &>/dev/null - elif (( $1 == 69 )); then + elif (( $index == 69 )); then - AGP python-rpi.gpio python3-rpi.gpio + G_AGP python-rpi.gpio python3-rpi.gpio - elif (( $1 == 72 )); then + elif (( $index == 72 )); then - AGP i2c-tools + G_AGP i2c-tools #Disable /DietPi/dietpi/func/dietpi-set_hardware i2c disable - elif (( $1 == 70 )); then + elif (( $index == 70 )); then rm -R /root/wiringPi* &> /dev/null - elif (( $1 == 60 )); then + elif (( $index == 60 )); then - AGP hostapd isc-dhcp-server + #apt-mark auto libssl1.0.0 &> /dev/null + G_AGP hostapd isc-dhcp-server rm /etc/dhcp/dhcpd.conf &> /dev/null rm /etc/hostapd/hostapd.conf &> /dev/null @@ -13795,63 +13118,71 @@ _EOF_ iptables -t nat -F iptables-save > /etc/iptables.ipv4.nat - elif (( $1 == 61 )); then + elif (( $index == 61 )); then - AGP tor + G_AGP tor # - uninstall WIFIHOTSPOT ALSO. Due to IPtables needing reset. Uninstall_Software 60 - elif (( $1 == 37 )); then + elif (( $index == 37 )); then - AGP shairport-sync* + #apt-mark auto libssl1.0.0 openssl libsoxr0 libavahi-client3 libtool libconfig9 libpopt0 libdaemon0 &> /dev/null + #No package is installed anymore, files are directly extracted into places, need to remove them manually? + #https://github.com/Fourdee/DietPi/blob/testing/dietpi/dietpi-software#L5968 + #G_RUN_CMD dpkg -P shairport-sync + rm /lib/systemd/system/shairport-sync.service /usr/local/bin/shairport-sync /usr/local/etc/shairport-sync.conf* /usr/local/share/man/man7/shairport-sync.7.gz &> /dev/null userdel -f shairport-sync - elif (( $1 == 38 )); then + elif (( $index == 38 )); then - AGP brutefir + G_AGP brutefir rm -R /etc/BruteFIR - rm /etc/dietpi/dietpi-software/services/brutefir.service + rm /var/lib/dietpi/dietpi-software/services/brutefir.service rm /etc/asound.conf rm /etc/modules-load.d/brutefir-alsa-loopback.conf rm /etc/modprobe.d/brutefir-alsa-loopback.conf - elif (( $1 == 48 )); then + elif (( $index == 48 )); then rm -R /var/www/pydio #drop database systemctl start mysql - mysqladmin -u root -p"$GLOBAL_PW" drop pydio -f + mysqladmin drop pydio -f + mysql -e "drop user pydio@localhost" - elif (( $1 == 36 )); then + elif (( $index == 36 )); then - AGP squeezelite + G_AGP squeezelite rm -R /usr/bin/squeezelite* rm /etc/systemd/system/squeezelite.service - elif (( $1 == 99 )); then + elif (( $index == 99 )); then rm -R /etc/emonhub rm /etc/init.d/emonhub rm /etc/default/emonhub - elif (( $1 == 66 )); then + elif (( $index == 66 )); then - AGP rpimonitor + G_RUN_CMD dpkg -P rpimonitor - elif (( $1 == 57 )); then + elif (( $index == 57 )); then rm -R /var/www/baikal #drop database systemctl start mysql - mysqladmin -u root -p"$GLOBAL_PW" drop baikal -f + mysqladmin drop baikal -f + mysql -e "drop user baikal@localhost" + + elif (( $index == 65 )); then - elif (( $1 == 65 )); then + #apt-mark auto zlib1g-dev &> /dev/null #all rm /etc/systemd/system/netdata.service @@ -13860,7 +13191,7 @@ _EOF_ groupdel netdata #1.2.0+ - AGP netdata + G_RUN_CMD dpkg -P netdata #1.0.0 rm /usr/sbin/netdata @@ -13871,35 +13202,37 @@ _EOF_ rm -R /var/cache/netdata rm -R /var/log/netdata - elif (( $1 == 43 )); then + elif (( $index == 43 )); then - AGP mumble-server + G_AGP mumble-server - elif (( $1 == 41 )); then + elif (( $index == 41 )); then - AGP emby-server + G_AGP emby-server embymagick rm /etc/apt/sources.list.d/emby-server.list - apt-get update + G_AGUP - elif (( $1 == 58 )); then + elif (( $index == 58 )); then rm -R /etc/openbazaar-server rm /etc/systemd/system/openbazaar.service - elif (( $1 == 42 )); then + elif (( $index == 42 )); then - AGP plexmediaserver + (( $G_HW_ARCH == 10 )) && G_RUN_CMD dpkg -P plexmediaserver plexmediaserver-installer || G_AGP plexmediaserver* + + rm -R /var/lib/plexmediaserver rm /etc/apt/sources.list.d/plex.list &> /dev/null - apt-get update + G_AGUP - elif (( $1 == 52 )); then + elif (( $index == 52 )); then rm -R /etc/cuberite rm /etc/systemd/system/cuberite.service - elif (( $1 == 53 )); then + elif (( $index == 53 )); then rm -R "$USERDATA_DIRECTORY"/mineos rm -R /var/games/minecraft @@ -13911,7 +13244,7 @@ _EOF_ userdel -f mineos - elif (( $1 == 49 )); then + elif (( $index == 49 )); then rm -R /etc/gogs rm /etc/systemd/system/gogs.service @@ -13920,30 +13253,31 @@ _EOF_ rm /var/log/gogs.log systemctl start mysql - mysqladmin -u root -p"$GLOBAL_PW" drop gogs -f + mysqladmin drop gogs -f + mysql -e "drop user gogs@localhost" - elif (( $1 == 46 )); then + elif (( $index == 46 )); then - AGP qbittorrent-nox + G_AGP qbittorrent-nox rm /etc/systemd/system/qbittorrent.service rm -R "$HOME"/.config/qBittorrent - elif (( $1 == 50 )); then + elif (( $index == 50 )); then rm -R /etc/syncthing rm /usr/bin/syncthing &> /dev/null # DietPi v158 <= rm /etc/systemd/system/syncthing.service - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/syncthing + rm -R "$G_FP_DIETPI_USERDATA"/syncthing - elif (( $1 == 116 )); then + elif (( $index == 116 )); then rm /etc/systemd/system/sickrage.service rm -R /etc/sickrage - elif (( $1 == 107 )); then + elif (( $index == 107 )); then - AGP rtorrent + G_AGP rtorrent rm -R /var/www/rutorrent rm "$HOME"/.rtorrent.rc rm /etc/systemd/system/rtorrent.service @@ -13961,7 +13295,7 @@ _EOF_ # apache2 rm /etc/apache2/sites-available/rutorrent.conf - elif (( $1 == 108 )); then + elif (( $index == 108 )); then rm -R /etc/amiberry rm /etc/systemd/system/amiberry.service @@ -13970,12 +13304,11 @@ _EOF_ #Disable autostart, revert boot index to console /DietPi/dietpi/dietpi-autostart 0 - elif (( $1 == 112 )); then + elif (( $index == 112 )); then - rm "$FP_DIETPI_USERDATA_DIRECTORY"/dxx-rebirth/* - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/dxx-rebirth/descent_1_game - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/dxx-rebirth/descent_2_game - sed -i '/dxx-rebirth/d' /etc/bash.bashrc + rm "$G_FP_DIETPI_USERDATA"/dxx-rebirth/* + rm -R "$G_FP_DIETPI_USERDATA"/dxx-rebirth/descent_1_game + rm -R "$G_FP_DIETPI_USERDATA"/dxx-rebirth/descent_2_game #Remove symlinks rm "$HOME"/.d1x-rebirth @@ -13983,16 +13316,17 @@ _EOF_ rm "$HOME"/Desktop/dxx-rebirth.desktop rm /usr/share/applications/dxx-rebirth.desktop - elif (( $1 == 113 )); then + elif (( $index == 113 )); then + #apt-mark auto libgnome-keyring0 libnspr4 libnss3 libnss3-1d libspeechd2 libxslt1.1 libxss1 xdg-utils libgnome-keyring-common libltdl7 &> /dev/null apt-mark unhold chromium chromedriver rm /etc/chromium.d/custom_flags rm "$HOME"/.chromium-browser.init - AGP chromium + (( $G_DISTRO >=4 )) && G_AGP chromium* || G_RUN_CMD dpkg -P chromium chromedriver - elif (( $1 == 157)); then + elif (( $index == 157)); then # Remove installationof HA. rm -R /srv/homeassistant @@ -14004,48 +13338,48 @@ _EOF_ # Remove the service. rm /etc/systemd/system/home-assistant.service - elif (( $1 == 165 )); then + elif (( $index == 165 )); then # Delete systemd files rm /etc/systemd/system/gitea.service # Delete data - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/gitea + rm -R "$G_FP_DIETPI_USERDATA"/gitea rm -R /var/log/gitea # drop/delete database systemctl start mysql - mysqladmin -u root -p"$GLOBAL_PW" drop gitea -f - systemctl stop mysql + mysqladmin drop gitea -f + mysql -e "drop user gitea@localhost" - elif (( $1 == 166 )); then + elif (( $index == 166 )); then rm /etc/systemd/system/pi-spc.service - rm -R /etc/dietpi/audiophonics/pi-spc + rm -R /var/lib/dietpi/dietpi-software/installed/pi-spc - elif (( $1 == 167 )); then + elif (( $index == 167 )); then - AGP raspotify + G_AGP raspotify rm /etc/apt/sources.list.d/raspotify.list - apt-get update + G_AGUP - elif (( $1 == 168 )); then + elif (( $index == 168 )); then echo -e "pending" - elif (( $1 == 169 )); then + elif (( $index == 169 )); then - rm -R "$FP_DIETPI_USERDATA_DIRECTORY"/voice-recognizer-raspi + rm -R "$G_FP_DIETPI_USERDATA"/voice-recognizer-raspi rm /etc/systemd/system/voice-recognizer.service rm /etc/systemd/system/alsa-init.service rm -R /home/dietpi/assistant.json - elif (( $1 == 170 )); then + elif (( $index == 170 )); then Reset_NTPD - AGP ntp + G_AGP ntp - elif (( $1 == 158 )); then + elif (( $index == 158 )); then # Remove service systemctl stop minio.service @@ -14059,7 +13393,7 @@ _EOF_ # Remove userdel userdel -r -f minio-user - elif (( $1 == 161 )); then + elif (( $index == 161 )); then /etc/init.d/bdd stop sleep 2 @@ -14073,22 +13407,22 @@ _EOF_ userdel -r bd - elif (( $1 == 162 )); then + elif (( $index == 162 )); then - if (( $HW_ARCH == 10 )); then + if (( $G_HW_ARCH == 10 )); then # remove docker and all its unused dependencies - x86_64 package name is different - AGP docker-ce + G_AGP docker-ce else # remove docker and all its unused dependencies - ARM package name - AGP docker-engine + G_AGP docker-engine fi # delete data files - dietpi - rm -r "$FP_DIETPI_USERDATA_DIRECTORY"/docker-data + rm -r "$G_FP_DIETPI_USERDATA"/docker-data # remove default unused folder rm -r /var/lib/docker - elif (( $1 == 164 )); then + elif (( $index == 164 )); then # Remove Service file rm /etc/systemd/system/nukkit.service @@ -14096,83 +13430,84 @@ _EOF_ # remove nukkit java file/folder rm -r /usr/local/bin/nukkit - elif (( $1 == 163 )); then + elif (( $index == 163 )); then - AGP gmrender + #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 + G_RUN_CMD dpkg -P gmrender rm /etc/systemd/system/gmrender.service - elif (( $1 == 159 || $1 == 160 )); then + elif (( $index == 159 || $index == 160 )); then rm -R /var/www/allo systemctl start mysql - mysqladmin -u root -p"$GLOBAL_PW" drop allo_db -f - systemctl stop mysql + mysqladmin drop allo_db -f + mysql -e "drop user allo_db@localhost" #---------------------------------------------------------------------- #LINUX SOFTWARE - elif (( $1 == 15 )); then + elif (( $index == 15 )); then - AGP tcpdump + G_AGP tcpdump - elif (( $1 == 14 )); then + elif (( $index == 14 )); then - AGP nload + G_AGP nload - elif (( $1 == 13 )); then + elif (( $index == 13 )); then - AGP mtr-tiny + G_AGP mtr-tiny - elif (( $1 == 11 )); then + elif (( $index == 11 )); then - AGP iptraf + G_AGP iptraf - elif (( $1 == 10 )); then + elif (( $index == 10 )); then - AGP iftop + G_AGP iftop - elif (( $1 == 19 )); then + elif (( $index == 19 )); then - AGP jed + G_AGP jed - elif (( $1 == 3 )); then + elif (( $index == 3 )); then - AGP mc + G_AGP mc - elif (( $1 == 18 )); then + elif (( $index == 18 )); then - AGP emacs + G_AGP emacs - elif (( $1 == 20 || $i == 21 )); then + elif (( $index == 20 || $i == 21 )); then - AGP vim vim-tiny + G_AGP vim vim-tiny - elif (( $1 == 127 )); then + elif (( $index == 127 )); then - AGP neovim + G_AGP neovim - elif (( $1 == 0 )); then + elif (( $index == 0 )); then #This also removes OpenSSH server. So lets check OpenSSH server isnt installed before hand. if (( $(dpkg -l | grep -ci -m1 'openssh-server') == 0 )); then - AGP openssh-client + G_AGP openssh-client fi - elif (( $1 == 1 )); then + elif (( $index == 1 )); then umount -f /mnt/samba - AGP smbclient + G_AGP smbclient #Disable in fstab sed -i '/\/mnt\/samba/c\#\/mnt\/samba . Please use dietpi-config and the Networking Options: NAS menu to setup this mount' /etc/fstab #Add info file for installation method. echo -e "Samba client can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking Options: NAS/Misc menu" > /mnt/samba/readme.txt - elif (( $1 == 111 )); then + elif (( $index == 111 )); then - AGP urbackup-server + G_RUN_CMD dpkg -P urbackup-server #+sourcebuild rm /etc/systemd/system/urbackupsrv.service @@ -14183,14 +13518,14 @@ _EOF_ rm /usr/bin/urbackupsrv rm -R /usr/share/urbackup - elif (( $1 == 110 )); then + elif (( $index == 110 )); then umount -f /mnt/nfs_client #nfs-kernel-server depends on nfs-common if (( ${aSOFTWARE_INSTALL_STATE[109]} == 0 )); then - AGP nfs-common + G_AGP nfs-common fi @@ -14200,30 +13535,28 @@ _EOF_ #Add info file for installation method. echo -e "NFS client can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking Options: NAS/Misc menu" > /mnt/nfs_client/readme.txt - elif (( $1 == 16 )); then - - AGP build-essential + elif (( $index == 16 )); then - elif (( $1 == 17 )); then + G_AGP build-essential - AGP git + elif (( $index == 17 )); then - elif (( $1 == 5 )); then + G_AGP git - AGP alsa-utils + elif (( $index == 5 )); then - #DietPi-JustBoom, remove bash alias for config panel: - sed -i '/dietpi-justboom/d' /etc/bash.bashrc &> /dev/null + G_AGP alsa-utils - elif (( $1 == 6 )); then + elif (( $index == 6 )); then - AGP xcompmgr xinit xauth xserver-xorg xfonts-base x11-xserver-utils x11-common x11-utils - rm /etc/xdg/autostart/xcompmgr.desktop + #apt-mark auto aml-libs-odroid mali450-odroid xf86-video-mali-odroid libump* xf86-video-fbturbo* firmware-samsung xf86-video-armsoc-odroid malit628-odroid &> /dev/null + G_AGP xcompmgr xterm xinit xauth xserver-xorg dbus-x11 xfonts-base x11-xserver-utils x11-common x11-utils + rm /etc/xdg/autostart/xcompmgr.desktop /etc/X11/xorg.conf &> /dev/null - elif (( $1 == 2 )); then + elif (( $index == 2 )); then umount -f /mnt/ftp_client - AGP curlftpfs + G_AGP curlftpfs #Disable in fstab sed -i '/\/mnt\/ftp_client/c\#\/mnt\/ftp_client . Please use dietpi-config and the Networking Options: NAS menu to setup this mount' /etc/fstab @@ -14231,62 +13564,62 @@ _EOF_ #Add info file for installation method. echo -e "FTP client mount can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking Options: NAS/Misc menu" > /mnt/ftp_client/readme.txt - elif (( $1 == 7 )); then + elif (( $index == 7 )); then - AGP ffmpeg - # + RPi - AGP libx264 libmp3lame libfdk-aac + G_AGP ffmpeg + # + RPi, use dpkg -P as packages were installed via dpkg -i and APT can produce error/terminate dietpi-software: + # https://github.com/Fourdee/DietPi/issues/1352#issuecomment-354552622 + (( $G_HW_MODEL < 10 )) && G_RUN_CMD dpkg -P libx264 libmp3lame libfdk-aac - elif (( $1 == 8 )); then + elif (( $index == 8 )); then - AGP oracle-java8-* - rm /etc/apt/sources.list.d/webupd8team-java.list - apt-get update + G_AGP openjdk-8-jdk + rm /etc/apt/preferences.d/99-dietpi-openjdk-8-jdk &> /dev/null - elif (( $1 == 104 )); then + elif (( $index == 104 )); then - AGP dropbear* #stretch | dropbear-initramfs dropbear-run + G_AGP dropbear* #stretch | dropbear-initramfs dropbear-run - elif (( $1 == 105 )); then + elif (( $index == 105 )); then - AGP openssh-* + G_AGP openssh-* # This also clears Openssh-client aSOFTWARE_INSTALL_STATE[0]=0 - elif (( $1 == 103 )); then + elif (( $index == 103 )); then sed -i '/\/var\/log/c\#\/var\/log DietPi Ramlog Disabled' /etc/fstab - elif (( $1 == 101 )); then + elif (( $index == 101 )); then - AGP logrotate + G_AGP logrotate - elif (( $1 == 102 )); then + elif (( $index == 102 )); then - AGP rsyslog + G_AGP rsyslog - elif (( $1 == 9 )); then + elif (( $index == 9 )); then - AGP nodejs + G_AGP nodejs # - old install via repo if [ -f /etc/apt/sources.list.d/nodesource_nodejs.list ]; then rm /etc/apt/sources.list.d/nodesource_nodejs.list - apt-get update + G_AGUP fi rm /usr/local/bin/node - elif (( $1 == 4 )); then + elif (( $index == 4 )); then - AGP vifm + G_AGP vifm else - /DietPi/dietpi/func/dietpi-notify 2 "Software index $1 is unknown, or, has no removal code." + G_DIETPI-NOTIFY 2 "Software index $index is unknown, or, has no removal code." valid_input=0 fi @@ -14299,17 +13632,22 @@ _EOF_ fi - echo -e "$1 | $(date)" >> /DietPi/dietpi/.uninstalled + echo -e "$index | $(date)" >> /DietPi/dietpi/.uninstalled #Update array installed state - aSOFTWARE_INSTALL_STATE[$1]=0 + aSOFTWARE_INSTALL_STATE[$index]=0 + + #---------------------------------------------------------------------- + #Reset error handler (eg: for usermsg clear) + G_ERROR_HANDLER_RESET + #---------------------------------------------------------------------- } Uninstall_Software_Finalize(){ #Purge - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Software "Removing packages that are no longer required" + G_DIETPI-NOTIFY 3 DietPi-Software "Removing packages that are no longer required" apt-get autoremove --purge -y @@ -14356,9 +13694,18 @@ _EOF_ #Disable powersaving on Main screen during installation setterm -blank 0 -powersave off 2> /dev/null #------------------------------------------------------------ + # Unmask all services: https://github.com/Fourdee/DietPi/issues/1320 + /DietPi/dietpi/dietpi-services unmask all # Stop Services /DietPi/dietpi/dietpi-services stop #------------------------------------------------------------ + #Generate Swapfile during 1st run (moved from boot: https://github.com/Fourdee/DietPi/issues/1270#issue-278797206) + if (( $G_DIETPI_INSTALL_STAGE == 0 )); then + + /DietPi/dietpi/func/dietpi-set_dphys-swapfile $(grep -m1 '^AUTO_SETUP_SWAPFILE_SIZE=' /DietPi/dietpi.txt | sed 's/.*=//') + + fi + #------------------------------------------------------------ #Generate userdata folders: Create_UserContent_Folders #------------------------------------------------------------ @@ -14370,31 +13717,23 @@ _EOF_ #Always clean and update apt, before running installs. apt-get clean - apt-get update + G_AGUP #Simluated apt installation to check for failures related to apt-cache. - /DietPi/dietpi/func/dietpi-notify 2 "Running apt simulation to check for errors, please wait..." - local package_to_test='bash-doc' - apt-get install $package_to_test -qq -s -y 2>&1 | tee "$FP_APT_LOG" - local result=${PIPESTATUS[0]} - - /DietPi/dietpi/func/dietpi-notify -1 $result "Apt simulation |" + G_DIETPI-NOTIFY 2 "Running apt simulation to check for errors, please wait..." - if (( $result != 0 )); then - - Error_AptGet_Failed simulation + local package_to_test='bash-doc' - fi + G_AGI $package_to_test -s #Upgrade Apt Banner_Setup Banner_Apt_Update - # - Set noninteractive | Allows automation for some software - DEBIAN_FRONTEND='noninteractive' apt-get upgrade -y --force-yes + G_AGUG #Generate dir for dietpi-software installed "non-service" based control scripts - mkdir -p /etc/dietpi/dietpi-software/services - chmod -R +x /etc/dietpi/dietpi-software/services + mkdir -p /var/lib/dietpi/dietpi-software/services + chmod -R +x /var/lib/dietpi/dietpi-software/services #Disable software installation, if user input is required for automated installs Install_Disable_Requires_UserInput @@ -14454,37 +13793,40 @@ _EOF_ Write_InstallFileList #DietPi-Automation - if (( $DIETPI_INSTALL_STAGE == 0 )); then + if (( $G_DIETPI_INSTALL_STAGE == 0 )); then #Apply Timezone if [ "$AUTOINSTALL_TIMEZONE" != "Europe/London" ]; then echo -e "\nDietPi: Setting Timezone = $AUTOINSTALL_TIMEZONE" - echo -e "$AUTOINSTALL_TIMEZONE" > /etc/timezone + rm /etc/timezone + rm /etc/localtime + ln -fs /usr/share/zoneinfo/$AUTOINSTALL_TIMEZONE /etc/localtime dpkg-reconfigure -f noninteractive tzdata fi #Apply Language (Locale) - if [ "$AUTOINSTALL_LANGUAGE" != "en_GB" ]; then + if [ "$AUTOINSTALL_LANGUAGE" != "en_GB.UTF-8" ]; then - /DietPi/dietpi/func/dietpi-notify 2 "Setting Locale $AUTOINSTALL_LANGUAGE. Please wait...\n" + G_DIETPI-NOTIFY 2 "Setting Locale $AUTOINSTALL_LANGUAGE. Please wait" - #Enable user setting - sed -i "/$AUTOINSTALL_LANGUAGE.UTF-8/c $AUTOINSTALL_LANGUAGE.UTF-8 UTF-8" /etc/locale.gen - echo -e "LANG=$AUTOINSTALL_LANGUAGE.UTF-8" > /etc/default/locale - echo -e "LC_ALL=$AUTOINSTALL_LANGUAGE.UTF-8" > /etc/environment #This prevents LC_* errors when checking locale on non-rpi devices. + # Sanity, No result, revert back to default + if [ -z "$AUTOINSTALL_LANGUAGE" ]; then - locale-gen + AUTOINSTALL_LANGUAGE='en_GB.UTF-8' - localectl set-locale LANG="$AUTOINSTALL_LANGUAGE.UTF-8" + fi + + # - Re-apply locale + auto install en_GB.UTF-8 alongside + /DietPi/dietpi/func/dietpi-set_software locale "$AUTOINSTALL_LANGUAGE" fi #Apply Keyboard if [ "$AUTOINSTALL_KEYBOARD" != "gb" ]; then - /DietPi/dietpi/func/dietpi-notify 2 "Setting Keyboard $AUTOINSTALL_KEYBOARD. Please wait...\n" + G_DIETPI-NOTIFY 2 "Setting Keyboard $AUTOINSTALL_KEYBOARD. Please wait...\n" sed -i '/XKBLAYOUT=/c XKBLAYOUT="'"$AUTOINSTALL_KEYBOARD"'"' /etc/default/keyboard #systemctl restart keyboard-setup @@ -14521,7 +13863,7 @@ _EOF_ INSTALL_URL_ADDRESS=$AUTOINSTALL_CUSTOMSCRIPTURL - /DietPi/dietpi/func/check_connection "$INSTALL_URL_ADDRESS" + G_CHECK_URL "$INSTALL_URL_ADDRESS" #Install if (( $? == 0 )); then @@ -14586,20 +13928,20 @@ _EOF_ FirstRun_Automation_Init(){ #Get settings - AUTOINSTALL_ENABLED=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_Install_Enable=' | sed 's/.*=//') + AUTOINSTALL_ENABLED=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_AUTOMATED=' | sed 's/.*=//') - AUTOINSTALL_AUTOSTARTTARGET=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_AutoStartTarget=' | sed 's/.*=//' ) + AUTOINSTALL_AUTOSTARTTARGET=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_AUTOSTART_TARGET_INDEX=' | sed 's/.*=//' ) - AUTOINSTALL_SSHINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_DietpiSoftware_SSHServerIndex=' | sed 's/.*=//') - AUTOINSTALL_FILESERVERINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_DietpiSoftware_FileServerIndex=' | sed 's/.*=//') - AUTOINSTALL_LOGGINGINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_DietpiSoftware_LoggingIndex=' | sed 's/.*=//') - AUTOINSTALL_WEBSERVERINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_DietpiSoftware_WebserverIndex=' | sed 's/.*=//') + AUTOINSTALL_SSHINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_SSH_SERVER_INDEX=' | sed 's/.*=//') + AUTOINSTALL_FILESERVERINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_FILE_SERVER_INDEX=' | sed 's/.*=//') + AUTOINSTALL_LOGGINGINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_LOGGING_INDEX=' | sed 's/.*=//') + AUTOINSTALL_WEBSERVERINDEX=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_WEB_SERVER_INDEX=' | sed 's/.*=//') - AUTOINSTALL_TIMEZONE=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_Timezone=' | sed 's/.*=//' ) - AUTOINSTALL_LANGUAGE=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_Locale=' | sed 's/.*=//' ) - AUTOINSTALL_KEYBOARD=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_KeyboardLayout=' | sed 's/.*=//' ) + AUTOINSTALL_TIMEZONE=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_TIMEZONE=' | sed 's/.*=//' ) + AUTOINSTALL_LANGUAGE=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_LOCALE=' | sed 's/.*=//' ) + AUTOINSTALL_KEYBOARD=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_KEYBOARD_LAYOUT=' | sed 's/.*=//' ) - AUTOINSTALL_CUSTOMSCRIPTURL=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_CustomScriptURL=' | sed 's/AUTO_CustomScriptURL=//') + AUTOINSTALL_CUSTOMSCRIPTURL=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_CUSTOM_SCRIPT_EXEC=' | sed 's/AUTO_SETUP_CUSTOM_SCRIPT_EXEC=//') } @@ -14608,7 +13950,7 @@ _EOF_ #Automated install if (( $AUTOINSTALL_ENABLED >= 1 )); then - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Software "Running automated installation" + G_DIETPI-NOTIFY 3 DietPi-Software "Running automated installation" #Skip dietpi-software menu TARGETMENUID=-1 @@ -14616,18 +13958,18 @@ _EOF_ #Set start install GOSTARTINSTALL=1 - #Find all software entires of AUTO_DietpiSoftware_Install_ID= in dietpi.txt. Then set to state 1 for installation. + #Find all software entires of AUTO_SETUP_INSTALL_SOFTWARE_ID= in dietpi.txt. Then set to state 1 for installation. while read -r line do - local index=$( echo -e "$line" | grep '^AUTO_DietpiSoftware_Install_ID=' | sed 's/[^0-9]*//g' ) + local index=$( echo -e "$line" | grep '^AUTO_SETUP_INSTALL_SOFTWARE_ID=' | sed 's/[^0-9]*//g' ) # - Flag for installation if [[ $index =~ ^-?[0-9]+$ ]]; then aSOFTWARE_INSTALL_STATE[$index]=1 - /DietPi/dietpi/func/dietpi-notify 2 "Automation: ${aSOFTWARE_WHIP_NAME[$index]}. Flagged for installation." + G_DIETPI-NOTIFY 2 "Automation: ${aSOFTWARE_WHIP_NAME[$index]}. Flagged for installation." fi @@ -14642,7 +13984,7 @@ _EOF_ INDEX_WEBSERVER_TARGET=$AUTOINSTALL_WEBSERVERINDEX # - IPversion preference: https://github.com/Fourdee/DietPi/issues/472 - /DietPi/dietpi/func/dietpi-set_hardware preferipversion "$(cat /DietPi/dietpi.txt | grep -m1 '^prefer_ipversion=' | sed 's/.*=//')" + /DietPi/dietpi/func/dietpi-set_hardware preferipversion "$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_PREFER_IPVERSION=' | sed 's/.*=//')" } @@ -14656,7 +13998,7 @@ _EOF_ echo 1 > /DietPi/dietpi/.update_stage #Update APT - apt-get update + G_AGUP #Check for updates and apply if needed (1=force apply updates). /DietPi/dietpi/dietpi-update 1 @@ -14668,7 +14010,7 @@ _EOF_ echo 1 > /DietPi/dietpi/.update_stage #Prompt user for reboot - if (( $USER_INPUTS )); then + if (( $G_USER_INPUTS )); then WHIP_TITLE='DietPi Update Completed' whiptail --title "$WHIP_TITLE" --msgbox "DietPi has been updated to the latest version.\nYour system will now reboot. Once completed, simply login to resume DietPi Setup. \n\nPress Enter to Continue." 13 65 @@ -14686,60 +14028,18 @@ _EOF_ #///////////////////////////////////////////////////////////////////////////////////// # Internet Connection Test Vars #///////////////////////////////////////////////////////////////////////////////////// - INTERNET_CONNECTED=0 #Use /etc/apt/sources.list for connection test - INTERNET_URL_TEST=$(cat /etc/apt/sources.list | grep -m1 'deb ' | awk '{print $2}') + INTERNET_URL_TEST=$(grep -m1 'deb ' /etc/apt/sources.list | awk '{print $2}') Check_Internet_Connection(){ - #Max loops for USER_INPUTS=0 - local max_loops=20 - local current_loop=0 - - INTERNET_CONNECTED=0 - while (( ! $INTERNET_CONNECTED )); do - - sleep 1 - - /DietPi/dietpi/func/check_connection "$INTERNET_URL_TEST" - - if (( $? == 0 )); then - - INTERNET_CONNECTED=1 - - elif (( $USER_INPUTS )); then - - Menu_No_Internet - - else - - if (( $current_loop >= $max_loops )); then - - /DietPi/dietpi/func/dietpi-notify 1 "Connection test failed. $INTERNET_URL_TEST" - Exit_Destroy - - else - - /DietPi/dietpi/func/dietpi-notify 2 "Testing connection to $INTERNET_URL_TEST" - /DietPi/dietpi/func/dietpi-notify 2 "Attempt ($current_loop / $max_loops), please wait..." - - fi - - ((current_loop++)) - - fi - - - done + G_CHECK_URL "$INTERNET_URL_TEST" #will exit on failure here } #///////////////////////////////////////////////////////////////////////////////////// # Globals #///////////////////////////////////////////////////////////////////////////////////// - #Enable all user inputs (eg: prompts) - USER_INPUTS=1 - Input_Modes(){ # - Skip menu @@ -14753,16 +14053,25 @@ _EOF_ #Install software and exit. if [ "$1" = "install" ] || [ "$1" = "reinstall" ] || [ "$1" = "uninstall" ] ; then - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Software "Automated $1" + G_DIETPI-NOTIFY 3 DietPi-Software "Automated $1" sleep 1 # - Make sure we have at least one entry if [ -z "$2" ]; then - /DietPi/dietpi/func/dietpi-notify 1 "Please enter a software index ID, or, choice system INDEX_*_TARGET=-?" + G_DIETPI-NOTIFY 1 "Please enter a software index ID, or, choice system INDEX_*_TARGET=-?" else + # - Uninstall | Stop services prior + if [ "$1" = "uninstall" ]; then + + # - stop services + /DietPi/dietpi/dietpi-services stop + + fi + + # - Process inputs for i in "${ainput[@]}" do @@ -14771,29 +14080,7 @@ _EOF_ if [ "$1" = "uninstall" ]; then - # - stop services - /DietPi/dietpi/dietpi-services stop - - for i in "${ainput[@]}" - do - - #Valid int means input is unique ID for software index - if [[ $i =~ ^-?[0-9]+$ ]]; then - - Uninstall_Software "$i" - - fi - - done - - #Finish up and clear non-required packages - Uninstall_Software_Finalize - - #Save - Write_InstallFileList - - # - Start services - /DietPi/dietpi/dietpi-services start + Uninstall_Software "$i" elif [ "$1" = "reinstall" ]; then @@ -14806,14 +14093,14 @@ _EOF_ aSOFTWARE_INSTALL_STATE[$i]=1 GOSTARTINSTALL=1 - /DietPi/dietpi/func/dietpi-notify 0 "Reinstalling ${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}" + G_DIETPI-NOTIFY 0 "Reinstalling ${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}" sleep 1 else - /DietPi/dietpi/func/dietpi-notify 2 "$i: ${aSOFTWARE_WHIP_NAME[$i]} is not currently installed" - /DietPi/dietpi/func/dietpi-notify 2 "The program must be installed, before reinstall can be used" - /DietPi/dietpi/func/dietpi-notify 0 "No changes applied for: ${aSOFTWARE_WHIP_NAME[$i]}" + G_DIETPI-NOTIFY 2 "$i: ${aSOFTWARE_WHIP_NAME[$i]} is not currently installed" + G_DIETPI-NOTIFY 2 "The program must be installed, before reinstall can be used" + G_DIETPI-NOTIFY 0 "No changes applied for: ${aSOFTWARE_WHIP_NAME[$i]}" fi @@ -14824,13 +14111,13 @@ _EOF_ aSOFTWARE_INSTALL_STATE[$i]=1 GOSTARTINSTALL=1 - /DietPi/dietpi/func/dietpi-notify 0 "Installing ${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}" + G_DIETPI-NOTIFY 0 "Installing ${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}" sleep 0.5 else - /DietPi/dietpi/func/dietpi-notify 2 "$i: ${aSOFTWARE_WHIP_NAME[$i]} is already installed" - /DietPi/dietpi/func/dietpi-notify 0 "No changes applied for: ${aSOFTWARE_WHIP_NAME[$i]}" + G_DIETPI-NOTIFY 2 "$i: ${aSOFTWARE_WHIP_NAME[$i]} is already installed" + G_DIETPI-NOTIFY 0 "No changes applied for: ${aSOFTWARE_WHIP_NAME[$i]}" fi @@ -14840,13 +14127,26 @@ _EOF_ done + # - Uninstall | Finish up and clear non-required packages + if [ "$1" = "uninstall" ]; then + + Uninstall_Software_Finalize + + #Save + Write_InstallFileList + + # - Start services + /DietPi/dietpi/dietpi-services start + + fi + fi #Apply permissions elif [ "$1" = "setpermissions" ]; then Install_Apply_Permissions &> /dev/null - /DietPi/dietpi/func/dietpi-notify 0 "Set permissions completed" + G_DIETPI-NOTIFY 0 "Set permissions completed" #List unique software names and ID's elif [ "$1" = "list" ]; then @@ -14939,17 +14239,17 @@ _EOF_ fi - # - Available for HW_ARCH? - if (( ! ${aSOFTWARE_AVAIL_HW_ARCH[$i,$HW_ARCH]} )); then + # - Available for G_HW_ARCH? + if (( ! ${aSOFTWARE_AVAIL_G_HW_ARCH[$i,$G_HW_ARCH]} )); then - string+=" \e[31mDISABLED for HW_ARCH\e[0m" + string+=" \e[31mDISABLED for G_HW_ARCH\e[0m" fi - # - Available for HW_MODEL? - if (( ! ${aSOFTWARE_AVAIL_HW_MODEL[$i,$HW_MODEL]} )); then + # - Available for G_HW_MODEL? + if (( ! ${aSOFTWARE_AVAIL_G_HW_MODEL[$i,$G_HW_MODEL]} )); then - string+=" \e[31mDISABLED for HW_MODEL\e[0m" + string+=" \e[31mDISABLED for G_HW_MODEL\e[0m" fi @@ -15022,14 +14322,14 @@ _EOF_ fp_target="$fp_export_dir/software_available_hw_model" for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++)) do - printf "%i\n" "${aSOFTWARE_AVAIL_HW_MODEL[$i,$HW_MODEL]}" >> "$fp_target" + printf "%i\n" "${aSOFTWARE_AVAIL_G_HW_MODEL[$i,$G_HW_MODEL]}" >> "$fp_target" done fp_target="$fp_export_dir/software_available_hw_arch" for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++)) do - printf "%i\n" "${aSOFTWARE_AVAIL_HW_ARCH[$i,$HW_ARCH]}" >> "$fp_target" + printf "%i\n" "${aSOFTWARE_AVAIL_G_HW_ARCH[$i,$G_HW_ARCH]}" >> "$fp_target" done @@ -15045,7 +14345,7 @@ _EOF_ else - /DietPi/dietpi/func/dietpi-notify 2 "Unknown command $1" + G_DIETPI-NOTIFY 2 "Unknown command $1" fi @@ -15070,7 +14370,7 @@ _EOF_ #Automation | Save to logfile - if (( $USER_INPUTS )); then + if (( $G_USER_INPUTS )); then whiptail --title "Error" --msgbox "$ERROR_TEXT" 18 70 @@ -15082,47 +14382,6 @@ _EOF_ } - Error_NoConnection_NoInstall(){ - - #Abort install - aSOFTWARE_INSTALL_STATE[$INSTALLING_INDEX]=0 - - ERROR_TEXT="Unable to Install ${aSOFTWARE_WHIP_NAME[$INSTALLING_INDEX]}: ${aSOFTWARE_WHIP_DESC[$INSTALLING_INDEX]}\n\n$INSTALL_URL_ADDRESS is offline and/or unreachable." - Error_Display - - } - - Error_AptGet_Failed(){ - - #*=apt installation failed - #simulation=apt simulation failed - - if [ "$1" = "simulation" ]; then - - ERROR_TEXT="Apt-get simulation has failed.\n - Apt log = $(echo -e $FP_APT_LOG)\n\nDietPi-Software will now exit." - Error_Display - - else - - ERROR_TEXT="Apt-get has failed:\n - Apt string = $string\n - Error code = $result\n - Software Title = ${aSOFTWARE_WHIP_NAME[$INSTALLING_INDEX]}: ${aSOFTWARE_WHIP_DESC[$INSTALLING_INDEX]}\n - Apt log = $(echo -e $FP_APT_LOG)\n\nPlease report this issue to DietPi (INCLUDING THE APT LOG) so it can be investigated.\n\nDietPi-Software will now exit." - Error_Display - - fi - - /DietPi/dietpi/func/dietpi-notify 1 "The apt cache may be corrupt, apt mirror offline, or you have held broken packages. DietPi-Software will now exit.\n" - - /DietPi/dietpi/func/dietpi-notify 2 "Apt Log:\n$(cat $FP_APT_LOG)\n" - - /DietPi/dietpi/func/dietpi-notify 2 "Please try:" - /DietPi/dietpi/func/dietpi-notify 2 "- Fixing apt package errors with 'apt-get install -f'" - /DietPi/dietpi/func/dietpi-notify 2 "- Change apt mirror: 'dietpi-config' > 'Networking: NAS/MISC' > 'Apt Mirror'" - /DietPi/dietpi/func/dietpi-notify 2 "- Clear and refresh apt 'apt-get update'" - /DietPi/dietpi/func/dietpi-notify 2 "- If problems persist, please create a Git ticket so DietPi can investigate the issue:\n - https://github.com/Fourdee/DietPi/issues\n" - - Exit_Destroy - - } - #///////////////////////////////////////////////////////////////////////////////////// # Whip menus #///////////////////////////////////////////////////////////////////////////////////// @@ -15158,13 +14417,13 @@ _EOF_ do #Check if this software matches the current category and sofware type for this menu. - # - I originally had "aSOFTWARE_AVAIL_HW_MODEL" and "aSOFTWARE_AVAIL_HW_ARCH" in one 'if' statement below, however, this seems to takes 4x longer to process in bash. + # - I originally had "aSOFTWARE_AVAIL_G_HW_MODEL" and "aSOFTWARE_AVAIL_G_HW_ARCH" in one 'if' statement below, however, this seems to takes 4x longer to process in bash. if (( ${aSOFTWARE_CATEGORY_INDEX[$j]} == $i && ${aSOFTWARE_TYPE[$j]} == $software_type )); then # + is available for hardware? # + is available for distro? - if (( ${aSOFTWARE_AVAIL_HW_MODEL[$j,$HW_MODEL]} && - ${aSOFTWARE_AVAIL_HW_ARCH[$j,$HW_ARCH]} )); then + if (( ${aSOFTWARE_AVAIL_G_HW_MODEL[$j,$G_HW_MODEL]} && + ${aSOFTWARE_AVAIL_G_HW_ARCH[$j,$G_HW_ARCH]} )); then local selected="off" @@ -15267,25 +14526,6 @@ _EOF_ } - Menu_No_Internet(){ - - #Ask to check settings, - whiptail --title "No Internet Connection!" --yesno "Internet access is required to start the DietPi Installation Program.\nWould you like to change your network settings and try again?\n\nIf problems persist:\n$INTERNET_URL_TEST may be offline and/or unreachable." --yes-button "Ok" --no-button "Exit" --defaultno --backtitle "$WHIP_BACKTITLE" 15 70 - CHOICE=$? - #run dietpi config - if (( $CHOICE == 0 )); then - whiptail --title "Launching DietPi-Config" --msgbox "DietPi-Config will now be started.\nUse the Network Options menu to change and test your network settings.\n\nWhen completed, Exit DietPi-Config to resume setup." --backtitle "Launching DietPi-Config" 14 60 - /DietPi/dietpi/dietpi-config 8 1 - #User aborted setup - else - Banner_Aborted - - #Exit Script NOW - Exit_Destroy - fi - - } - Menu_Main(){ #Data for storing SSH server index info @@ -15321,14 +14561,14 @@ _EOF_ Check_USB_Drive_Installed #Where is userdata stored? - local user_data_location_current=$(/DietPi/dietpi/func/dietpi-set_userdata return_source) + local user_data_location_current=$(readlink -f $G_FP_DIETPI_USERDATA) local user_data_location_description='' if [ "$user_data_location_current" = "$FP_DIETPI_DEDICATED_USBDRIVE" ]; then user_data_location_description="USB Drive | $user_data_location_current" - elif [ "$user_data_location_current" = "$FP_DIETPI_USERDATA_DIRECTORY" ]; then + elif [ "$user_data_location_current" = "$G_FP_DIETPI_USERDATA" ]; then user_data_location_description="SD/EMMC | $user_data_location_current" @@ -15351,7 +14591,7 @@ _EOF_ fi WHIP_TITLE='DietPi-Software' - WHIP_BACKTITLE="DietPi-Software | IP: $(sed -n 4p /DietPi/dietpi/.network) | Device: $HW_MODEL_DESCRIPTION" + WHIP_BACKTITLE="DietPi-Software | IP: $(sed -n 4p /DietPi/dietpi/.network) | Device: $G_HW_MODEL_DESCRIPTION" OPTION=$(whiptail --title "$WHIP_TITLE" --backtitle "$WHIP_BACKTITLE" --menu "" --default-item "$MENU_MAIN_LASTITEM" --cancel-button "Exit" 20 100 13 \ "Help!" "Links to online guides, docs and information" \ @@ -15576,7 +14816,7 @@ _EOF_ if (( $? == 0 )); then - whiptail --title "User data transfer: Completed" --msgbox "Your user data has been sucessfuly moved:\n\n - From: $user_data_location_current\n - To: $(/DietPi/dietpi/func/dietpi-set_userdata return_source)" 12 70 + whiptail --title "User data transfer: Completed" --msgbox "Your user data has been sucessfuly moved:\n\n - From: $user_data_location_current\n - To: $move_data_target" 12 70 else @@ -15736,7 +14976,7 @@ _EOF_ Menu_Exit(){ #1st run install - if (( $DIETPI_INSTALL_STAGE == 0 )); then + if (( $G_DIETPI_INSTALL_STAGE == 0 )); then WHIP_TITLE='Exit Setup?' WHIP_QUESTION=' DietPi has not fully been installed.\n This must be completed prior to using DietPi by selecting:\n - Go Start Install. \n \n Would you like to exit and abort the installation?' whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" --yes-button "Ok" --no-button "Back" --defaultno 13 65 @@ -15750,7 +14990,7 @@ _EOF_ TARGETMENUID=0 fi #Standard exit - elif (( $DIETPI_INSTALL_STAGE == 1 )); then + elif (( $G_DIETPI_INSTALL_STAGE == 1 )); then WHIP_TITLE='Exit DietPi-Software?' WHIP_QUESTION='Do you wish to exit DietPi-Software?\n\nAll changes to software selections will be cleared.' whiptail --title "$WHIP_TITLE" --yesno "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" --yes-button "Ok" --no-button "Back" --defaultno 11 65 @@ -15818,7 +15058,7 @@ _EOF_ else #1st run install - if (( $DIETPI_INSTALL_STAGE == 0 )); then + if (( $G_DIETPI_INSTALL_STAGE == 0 )); then WHIP_TITLE='No Software Selected. Continue?' WHIP_QUESTION='DietPi was unable to detect any software selections for install. Do you wish to continue?\n\nBy selecting Ok: \n- DietPi optimized software will NOT be installed.\nYou can use dietpi-software at a later date if you change your mind. \n\n- You want a Minimal Raspbian/Debian Server Install.\nDietPi is a minimal image. A great OS base to use with your projects.' @@ -15840,7 +15080,7 @@ _EOF_ fi #Not 1st run - elif (( $DIETPI_INSTALL_STAGE == 1 )); then + elif (( $G_DIETPI_INSTALL_STAGE == 1 )); then WHIP_TITLE='No Changes to Software Selection' whiptail --title "$WHIP_TITLE" --msgbox "No changes have been detected. Unable to start installation." 8 65 @@ -15935,7 +15175,7 @@ _EOF_ ( ${aSOFTWARE_INSTALL_STATE[80]} < 2 && ${aSOFTWARE_INSTALL_STATE[82]} < 2 ) )); then WHIP_TITLE='PhpMyAdmin' - WHIP_QUESTION="Due to a apt-get installation issue with PhpMyAdmin, you must have a fully installed Lighttpd + Mysql/MaridaDB webserver stack, before PhpMyAdmin can be selected for install.\n\nYour selection for PhpMyAdmin has been removed." + WHIP_QUESTION="Due to a apt-get installation issue with PhpMyAdmin, you must have a fully installed Lighttpd + MaridaDB webserver stack, before PhpMyAdmin can be selected for install.\n\nYour selection for PhpMyAdmin has been removed." whiptail --title "$WHIP_TITLE" --msgbox "$WHIP_QUESTION" --backtitle "$WHIP_BACKTITLE" 13 70 aSOFTWARE_INSTALL_STATE[90]=0 @@ -15956,7 +15196,7 @@ _EOF_ # - Enter API KEY # - Grab key from dietpi.txt - USER_EMONHUB_APIKEY_CURRENT=$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_emonhub_apikey=' | sed 's/.*=//') + USER_EMONHUB_APIKEY_CURRENT=$(cat /DietPi/dietpi.txt | grep -m1 '^SOFTWARE_EMONHUB_APIKEY=' | sed 's/.*=//') while (( $USER_EMONHUB_APIKEY_COMPLETED == 0 )); do @@ -15975,7 +15215,7 @@ _EOF_ if (( $CHOICE == 0 )); then # - update dietpi.txt so the value will be applied during installation. - sed -i "/^dietpi_emonhub_apikey=/c\dietpi_emonhub_apikey=$USER_EMONHUB_APIKEY_CURRENT" /DietPi/dietpi.txt + sed -i "/^SOFTWARE_EMONHUB_APIKEY=/c\SOFTWARE_EMONHUB_APIKEY=$USER_EMONHUB_APIKEY_CURRENT" /DietPi/dietpi.txt USER_EMONHUB_APIKEY_COMPLETED=1 @@ -16345,17 +15585,19 @@ _EOF_ Banner_Installing(){ - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Software "Install software" + G_DIETPI-NOTIFY 3 DietPi-Software "Installing ${aSOFTWARE_WHIP_NAME[$INSTALLING_INDEX]}: ${aSOFTWARE_WHIP_DESC[$INSTALLING_INDEX]}" - echo -e " ${aSOFTWARE_WHIP_NAME[$INSTALLING_INDEX]}: ${aSOFTWARE_WHIP_DESC[$INSTALLING_INDEX]}" - /DietPi/dietpi/func/dietpi-notify 2 "Please wait...\n" - /DietPi/dietpi/dietpi-funtime 0 + } + + Banner_Configuration(){ + + G_DIETPI-NOTIFY 3 DietPi-Software "Configuring ${aSOFTWARE_WHIP_NAME[$INSTALLING_INDEX]}: ${aSOFTWARE_WHIP_DESC[$INSTALLING_INDEX]}" } Banner_Apt_Update(){ - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Software "Update & upgrade APT" + G_DIETPI-NOTIFY 3 DietPi-Software "Update & upgrade APT" sleep 1 } @@ -16364,46 +15606,31 @@ _EOF_ if (( ! $DISABLE_REBOOT )); then - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Software "Installation completed" - echo -e "\n The system will now reboot. \n This completes the DietPi-Software installation.\n" - /DietPi/dietpi/dietpi-funtime 0 + G_DIETPI-NOTIFY 3 DietPi-Software "Installation completed" + G_DIETPI-NOTIFY 0 "The system will now reboot. \n This completes the DietPi-Software installation.\n" sleep 3 else - /DietPi/dietpi/func/dietpi-notify 0 "DietPi-Software installation completed." + G_DIETPI-NOTIFY 0 "DietPi-Software installation completed." fi } Banner_Configs(){ - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Software "Optimize and configure software" - /DietPi/dietpi/func/dietpi-notify 2 "Applying DietPi optimizations and configurations for $HW_MODEL_DESCRIPTION" - /DietPi/dietpi/func/dietpi-notify 2 "Please wait...\n" - /DietPi/dietpi/dietpi-funtime 0 - - #List software due for configuration - # for ((i=0; i<$TOTAL_SOFTWARE_INDEXS; i++)) - # do - - # if (( ${aSOFTWARE_INSTALL_STATE[$i]} == 1 )); then - - # /DietPi/dietpi/func/dietpi-notify 2 "${aSOFTWARE_WHIP_NAME[$i]}: ${aSOFTWARE_WHIP_DESC[$i]}" - - # fi - - # done + G_DIETPI-NOTIFY 3 DietPi-Software "Optimize and configure software" + G_DIETPI-NOTIFY 2 "Applying DietPi optimizations and configurations for $G_HW_MODEL_DESCRIPTION, please wait...\n" } Banner_Aborted(){ #1st run abort - if (( $DIETPI_INSTALL_STAGE == 0 )); then + if (( $G_DIETPI_INSTALL_STAGE == 0 )); then /DietPi/dietpi/dietpi-banner 0 - echo -e "\n Installation Aborted by User \n Installation must be completed prior to using DietPi \n Please run dietpi-software to restart the installation \n" + G_DIETPI-NOTIFY 1 "\n Installation Aborted by User \n Installation must be completed prior to using DietPi \n Please run dietpi-software to restart the installation \n" #Standard abort else @@ -16418,7 +15645,7 @@ _EOF_ # Main Loop #///////////////////////////////////////////////////////////////////////////////////// #-------------------------------------------------------------------------------------- - /DietPi/dietpi/func/dietpi-notify 2 "Initializing database, please wait..." + G_DIETPI-NOTIFY 2 "Initializing database, please wait..." #-------------------------------------------------------------------------------------- #Init software arrays @@ -16432,9 +15659,6 @@ _EOF_ # - CLi input mode if [ -n "$1" ]; then - # - Disable user inputs and prompts. - USER_INPUTS=0 - # - Run input mode Input_Modes "$@" @@ -16444,21 +15668,14 @@ _EOF_ #Check if we are setting no user inputs and prompts # - Load all automation vars - if (( $DIETPI_INSTALL_STAGE == 0 )); then + if (( $G_DIETPI_INSTALL_STAGE == 0 )); then FirstRun_Automation_Init - if (( $AUTOINSTALL_ENABLED >= 1 )); then - - # - Disable user inputs and prompts. - USER_INPUTS=0 - - fi - fi #GPL compliance prompt - if (( $DIETPI_INSTALL_STAGE == 0 && $USER_INPUTS )); then + if (( $G_DIETPI_INSTALL_STAGE == 0 && $G_USER_INPUTS )); then whiptail --title "DietPi - GPLv2 License" --msgbox "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.\n\nThis 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.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see http://www.gnu.org/licenses/" --backtitle "DietPi - GPLv2 Compliance" 18 70 @@ -16479,8 +15696,8 @@ _EOF_ fi - #Apply 1st run automation and ask questions. - if (( $DIETPI_INSTALL_STAGE == 0 )); then + #Apply 1st run automation + if (( $G_DIETPI_INSTALL_STAGE == 0 )); then #Activate automation settings from dietpi.txt, if set. FirstRun_Automation_Set @@ -16528,27 +15745,24 @@ _EOF_ Check_Internet_Connection - if (( $INTERNET_CONNECTED == 1 )); then - - #Start installations for software - Run_Installations - - #Upload DietPi-Survey Data - /DietPi/dietpi/dietpi-survey &> /dev/null + #Start installations for software + Run_Installations - #Reboot - Banner_Reboot + #Upload DietPi-Survey Data + /DietPi/dietpi/dietpi-survey &> /dev/null - if (( $DISABLE_REBOOT )); then + #Reboot + Banner_Reboot - # - Start services - /DietPi/dietpi/dietpi-services start + if (( $DISABLE_REBOOT )); then - else + # - Start services + /DietPi/dietpi/dietpi-services start - reboot + else - fi + sync + reboot fi diff --git a/dietpi/dietpi-survey b/dietpi/dietpi-survey index 1e39675856..2ca1b714c5 100644 --- a/dietpi/dietpi-survey +++ b/dietpi/dietpi-survey @@ -22,19 +22,19 @@ # $FILENAME_FORMAT.txt #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + export G_PROGRAM_NAME='DietPi-Survey' + G_CHECK_ROOT_USER + #Import DietPi-Globals --------------------------------------------------------------- - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - SURVEY_VERSION=3 + SURVEY_VERSION=4 SURVEY_SENTCOUNT=1 OPTED_IN=1 - DIETPI_VERSION=$(cat /DietPi/dietpi/.version) - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) + DIETPI_VERSION="$(sed -n 1p /DietPi/dietpi/.version).$(sed -n 2p /DietPi/dietpi/.version)" + G_HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) UNIQUE_ID=$(sed -n 5p /DietPi/dietpi/.hw_model) FTP_ADDR="dietpi.com" @@ -42,7 +42,7 @@ FTP_PASS="raspberry13" Update_FileName_Format(){ - FILENAME_FORMAT="$SURVEY_VERSION-$UNIQUE_ID-$DIETPI_VERSION-$HW_MODEL.txt" + FILENAME_FORMAT="$SURVEY_VERSION-$UNIQUE_ID-$DIETPI_VERSION-$G_HW_MODEL.txt" } FP_SETTINGS="/DietPi/dietpi/.dietpi-survey" @@ -66,11 +66,14 @@ _EOF_ #///////////////////////////////////////////////////////////////////////////////////// #Read data from .dietpi-survey file if [ -f "$FP_SETTINGS" ]; then + Read_Settings #Create new file + generate UUID else + Write_Settings + fi #----------------------------------------------------------------------------------- @@ -78,7 +81,7 @@ _EOF_ if (( $OPTED_IN == 1 )); then #Check if we have a working internet connection beforehand - /DietPi/dietpi/func/check_connection "$FTP_ADDR" + G_CHECK_URL "$FTP_ADDR" if (( $? == 0 )); then #Obtain active network adapter. @@ -94,15 +97,15 @@ _EOF_ cat << _EOF_ > "$FILENAME_FORMAT" ------------------------- -DietPi-Survey V$SURVEY_VERSION +DietPi-Survey v$SURVEY_VERSION ------------------------- Upload Count : $SURVEY_SENTCOUNT -DietPi Version : $(cat /DietPi/dietpi/.version) +DietPi Version : $DIETPI_VERSION Mac Address : $( ifconfig -a | grep -m1 "$active_network_adapter" | awk '{print $NF}' | sed 's/://g') -Hardware Index : $(sed -n 1p /DietPi/dietpi/.hw_model) -Hardware Name : $(sed -n 2p /DietPi/dietpi/.hw_model) -Distro Index : $(sed -n 3p /DietPi/dietpi/.hw_model) +Hardware Index : $G_HW_MODEL +Hardware Name : $G_HW_MODEL_DESCRIPTION +Distro Index : $G_DISTRO Autoboot Index : $(cat /DietPi/dietpi/.dietpi-autostart_index) Country : $(curl --max-time 4 -s http://whatismycountry.com/ | sed -n 's|.*,\(.*\)|\1|p') Hostname : $(cat /etc/hostname) @@ -110,7 +113,7 @@ Hostname : $(cat /etc/hostname) ------------------------- DietPi-Software Installed ------------------------- -$(cat /DietPi/dietpi/.installed) +$(cat /DietPi/dietpi/.installed | grep ' =2 ') ------------------------- FileSystem @@ -132,6 +135,6 @@ _EOF_ fi #----------------------------------------------------------------------------------- - exit + exit 0 #----------------------------------------------------------------------------------- } \ No newline at end of file diff --git a/dietpi/dietpi-sync b/dietpi/dietpi-sync index cd389e73d0..977bcf3125 100644 --- a/dietpi/dietpi-sync +++ b/dietpi/dietpi-sync @@ -17,34 +17,19 @@ # - /DietPi/dietpi/dietpi-sync 1 = Sync #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Exit path for non-root logins. - if (( $UID != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit - - fi - - #RootFS RW check - /DietPi/dietpi/dietpi-drive_manager 3 - if (( $? != 0 )); then - - exit - - fi - #Grab Input (valid interger) INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then INPUT=$1 fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Sync' + #Import DietPi-Globals --------------------------------------------------------------- + #///////////////////////////////////////////////////////////////////////////////////// # MENUS #///////////////////////////////////////////////////////////////////////////////////// @@ -55,40 +40,48 @@ TARGETMENUID=0 FTP_MOUNT_AVAILABLE=0 - FTP_MOUNT_TEXT="Not available" + FTP_MOUNT_TEXT='Not available' SAMBA_MOUNT_AVAILABLE=0 - SAMBA_MOUNT_TEXT="Not available" + SAMBA_MOUNT_TEXT='Not available' SYNC_DRY_RUN=0 - SYNC_MODE_TEXT="Disabled" - SYNC_COMPRESSION_TEXT="Disabled" - SYNC_CRONDAILY_TEXT="Disabled" + SYNC_MODE_TEXT='Disabled' + SYNC_COMPRESSION_TEXT='Disabled' + SYNC_CRONDAILY_TEXT='Disabled' #TARGETMENUID=0 Menu_Main(){ - SYNC_MODE_TEXT="Disabled" + SYNC_MODE_TEXT='Disabled' if (( $SYNC_DELETE_MODE == 1 )); then - SYNC_MODE_TEXT="Enabled" + + SYNC_MODE_TEXT='Enabled' + fi - SYNC_COMPRESSION_TEXT="Disabled" + SYNC_COMPRESSION_TEXT='Disabled' if (( $SYNC_COMPRESSION == 1 )); then - SYNC_COMPRESSION_TEXT="Enabled" + + SYNC_COMPRESSION_TEXT='Enabled' + fi - SYNC_CRONDAILY_TEXT="Disabled" + SYNC_CRONDAILY_TEXT='Disabled' if (( $SYNC_CRONDAILY == 1 )); then - SYNC_CRONDAILY_TEXT="Enabled" + + SYNC_CRONDAILY_TEXT='Enabled' + fi local sync_last_completed='No previous sync found in target directory.' if [ -f "$FP_TARGET/$SYNC_STATS_FILENAME" ]; then + sync_last_completed=$(grep '^Sync completed' "$FP_TARGET/$SYNC_STATS_FILENAME" | tail -1 | awk '{print $3}') + fi - WHIP_TITLE='- DietPi-Sync -' + WHIP_TITLE='DietPi-Sync' OPTION=$(whiptail --title "$WHIP_TITLE" --menu "Source location:\n $FP_SOURCE\n\nTarget location:\n $FP_TARGET\n\nMost recent successful sync date:\n $sync_last_completed" --cancel-button "Exit" --backtitle "$WHIP_BACKTITLE" 23 73 8 \ "Help" "What does DietPi-Sync do?" \ "Source Location" "Change the Source directory." \ @@ -104,45 +97,75 @@ case "$OPTION" in "Source Location") + TARGETMENUID=2 + ;; + "Target Location") + TARGETMENUID=1 + ;; + Help) + whiptail --title "DietPi-Sync Help" --msgbox "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 - http://dietpi.com/phpbb/viewtopic.php?f=8&t=5&p=256#p256" --backtitle "$WHIP_BACKTITLE" 19 75 + ;; + "Delete Mode") + TARGETMENUID=3 + ;; + Compression) + TARGETMENUID=4 + ;; + "Sync: Daily") + TARGETMENUID=5 + ;; + "Sync: Dry Run") + WHIP_TITLE=' Test Dry Run Sync? ' whiptail --title "$WHIP_TITLE" --yesno "Source 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?" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 16 72 CHOICE=$? if (( $CHOICE == 0 )); then + SYNC_DRY_RUN=1 Run_Sync + fi + ;; + "Sync: Now") + WHIP_TITLE=' Start Sync? ' whiptail --title "$WHIP_TITLE" --yesno "Source 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?" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 16 72 CHOICE=$? if (( $CHOICE == 0 )); then + SYNC_DRY_RUN=0 Run_Sync + fi + ;; + esac else + Menu_Exit + fi } @@ -155,7 +178,9 @@ #Exit if (( $CHOICE == 0 )); then + TARGETMENUID=-1 + fi } @@ -171,10 +196,12 @@ 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" WHIP_TITLE='Select your Sync Target location' 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_TITLE='Select your Sync Source location' + fi Check_Available_DietPi_Mounts @@ -218,41 +245,71 @@ ;; "Samba Client") if (( $SAMBA_MOUNT_AVAILABLE == 1 )); then + if (( $TARGETMENUID == 2 )); then + FP_SOURCE="$FP_SAMBA_MOUNT" + else + FP_TARGET="$FP_SAMBA_MOUNT/dietpi-sync" + fi + else + Prompt_Setup_Samba_Mount if (( $TARGETMENUID == 2 )); then + FP_SOURCE="$current_directory" + else + FP_TARGET="$current_directory" + fi + fi + ;; + "FTP Client") if (( $FTP_MOUNT_AVAILABLE == 1 )); then + if (( $TARGETMENUID == 2 )); then + FP_SOURCE="$FP_FTP_MOUNT" + else + FP_TARGET="$FP_FTP_MOUNT/dietpi-sync" + fi + else + Prompt_Setup_FTP_Mount if (( $TARGETMENUID == 2 )); then + FP_SOURCE="$current_directory" + else + FP_TARGET="$current_directory" + fi + fi + ;; + esac else + #Return to main menu TARGETMENUID=0 + fi } @@ -269,12 +326,19 @@ if (( $CHOICE == 0 )); then case "$OPTION" in + Disabled) + SYNC_DELETE_MODE=0 + ;; + Enabled) + SYNC_DELETE_MODE=1 + ;; + esac fi @@ -296,12 +360,19 @@ if (( $CHOICE == 0 )); then case "$OPTION" in + Disabled) + SYNC_COMPRESSION=0 + ;; + Enabled) + SYNC_COMPRESSION=1 + ;; + esac fi @@ -323,12 +394,19 @@ if (( $CHOICE == 0 )); then case "$OPTION" in + Disabled) + SYNC_CRONDAILY=0 + ;; + Enabled) + SYNC_CRONDAILY=1 + ;; + esac fi @@ -345,19 +423,26 @@ #Target if (( $TARGETMENUID == 1 )); then + OPTION=$(whiptail --inputbox "Please enter the filepath to your Target directory. \neg: /mnt/target" 8 70 "$FP_TARGET" --title "Manual sync directory" --backtitle "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3) CHOICE=$? if (( $CHOICE == 0 )); then + FP_TARGET="$OPTION" + fi #Source elif (( $TARGETMENUID == 2 )); then + OPTION=$(whiptail --inputbox "Please enter the filepath to your Source directory. \neg: /mnt/source" 8 70 "$FP_SOURCE" --title "Manual sync directory" --backtitle "$WHIP_BACKTITLE" 3>&1 1>&2 2>&3) CHOICE=$? if (( $CHOICE == 0 )); then + FP_SOURCE="$OPTION" + fi + fi } @@ -367,8 +452,10 @@ whiptail --title "Not available. Setup Now?" --yesno "$SAMBA_MOUNT_TEXT\n\nWould you like to run DietPi-Config and setup your Samba Client Mount now?" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 11 70 CHOICE=$? if (( $CHOICE == 0 )); then + #Run configure /DietPi/dietpi/dietpi-config 16 1 + fi } @@ -378,8 +465,10 @@ whiptail --title "Not available. Setup Now?" --yesno "$FTP_MOUNT_TEXT\n\nWould you like to run DietPi-Config and setup your FTP Client Mount now?" --yes-button "Ok" --no-button "Back" --defaultno --backtitle "$WHIP_BACKTITLE" 11 70 CHOICE=$? if (( $CHOICE == 0 )); then + #Run configure /DietPi/dietpi/dietpi-config 16 1 + fi } @@ -483,10 +572,12 @@ local mode='Sync' #Dry Run? if (( $SYNC_DRY_RUN == 1 )); then + mode='Dry Run' + fi - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Sync "$mode" + G_DIETPI-NOTIFY 3 DietPi-Sync "$mode" } @@ -500,16 +591,23 @@ #Error: Folder not found if [ ! -d "$FP_TARGET" ]; then - if (( $INPUT == 0 )); then + + if (( $G_USER_INPUTS )); then + whiptail --title "Sync failed." --msgbox "Unable to create Target directory $FP_TARGET" --backtitle "$WHIP_BACKTITLE" 10 60 + fi #Error: Rsync is already running elif (( $(ps aux | grep -ci -m1 "[r]sync") == 1 )); then + echo -e "Sync failed: $(date +"%d-%m-%Y_%H%M"). Rsync is already running." >> "$FP_TARGET/$SYNC_STATS_FILENAME" + #Menu - if (( $INPUT == 0 )); then + if (( $G_USER_INPUTS )); then + whiptail --title "Sync Error" --msgbox "A sync job could not be started as rsync is already running." --backtitle "$WHIP_BACKTITLE" 13 60 + fi #Start sync @@ -530,17 +628,23 @@ #Compression? if (( $SYNC_COMPRESSION == 1 )); then + rync_options+="z" + fi #Dry Run? if (( $SYNC_DRY_RUN == 1 )); then + rync_options+="n" + fi #Delete mode? if (( $SYNC_DELETE_MODE == 1 )); then + rync_options+=" --delete" + fi #Write new logfile @@ -555,28 +659,42 @@ #Success if (( $? == 0 )); then + echo -e "Sync completed: $(date +"%d-%m-%Y_%H%M")" >> "$FP_TARGET/$SYNC_STATS_FILENAME" + #Menu - if (( $INPUT == 0 )); then + if (( $G_USER_INPUTS )); then if (( $SYNC_DRY_RUN == 0 )); then + whiptail --title "Sync completed" --msgbox "$FP_SOURCE\n\nHas been synced to:\n$FP_TARGET\n\nLog file: $LOGFILE" --backtitle "$WHIP_BACKTITLE" 13 60 + else + whiptail --title "Dry Run Sync completed" --msgbox "$FP_SOURCE\n\nHas been synced with a Dry Run (NO modifications) to:\n$FP_TARGET\n\nLog file: $LOGFILE" --backtitle "$WHIP_BACKTITLE" 13 60 + fi + fi #Failed else + echo -e "Sync failed: $(date +"%d-%m-%Y_%H%M")" >> "$FP_TARGET/$SYNC_STATS_FILENAME" + #Menu - if (( $INPUT == 0 )); then + if (( $G_USER_INPUTS )); then if (( $SYNC_DRY_RUN == 0 )); then + whiptail --title "Sync failed" --msgbox "Your sync has failed. Please see the Log file for more information:\n\n$LOGFILE" --backtitle "$WHIP_BACKTITLE" 13 60 + else + whiptail --title "Dry Run Sync failed" --msgbox "Your sync has failed. Please see the Log file for more information:\n\n$LOGFILE" --backtitle "$WHIP_BACKTITLE" 13 60 + fi + fi fi @@ -589,15 +707,7 @@ Check_Install_PreReqs(){ - #Rsync - if (( $(dpkg -l | grep -ci -m1 ' rsync ') == 0 )); then - - echo -e "\n\nInstalling Rsync, please wait....\n\n" - sleep 1 - - apt-get install rsync -y - - fi + G_AG_CHECK_INSTALL_PREREQ rsync } @@ -610,16 +720,20 @@ SAMBA_MOUNT_AVAILABLE=0 SAMBA_MOUNT_TEXT="Not mounted ($FP_SAMBA_MOUNT). Select to setup." if (( $(cat "$temp_file_mounts" | grep -ci -m1 "/mnt/samba") == 1 )); 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" + fi #FTP Client FTP_MOUNT_AVAILABLE=0 FTP_MOUNT_TEXT="Not mounted ($FP_FTP_MOUNT). Select to setup." if (( $(cat "$temp_file_mounts" | grep -ci -m1 "/mnt/ftp_client") == 1 )); then + FTP_MOUNT_AVAILABLE=1 FTP_MOUNT_TEXT="Mounted and online." + fi rm "$temp_file_mounts" @@ -647,12 +761,14 @@ Read_Settings_File(){ if [ -f "$FP_DIETPISYNC_SETTINGS" ]; then + local sed_index=1 FP_SOURCE=$(sed -n "$sed_index"p "$FP_DIETPISYNC_SETTINGS");((sed_index++)) FP_TARGET=$(sed -n "$sed_index"p "$FP_DIETPISYNC_SETTINGS");((sed_index++)) SYNC_DELETE_MODE=$(sed -n "$sed_index"p "$FP_DIETPISYNC_SETTINGS");((sed_index++)) SYNC_COMPRESSION=$(sed -n "$sed_index"p "$FP_DIETPISYNC_SETTINGS");((sed_index++)) SYNC_CRONDAILY=$(sed -n "$sed_index"p "$FP_DIETPISYNC_SETTINGS");((sed_index++)) + fi } @@ -682,16 +798,26 @@ clear if (( $TARGETMENUID == 0 )); then + Menu_Main + elif (( $TARGETMENUID == 1 )) || (( $TARGETMENUID == 2 )); then + 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 @@ -706,6 +832,7 @@ rm "$FP_INCLUDE_GLOBAL" &> /dev/null rm "$FP_EXCLUDE_GLOBAL" &> /dev/null #----------------------------------------------------------------------------------- - exit + exit 0 #----------------------------------------------------------------------------------- -} \ No newline at end of file + +} diff --git a/dietpi/dietpi-update b/dietpi/dietpi-update index 209b6a50dc..bef18b6607 100644 --- a/dietpi/dietpi-update +++ b/dietpi/dietpi-update @@ -19,28 +19,6 @@ # - dietpi-update 2 = Check for updates. print server_version to /DietPi/dietpi/.update_available (-1=new image required) #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Exit path for non-root logins. - if (( $UID != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit - - fi - - #RootFS RW check - /DietPi/dietpi/dietpi-drive_manager 3 - if (( $? != 0 )); then - - exit - - fi - INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then @@ -48,18 +26,24 @@ fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Update' + #Import DietPi-Globals --------------------------------------------------------------- + #///////////////////////////////////////////////////////////////////////////////////// #GIT Branch | master / testing #///////////////////////////////////////////////////////////////////////////////////// - GITBRANCH=$(cat /DietPi/dietpi.txt | grep -m1 '^gitbranch=' | sed 's/.*=//') - GITFORKOWNER=$(cat /DietPi/dietpi.txt | grep -m1 '^gitforkowner=' | sed 's/.*=//') + GITBRANCH=$(grep -m1 '^DEV_GITBRANCH=' /DietPi/dietpi.txt | sed 's/.*=//') + GITFORKOWNER=$(grep -m1 '^DEV_GITOWNER=' /DietPi/dietpi.txt | sed 's/.*=//') #///////////////////////////////////////////////////////////////////////////////////// #UPDATE Vars #///////////////////////////////////////////////////////////////////////////////////// - FP_LOG='/etc/dietpi/logs/dietpi-update.log' - DIETPIUPDATE_VERSION_CURRENT=5 # Version of dietpi-update / set server_version line two to value++ and obsolete previous dietpi-update scripts - DIETPIUPDATE_VERSION_REQUIRED=0 + FP_LOG='/var/tmp/dietpi/logs/dietpi-update.log' + DIETPIUPDATE_COREVERSION_CURRENT=6 # Version of dietpi-update / set server_version-6 line one to value++ and obsolete previous dietpi-update scripts FILEPATH_TEMP="/tmp/dietpi-update" @@ -68,14 +52,17 @@ UPDATE_REQUIRESNEWIMAGE=0 RUN_UPDATE=0 - VERSION_CURRENT=0 - VERSION_SERVER=0 + COREVERSION_CURRENT=0 + SUBVERSION_CURRENT=0 + + COREVERSION_SERVER=0 + SUBVERSION_SERVER=0 URL_MIRROR_INDEX=0 URL_MIRROR_SERVERVERSION=( - "http://dietpi.com/downloads/dietpi-update_mirror/$GITBRANCH/server_version" - "https://raw.githubusercontent.com/${GITFORKOWNER:-Fourdee}/DietPi/$GITBRANCH/dietpi/server_version" + "http://dietpi.com/downloads/dietpi-update_mirror/$GITBRANCH/server_version-6" + "https://raw.githubusercontent.com/${GITFORKOWNER:-Fourdee}/DietPi/$GITBRANCH/dietpi/server_version-6" ) @@ -88,7 +75,8 @@ Get_Client_Version(){ - VERSION_CURRENT=$(cat /DietPi/dietpi/.version) + COREVERSION_CURRENT=$(sed -n 1p /DietPi/dietpi/.version) + SUBVERSION_CURRENT=$(sed -n 2p /DietPi/dietpi/.version) } @@ -100,35 +88,36 @@ URL_MIRROR_INDEX=$i - /DietPi/dietpi/func/dietpi-notify 2 "Checking Mirror : ${URL_MIRROR_SERVERVERSION[$i]}" + G_DIETPI-NOTIFY 2 "Checking Mirror : ${URL_MIRROR_SERVERVERSION[$i]}" curl -k -L ${URL_MIRROR_SERVERVERSION[$i]} > "$FILEPATH_TEMP"/server_version if (( $? == 0 )); then #Get server Version info - VERSION_SERVER=$(sed -n 1p "$FILEPATH_TEMP"/server_version) - DIETPIUPDATE_VERSION_REQUIRED=$(sed -n 2p "$FILEPATH_TEMP"/server_version) + COREVERSION_SERVER=$(sed -n 1p "$FILEPATH_TEMP"/server_version) + SUBVERSION_SERVER=$(sed -n 2p "$FILEPATH_TEMP"/server_version) #Check if server_version is a valid interger. - if [[ $VERSION_SERVER =~ ^-?[0-9]+$ ]]; then + if [[ $SUBVERSION_SERVER =~ ^-?[0-9]+$ ]]; then SERVER_ONLINE=1 - /DietPi/dietpi/func/dietpi-notify 0 "Using update server: ${URL_MIRROR_SERVERVERSION[$i]}" + G_DIETPI-NOTIFY 0 "Using update server: ${URL_MIRROR_SERVERVERSION[$i]}" break else - /DietPi/dietpi/func/dietpi-notify 2 "Invalid server version and/or update file unavailable" + G_DIETPI-NOTIFY 2 "Invalid server version and/or update file unavailable" fi else - /DietPi/dietpi/func/dietpi-notify 2 "No response from: ${URL_MIRROR_SERVERVERSION[$i]}" + G_DIETPI-NOTIFY 2 "No response from: ${URL_MIRROR_SERVERVERSION[$i]}" fi done + } Check_Update_Available(){ @@ -140,29 +129,31 @@ if (( $SERVER_ONLINE )); then #Update Requires new image? - if (( $DIETPIUPDATE_VERSION_CURRENT < $DIETPIUPDATE_VERSION_REQUIRED )); then + if (( $DIETPIUPDATE_COREVERSION_CURRENT < $COREVERSION_SERVER )); then UPDATE_REQUIRESNEWIMAGE=1 echo -e "-1" > /DietPi/dietpi/.update_available #Update available - elif (( $VERSION_CURRENT < $VERSION_SERVER )); then + elif (( $SUBVERSION_CURRENT < $SUBVERSION_SERVER )); then UPDATE_AVAILABLE=1 echo -e "" - /DietPi/dietpi/func/dietpi-notify 0 "Update available" - /DietPi/dietpi/func/dietpi-notify 2 "Current Version : $VERSION_CURRENT" - /DietPi/dietpi/func/dietpi-notify 2 "Server Version : $VERSION_SERVER" + G_DIETPI-NOTIFY 0 "Update available" + G_DIETPI-NOTIFY 2 "Current Version : $COREVERSION_CURRENT.$SUBVERSION_CURRENT" + G_DIETPI-NOTIFY 2 "Server Version : $COREVERSION_SERVER.$SUBVERSION_SERVER" #Write update available version to file. - echo -e "$VERSION_SERVER" > /DietPi/dietpi/.update_available + cat << _EOF_ > /DietPi/dietpi/.update_available +$COREVERSION_SERVER.$SUBVERSION_SERVER +_EOF_ fi else - /DietPi/dietpi/func/dietpi-notify 1 "Unable to access update servers. Please check your connection, then run dietpi-update again." - exit + G_DIETPI-NOTIFY 1 "Unable to access update servers. Please check your connection, then run dietpi-update again." + exit 1 fi @@ -171,7 +162,7 @@ #///////////////////////////////////////////////////////////////////////////////////// # MENUS #///////////////////////////////////////////////////////////////////////////////////// - WHIP_BACKTITLE='- DietPi-Update -' + WHIP_BACKTITLE='DietPi-Update' WHIP_TITLE=$WHIP_BACKTITLE CHOICE=0 OPTION=0 @@ -179,8 +170,8 @@ Menu_Update(){ whiptail --title "$WHIP_TITLE" --yesno "Update available : https://goo.gl/G9ikqn -Installed version : $VERSION_CURRENT -Latest version : $VERSION_SERVER +Installed version : $COREVERSION_CURRENT.$SUBVERSION_CURRENT +Latest version : $COREVERSION_SERVER.$SUBVERSION_SERVER ---------------------------------Notice------------------------------------- The benefit of DietPi is we use standard linux configurations and commands. The downside is we can't possibly accommodate or predict, every modifcation to Linux configurations files by the end user, during the update. @@ -191,7 +182,7 @@ You can create a system backup, by running: - dietpi-backup ---------------------------------------------------------------------------- -Do you wish to continue and update DietPi to v$VERSION_SERVER?" --yes-button "Ok" --no-button "Exit" --defaultno --backtitle "$WHIP_BACKTITLE" 24 80 +Do you wish to continue and update DietPi to v$COREVERSION_SERVER.$SUBVERSION_SERVER?" --yes-button "Ok" --no-button "Exit" --defaultno --backtitle "$WHIP_BACKTITLE" 24 80 CHOICE=$? if (( $CHOICE == 0 )); then @@ -227,22 +218,28 @@ Do you wish to continue and update DietPi to v$VERSION_SERVER?" --yes-button "Ok #Allow execute of all DietPi scripts and patch file chmod -R +x /DietPi + #Verify/update dietpi.txt entries: + /DietPi/dietpi/func/dietpi-set_software verify_dietpi.txt + #Run Patch file - while (( $VERSION_CURRENT < $VERSION_SERVER )); do + while (( $SUBVERSION_CURRENT < $SUBVERSION_SERVER )); do - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Update "Updating DietPi" - /DietPi/dietpi/func/dietpi-notify 2 "Current Version : $VERSION_CURRENT" - /DietPi/dietpi/func/dietpi-notify 2 "Server Version : $VERSION_SERVER\n" + G_DIETPI-NOTIFY 3 'DietPi-Update Updating DietPi' + G_DIETPI-NOTIFY 2 "Current Version : $COREVERSION_CURRENT.$SUBVERSION_CURRENT" + G_DIETPI-NOTIFY 2 "Server Version : $COREVERSION_SERVER.$SUBVERSION_SERVER\n" #Run patch file - /DietPi/dietpi/func/dietpi-notify 2 "Patching $VERSION_CURRENT to $(( $VERSION_CURRENT + 1 ))" - /DietPi/dietpi/patch_file "$VERSION_CURRENT" "$VERSION_SERVER" + G_DIETPI-NOTIFY 2 "Patching $COREVERSION_CURRENT.$SUBVERSION_CURRENT to $COREVERSION_CURRENT.$(( $SUBVERSION_CURRENT + 1 ))" + /DietPi/dietpi/patch_file $SUBVERSION_CURRENT $SUBVERSION_SERVER #Update Local Version ID - ((VERSION_CURRENT++)) - echo -e "$VERSION_CURRENT" > /DietPi/dietpi/.version + ((SUBVERSION_CURRENT++)) + cat << _EOF_ > /DietPi/dietpi/.version +$COREVERSION_CURRENT +$SUBVERSION_CURRENT +_EOF_ - /DietPi/dietpi/func/dietpi-notify 0 "Patch $VERSION_CURRENT completed\n" + G_DIETPI-NOTIFY 0 "Patch $COREVERSION_CURRENT.$SUBVERSION_CURRENT completed\n" Get_Client_Version @@ -258,8 +255,8 @@ Do you wish to continue and update DietPi to v$VERSION_SERVER?" --yes-button "Ok #Unable to download file. else - /DietPi/dietpi/func/dietpi-notify 1 "Download failed, unable to run update. Please try running dietpi-update again." - exit + G_DIETPI-NOTIFY 1 "Download failed, unable to run update. Please try running dietpi-update again." + exit 1 fi @@ -270,7 +267,7 @@ Do you wish to continue and update DietPi to v$VERSION_SERVER?" --yes-button "Ok #///////////////////////////////////////////////////////////////////////////////////// #---------------------------------------------------------------- #Inform user - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Update "Checking for DietPi updates" + G_DIETPI-NOTIFY 3 DietPi-Update 'Checking for DietPi updates' #---------------------------------------------------------------- #Create temp directory used in dietpi-update rm -R "$FILEPATH_TEMP" &> /dev/null @@ -302,10 +299,10 @@ Do you wish to continue and update DietPi to v$VERSION_SERVER?" --yes-button "Ok elif (( $UPDATE_REQUIRESNEWIMAGE == 1 )); then #Cannot update, Image required - whiptail --title "New image required" --msgbox " Your version of DietPi is now obsolete and cannot be updated. \n\n Please download the latest DietPi image:\n - http://dietpi.com/downloads/images \n\n - Current Version : $VERSION_CURRENT \n - Server Version : $VERSION_SERVER \n " 13 70 + whiptail --title "New image required" --msgbox " Your version of DietPi is now obsolete and cannot be updated. \n\n Please download the latest DietPi image:\n - http://dietpi.com/downloads/images \n\n - Current Version : $SUBVERSION_CURRENT \n - Server Version : $SUBVERSION_SERVER \n " 13 70 - /DietPi/dietpi/func/dietpi-notify 1 "Your version of DietPi is now obsolete and cannot be updated." - echo -e "Please download the latest DietPi image:\n - http://dietpi.com/download \n\n - Current Version : $VERSION_CURRENT \n - Server Version : $VERSION_SERVER \n " + G_DIETPI-NOTIFY 1 "Your version of DietPi is now obsolete and cannot be updated." + echo -e "Please download the latest DietPi image:\n - http://dietpi.com/download \n\n - Current Version : $SUBVERSION_CURRENT \n - Server Version : $SUBVERSION_SERVER \n " #Update available elif (( $UPDATE_AVAILABLE == 1 )); then @@ -319,11 +316,9 @@ Do you wish to continue and update DietPi to v$VERSION_SERVER?" --yes-button "Ok #Forced update elif (( $INPUT == 1 )); then - /DietPi/dietpi/func/dietpi-notify 0 "Updates have been found and are being applied, please wait..." - /DietPi/dietpi/func/dietpi-notify 2 "Current Version : $VERSION_CURRENT" - /DietPi/dietpi/func/dietpi-notify 2 "Server Version : $VERSION_SERVER" - - /DietPi/dietpi/dietpi-funtime 0 + G_DIETPI-NOTIFY 0 "Updates have been found and are being applied, please wait..." + G_DIETPI-NOTIFY 2 "Current Version : $COREVERSION_CURRENT.$SUBVERSION_CURRENT" + G_DIETPI-NOTIFY 2 "Server Version : $COREVERSION_SERVER.$SUBVERSION_SERVER" RUN_UPDATE=1 @@ -338,9 +333,9 @@ Do you wish to continue and update DietPi to v$VERSION_SERVER?" --yes-button "Ok else echo -e "" - /DietPi/dietpi/func/dietpi-notify 0 "No updates required, your DietPi installation is up to date.\n" - /DietPi/dietpi/func/dietpi-notify 2 "Current Version : $VERSION_CURRENT" - /DietPi/dietpi/func/dietpi-notify 2 "Server Version : $VERSION_SERVER" + G_DIETPI-NOTIFY 0 "No updates required, your DietPi installation is up to date.\n" + G_DIETPI-NOTIFY 2 "Current Version : $COREVERSION_CURRENT.$SUBVERSION_CURRENT" + G_DIETPI-NOTIFY 2 "Server Version : $COREVERSION_SERVER.$SUBVERSION_SERVER" sleep 2 fi @@ -372,11 +367,14 @@ Do you wish to continue and update DietPi to v$VERSION_SERVER?" --yes-button "Ok #Remove update_available file rm /DietPi/dietpi/.update_available &> /dev/null + #Sync to disk now: http://dietpi.com/phpbb/viewtopic.php?f=9&t=2591 + sync + #Done - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Update "Completed" - /DietPi/dietpi/func/dietpi-notify 2 "Current Version : $VERSION_CURRENT" - /DietPi/dietpi/func/dietpi-notify 2 "Server Version : $VERSION_SERVER" - /DietPi/dietpi/func/dietpi-notify 0 "Update completed" + G_DIETPI-NOTIFY 3 DietPi-Update "Completed" + G_DIETPI-NOTIFY 2 "Current Version : $COREVERSION_CURRENT.$SUBVERSION_CURRENT" + G_DIETPI-NOTIFY 2 "Server Version : $COREVERSION_SERVER.$SUBVERSION_SERVER" + G_DIETPI-NOTIFY 0 "Update completed" echo -e "" echo -e "Please reboot your system now, using the command \e[31;49;1mreboot\e[0m" @@ -399,6 +397,6 @@ Do you wish to continue and update DietPi to v$VERSION_SERVER?" --yes-button "Ok unset URL_MIRROR_SERVERVERSION unset URL_MIRROR_ZIP #---------------------------------------------------------------- - exit + exit 0 #---------------------------------------------------------------- } diff --git a/dietpi/finalise b/dietpi/finalise deleted file mode 100644 index aa6d155ebd..0000000000 --- a/dietpi/finalise +++ /dev/null @@ -1,395 +0,0 @@ -#!/bin/bash -{ - #//////////////////////////////////// - # DietPi Finalise - # - #//////////////////////////////////// - # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com - # - #//////////////////////////////////// - # - # Info: - # - Preps the system for saving an image file, and, setting up for 1st use. - # NB: Use of this script will drop WiFi connections, use ETH only. - #//////////////////////////////////// - - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Use version of master branch - wget https://raw.githubusercontent.com/Fourdee/DietPi/master/dietpi/.version -O /tmp/masterversion - IMAGE_VERSION=$(cat /tmp/masterversion) - - #///////////////////////////////////////////////////////////////////////////////////// - #Obtain Pi/Odroid Model - #///////////////////////////////////////////////////////////////////////////////////// - - /DietPi/dietpi/dietpi-obtain_hw_model - - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) - - #//////////////////////////////////// - #Stop services - /DietPi/dietpi/dietpi-services stop - - #Disable services - /DietPi/dietpi/dietpi-services dietpi_controlled - - #//////////////////////////////////// - #Unmount Drives - umount /dev/sda[1-9] - - #//////////////////////////////////// - # Clean Apt + cache - #Remove packages - apt-get purge openssh-client openssh-server alsa-utils rsync stress -y - # + rpi - apt-get purge -y rpi-update - - apt-get autoremove -y --purge - - #Install dropbear - apt-get install -y dropbear - # - set to start on next boot - sed -i '/NO_START=1/c\NO_START=0' /etc/default/dropbear - - #BBB required for EMMC transfer - if (( $HW_MODEL == 71 )); then - - apt-get install -y dosfstools rsync - - fi - - #Clear cache - apt-get clean - rm -R /var/lib/apt/lists/* -vf #lists cache: remove partial folder also, automatically gets regenerated on apt-get update - #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 - - - # - Set default apt mirrors - /DietPi/dietpi/func/dietpi-set_software apt-mirror default - - # - Clear deb-multimedia (meveric's images, seems to be pulled in via his kernel package updates) - rm /etc/apt/sources.list.d/deb-multimedia.list - - #//////////////////////////////////// - #Sudo UID bit: https://github.com/Fourdee/DietPi/issues/794 - chmod 4755 /usr/bin/sudo - - #//////////////////////////////////// - #Delete/Cleanup - # - general folders - rm -R /media - rm -R /tmp/* - rm -R /selinux - # + sourcecode (linux-headers etc) - rm -R /usr/src/* - - # - root - rm -R /root/.cache/* - rm -R /root/.local/* - rm -R /root/.config/* - # + Reapply htop config - mkdir -p /root/.config/htop - cp /boot/dietpi/conf/htoprc /root/.config/htop/htoprc - - # - documentation folders - rm -R /usr/share/man - rm -R /usr/share/doc - rm -R /usr/share/doc-base - rm -R /usr/share/calendar - - # - Remove Bash History file - rm ~/.bash_history - - # - Nano histroy file - rm ~/.nano_history - - rm /var/cache/debconf/*-old - - #//////////////////////////////////// - #Disable/Remove Swapfile (saves 100mb in final image) - /DietPi/dietpi/func/dietpi-set_dphys-swapfile 0 /var/swap - # - Reset config - echo -e "CONF_SWAPSIZE=100" > /etc/dphys-swapfile - echo -e "CONF_SWAPFILE=/var/swap" >> /etc/dphys-swapfile - - #//////////////////////////////////// - # Disable Autologin/Autostart - rm /etc/systemd/system/getty@tty1.service.d/autologin.conf - - #//////////////////////////////////// - #Reset FSTAB - cp /DietPi/dietpi/conf/fstab /etc/fstab - - # Rock64 - if (( $HW_MODEL == 43 )); then - - cp /DietPi/dietpi/conf/fstab_rock64 /etc/fstab - - # X86_64 native - elif (( $HW_MODEL == 21 )); then - - if [ -d /boot/efi ]; then - - cp /DietPi/dietpi/conf/fstab_x86_64-native_EFI /etc/fstab - - else - - cp /DietPi/dietpi/conf/fstab_x86_64-native /etc/fstab - - fi - - # VM - elif (( $HW_MODEL == 20 )); then - - cp /DietPi/dietpi/conf/fstab_vm /etc/fstab - - # XU4 requires UUID with 4.9 kernel: https://github.com/Fourdee/DietPi/issues/899#issuecomment-298912660 - # NB: Do this on EMMC due to SD mmcblk1 - elif (( $HW_MODEL == 11 )); then - - UUID_CURRENT=$(blkid /dev/mmcblk0p1 -s UUID -o value) - sed -i "s#^/dev/mmcblk0p1#UUID=$UUID_CURRENT#g" /etc/fstab - - UUID_CURRENT=$(blkid /dev/mmcblk0p2 -s UUID -o value) - sed -i "s#^/dev/mmcblk0p2#UUID=$UUID_CURRENT#g" /etc/fstab - - # RPi requires PARTUUID for USB write: https://github.com/Fourdee/DietPi/issues/970 - elif (( $HW_MODEL < 10 )); then - - PARTUUID_CURRENT=$(blkid /dev/mmcblk0p1 -s PARTUUID -o value) - sed -i "s#^/dev/mmcblk0p1#PARTUUID=$PARTUUID_CURRENT#g" /etc/fstab - - PARTUUID_CURRENT=$(blkid /dev/mmcblk0p2 -s PARTUUID -o value) - sed -i "s#^/dev/mmcblk0p2#PARTUUID=$PARTUUID_CURRENT#g" /etc/fstab - - fi - - systemctl daemon-reload - mount -a - - #//////////////////////////////////// - # Reset cmdline.txt / boot.ini / dietpi.txt - #Set Pi Config.txt back to normal - wget https://raw.githubusercontent.com/Fourdee/DietPi/testing/config.txt -O /DietPi/config.txt - - /DietPi/dietpi/func/dietpi-set_hardware i2c disable - - sed -i "/temp_limit=/c\temp_limit=65" /DietPi/config.txt - - - # ODROID's - Set boot.ini back to normal - if (( $HW_MODEL == 10 )); then - - wget https://raw.githubusercontent.com/Fourdee/DietPi/testing/boot_c1.ini -O /DietPi/boot.ini - - elif (( $HW_MODEL == 11 )); then - - wget https://raw.githubusercontent.com/Fourdee/DietPi/testing/boot_xu4.ini -O /DietPi/boot.ini - - elif (( $HW_MODEL == 12 )); then - - wget https://raw.githubusercontent.com/Fourdee/DietPi/testing/boot_c2.ini -O /DietPi/boot.ini - - fi - - systemctl mask cpu_governor #Meveric's images - - # PineA64 - delete ethaddr from uEnv.txt file - if (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then - - sed -i '/^ethaddr/ d' /boot/uEnv.txt - - fi - - #Set dietpi.txt back to normal - wget https://raw.githubusercontent.com/Fourdee/DietPi/testing/dietpi.txt -O /DietPi/dietpi.txt - - #??? BBB disable swapfile gen - if (( $HW_MODEL == 71 )); then - - sed -i '/Swapfile_Size=/c\Swapfile_Size=0' /DietPi/dietpi.txt - - fi - #??? - - # Update README.MD - wget https://raw.githubusercontent.com/Fourdee/DietPi/testing/README.md -O /boot/README.md - - # Set Pi cmdline.txt back to normal - # - Remove root delay - sed -i "s/ rootdelay=10//g" /boot/cmdline.txt - - #//////////////////////////////////// - #Reset Networking - /DietPi/dietpi/func/dietpi-set_hardware wifimodules enable # Must be enabled to set. - /DietPi/dietpi/func/dietpi-set_hardware wificountrycode GB - iw reg get - - #Copy Network Interface conf - cp /DietPi/dietpi/conf/network_interfaces /etc/network/interfaces - # Generate stock wpa_supplicant.conf - /DietPi/dietpi/func/dietpi-set_hardware wificreds set - - #Add pre-up lines for wifi on OrangePi Zero - if (( $HW_MODEL == 32 )); then - - sed -i '/iface wlan0 inet dhcp/apre-up modprobe xradio_wlan\npre-up iwconfig wlan0 power on' /etc/network/interfaces - - fi - - # Remove all predefined eth*/wlan* adapter rules - rm /etc/udev/rules.d/70-persistent-net.rules - rm /etc/udev/rules.d/70-persistant-net.rules - - # Disable wifi and bluetooth modules on all devices. - /DietPi/dietpi/func/dietpi-set_hardware bluetooth disable - /DietPi/dietpi/func/dietpi-set_hardware wifimodules disable - - # Enable onboard WiFi chips by default (removes them from blacklist) - /DietPi/dietpi/func/dietpi-set_hardware wifimodules onboard_enable - - # Disable forced eth speed if set - /DietPi/dietpi/func/dietpi-set_hardware eth-forcespeed disable - - # Reset IP version pref - /DietPi/dietpi/func/dietpi-set_hardware preferipversion auto - - #Set Hostname - cat << _EOF_ > /etc/hosts -127.0.0.1 localhost -127.0.1.1 DietPi -_EOF_ - - cat << _EOF_ > /etc/hostname -DietPi -_EOF_ - - - #//////////////////////////////////// - #Htop cfg - cp /DietPi/dietpi/conf/htoprc /root/.config/htop/htoprc - - #//////////////////////////////////// - #Kernel - # - Disable installed flags - rm /etc/dietpi/.* - - # - RPi install DietPi kernel by default - #NB: Done during patches. - # if (( $HW_MODEL < 10 )); then - - # /DietPi/dietpi/func/dietpi-set_hardware kernel dietpi_rpi - - # fi - - #//////////////////////////////////// - #Disable serial console - /DietPi/dietpi/func/dietpi-set_hardware serialconsole disable - - #//////////////////////////////////// - #Disable soundcards - /DietPi/dietpi/func/dietpi-set_hardware soundcard none - - #//////////////////////////////////// - #Set CPU govs - /DietPi/dietpi/dietpi-cpu_set - - #//////////////////////////////////// - #Logs/Automation - /DietPi/dietpi/dietpi-logclear 2 - - # Clear DietPi-Ramlog storage - rm -R /etc/dietpi/dietpi-ramlog/storage - - # DietPi logs, excluded from /var/log (due to ramlog clear) - rm -R /etc/dietpi/logs - - # ntp delete drift file - rm /var/lib/ntp/ntp.drift - - # DietPi-Automation - rm /root/DietPi-Automation.log - rm /boot/Automation_Format_My_Usb_Drive - - #//////////////////////////////////// - #Create DietPi user: https://github.com/Fourdee/DietPi/issues/796 - /DietPi/dietpi/func/dietpi-set_software useradd dietpi - - #//////////////////////////////////// - # Reset DietPi generated files - rm /DietPi/dietpi/.* - - echo -e "$IMAGE_VERSION" > /DietPi/dietpi/.version - echo -e "$IMAGE_VERSION" > /etc/.dietpi_image_version - - # .dietpi-autostart_index Console - echo 0 > /DietPi/dietpi/.dietpi-autostart_index - - # Create our update file (used on 1st run to check for DietPi updates) - echo -1 > /DietPi/dietpi/.update_stage - - # Set Init .install_stage to -3 (first boot) - echo -3 > /DietPi/dietpi/.install_stage - - #??? BBB skip FS_partition - if (( $HW_MODEL == 71 )); then - - echo -2 > /DietPi/dietpi/.install_stage - - fi - #??? - - # Remove server_version / patch_file (downloads fresh from dietpi-update) - rm /DietPi/dietpi/patch_file - rm /DietPi/dietpi/server_version - - #//////////////////////////////////// - #setup DietPi specific mount folders - rm -R /mnt/dietpi-backup - rm -R /mnt/dietpi-sync - rm -R /mnt/dietpi_userdata - - mkdir -p /mnt/dietpi_userdata - mkdir -p /etc/dietpi/logs - - #unmount - umount /mnt/samba - if (( ! $(df | grep -ci -m1 '/mnt/samba') )); then - rm -R /mnt/samba - mkdir -p /mnt/samba - echo -e "Samba client can be installed and setup by DietPi-Config.\nSimply run: dietpi-config" > /mnt/samba/readme.txt - else - echo -e "\nWARN: samba is mounted, please unmount and run this script again." - fi - - umount /mnt/ftp_client - if (( ! $(df | grep -ci -m1 '/mnt/ftp_client') )); then - rm -R /mnt/ftp_client - mkdir -p /mnt/ftp_client - echo -e "FTP client mount can be installed and setup by DietPi-Config.\nSimply run: dietpi-config" > /mnt/ftp_client/readme.txt - else - echo -e "\nWARN: ftp_client is mounted, please unmount and run this script again." - fi - - #TRIM root FS - sync - fstrim -v / - sync - - #Sync DietPi RAMdisk to Disk now - #systemctl restart dietpi-ramdisk # causes reboot on sparky????/ due to rm *. on dietpi globals? - - echo -e "Check and delete all non-required folders in /root/.xxxxxx" - ls -lha /lib/modules - - #----------------------------------------------------------------------------------- - exit - #----------------------------------------------------------------------------------- -} diff --git a/dietpi/func/change_hostname b/dietpi/func/change_hostname index 355a260396..93f5fe4326 100644 --- a/dietpi/func/change_hostname +++ b/dietpi/func/change_hostname @@ -17,11 +17,12 @@ # - /DietPi/dietpi/func/change_hostname sNEWHOSTNAME #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Change_hostname' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// #Change Hostname diff --git a/dietpi/func/check_connection b/dietpi/func/check_connection deleted file mode 100644 index 666e4a8dd7..0000000000 --- a/dietpi/func/check_connection +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -{ - #//////////////////////////////////// - # DietPi Function: - # - check_connection - # - #//////////////////////////////////// - # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com - # - #//////////////////////////////////// - # - # Info: - # - Used to check a url connection is valid with wget spider - # - Timeout and Retry count prevents endless waiting if HTTP request is delayed/broken . - # - Returns exit code 0 if successful - # - # Usage: - # - /DietPi/dietpi/func/check_connection sURL - #//////////////////////////////////// - - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - INTERNET_ADDRESS=$1 - TIMEOUT=10 - RETRYCOUNT=2 - - EXIT_CODE=0 - - #///////////////////////////////////////////////////////////////////////////////////// - # Main Loop - #///////////////////////////////////////////////////////////////////////////////////// - #----------------------------------------------------------------------------------- - /DietPi/dietpi/func/dietpi-notify 2 "Testing connection to $INTERNET_ADDRESS" - /DietPi/dietpi/func/dietpi-notify 2 "Max duration of $(($TIMEOUT * $RETRYCOUNT)) seconds, please wait..." - - wget -q --spider --timeout="$TIMEOUT" --tries="$RETRYCOUNT" "$INTERNET_ADDRESS" - - #--no-check-certificate - #https://github.com/Fourdee/DietPi/issues/352#issuecomment-221013166 - - EXIT_CODE=$? - /DietPi/dietpi/func/dietpi-notify -1 $EXIT_CODE "Connection test |" - - #----------------------------------------------------------------------------------- - #return exit code - exit $EXIT_CODE - #----------------------------------------------------------------------------------- -} \ No newline at end of file diff --git a/dietpi/func/create_mysql_db b/dietpi/func/create_mysql_db index 36031c8297..d10ce98f94 100644 --- a/dietpi/func/create_mysql_db +++ b/dietpi/func/create_mysql_db @@ -2,43 +2,45 @@ { #//////////////////////////////////// # DietPi Function: - # - Creates a MySql database + # - Creates a MariaDB database #//////////////////////////////////// # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com #//////////////////////////////////// # Usage: - # - /DietPi/dietpi/func/create_mysql_db DATABASE_NAME MYSQL_ROOT_PW DATABASE_USER DATABASE_PW + # - /DietPi/dietpi/func/create_mysql_db DATABASE_NAME DATABASE_USER DATABASE_PW # # Drop database: - # - mysqladmin -u root -pdietpi drop phpbb3 -f + # - mysqladmin -uroot drop phpbb3 -f #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - DATABASE_NAME="$1" - MYSQL_ROOT_PW="$2" - DATABASE_USER="$3" - DATABASE_PW="$4" + DATABASE_USER="$2" + DATABASE_PW="$3" + + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Create_MySQL_DB' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// # Main Loop #///////////////////////////////////////////////////////////////////////////////////// - #Start sql if not running. + #Start MySQL if not running. service mysql start &> /dev/null - /DietPi/dietpi/func/dietpi-notify 2 "Creating MySql DB for $DATABASE_NAME\n" + G_DIETPI-NOTIFY 2 "Creating MariaDB database: $DATABASE_NAME" #Generate DB - mysql -u root -p$MYSQL_ROOT_PW -e "create database \`$DATABASE_NAME\`;GRANT ALL PRIVILEGES ON \`$DATABASE_NAME\`.* TO $DATABASE_USER@localhost IDENTIFIED BY '$DATABASE_PW';FLUSH PRIVILEGES;" + # 'identified by' can overwrite unix_socket authentication, thus just use this for non-root users. + grant_privileges='' + [ "$DATABASE_USER" == 'root' ] || grant_privileges="grant all privileges on \`$DATABASE_NAME\`.* to $DATABASE_USER@localhost identified by '$DATABASE_PW';flush privileges" + mysql -uroot -e "create database \`$DATABASE_NAME\`;$grant_privileges" - /DietPi/dietpi/func/dietpi-notify -1 $? "Create database $DATABASE_NAME |" + G_DIETPI-NOTIFY -1 "$?" "Creating MariaDB database: $DATABASE_NAME |" #----------------------------------------------------------------------------------- exit #----------------------------------------------------------------------------------- -} \ No newline at end of file +} diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals new file mode 100644 index 0000000000..80a87a632c --- /dev/null +++ b/dietpi/func/dietpi-globals @@ -0,0 +1,1098 @@ +#!/bin/bash +{ + #//////////////////////////////////// + # DietPi-Globals + # + #//////////////////////////////////// + # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com + # + #//////////////////////////////////// + # + # Info: + # - Allows export of shared DietPi global variables/funcs into current bash session, and other scripts + # + # Excluded scripts, which do NOT load these globals + # - dietpi-ramlog + # - dietpi-ramdisk + # - dietpi.txt (and all other .txt .ini or config files) + # + #//////////////////////////////////// + + #----------------------------------------------------------------------------------- + # Core var's, functions, environment. Used at start of all scripts. + #----------------------------------------------------------------------------------- + #Prevent incorrect parsing with non-english locales. + LANG=en_GB.UTF-8 + + #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 + cd "$HOME" + + #To be exported by the originating script (eg: dietpi-software) + # - Used in: + # G_ERROR_ (info) + G_PROGRAM_NAME='' + + #User input? (eg: interactive shell available via STDIN check) + # Effects: + # - G_ERROR_HANDLER whiptail display + # NB: You can export G_USER_INPUTS=0 to force non-interactive (eg: .bashrc) Must run 'unset G_USER_INPUTS' after to return to auto detection. + if [ -z $G_USER_INPUTS ]; then + + G_USER_INPUTS=0 + + if [[ -t 0 ]]; then + + #checked: + # - OK | systemD = non-STDIN + # - OK | Cron = non-STDIN + + #shopt login_shell # == [[ $- == *i* ]] #.bashrc dietpi/login exec is not interactive... + #[ -t 0 ]# .bashrc dietpi/login exec is interactive... + #set -i in .bashrc is not available... + + G_USER_INPUTS=1 + + fi + + fi + + #DEBUG: + # echo $G_USER_INPUTS + # shopt login_shell + # sleep 1 + #DEBUG: + + # - DietPi Scripts, moved from /etc/bash.bashrc + alias sudo='sudo ' # https://github.com/Fourdee/DietPi/issues/424 + alias dietpi-process_tool='/DietPi/dietpi/dietpi-process_tool' + alias dietpi-letsencrypt='/DietPi/dietpi/dietpi-letsencrypt' + alias dietpi-autostart='/DietPi/dietpi/dietpi-autostart' + alias dietpi-cron='/DietPi/dietpi/dietpi-cron' + alias dietpi-launcher='/DietPi/dietpi/dietpi-launcher' + alias dietpi-cleaner='/DietPi/dietpi/dietpi-cleaner' + alias dietpi-morsecode='/DietPi/dietpi/dietpi-morsecode' + alias dietpi-sync='/DietPi/dietpi/dietpi-sync' + alias dietpi-backup='/DietPi/dietpi/dietpi-backup' + alias dietpi-bugreport='/DietPi/dietpi/dietpi-bugreport' + alias dietpi-services='/DietPi/dietpi/dietpi-services' + alias dietpi-config='/DietPi/dietpi/dietpi-config' + alias dietpi-software='/DietPi/dietpi/dietpi-software' + alias dietpi-update='/DietPi/dietpi/dietpi-update' + alias dietpi-drive_manager='/DietPi/dietpi/dietpi-drive_manager' + alias emulationstation='/opt/retropie/supplementary/emulationstation/emulationstation' + + alias cpu='/DietPi/dietpi/dietpi-cpuinfo' + alias dietpi-logclear='/DietPi/dietpi/dietpi-logclear' + + # - Optional DietPi software aliases/functions + [ -f /usr/local/games/opentyrian/run ] && alias opentyrian='/usr/local/games/opentyrian/run' + [ -f /DietPi/dietpi/misc/dietpi-justboom ] && alias dietpi-justboom='/DietPi/dietpi/misc/dietpi-justboom' + [ -f "$G_FP_DIETPI_USERDATA"/dxx-rebirth/run.sh ] && alias dxx-rebirth="$G_FP_DIETPI_USERDATA/dxx-rebirth/run.sh" + [ -f /usr/share/applications/kodi.desktop ] && alias startkodi='/DietPi/dietpi/misc/start_kodi' + [ -f /etc/systemd/system/dietpi-cloudshell.service ] && alias dietpi-cloudshell='/DietPi/dietpi/dietpi-cloudshell' + # occ/ncc need to be global function, as aliases are not accessible from non-interactive scripts: + [ -f /var/www/owncloud/occ ] && occ(){ sudo -u www-data php /var/www/owncloud/occ "$@"; } + [ -f /var/www/nextcloud/occ ] && ncc(){ sudo -u www-data php /var/www/nextcloud/occ "$@"; } + + # - Treesize + # $1 = Optional input directory (eg: G_TREESIZE /etc/apt) + G_TREESIZE() + { + + du -k --max-depth=1 $1 | sort -nr | awk ' + BEGIN { + split("KB,MB,GB,TB", Units, ","); + } + { + u = 1; + while ($1 >= 1024) + { + $1 = $1 / 1024; + u += 1; + } + $1 = sprintf("%.1f %s", $1, Units[u]); + print $0; + } + ' + } + + # DietPi-Notify + # $1: + # -2=process animation + # - $2 = text + # -1=autodetect_fail_ok + # - $2 = EXIT_CODE + # 0=OK + # - $2 = text + # 1=failed + # - $2 = text + # 2=info + # - $2 = text + # 3=DietPi banner style + # - $2 = txt program name + # - $3 = txt mode + G_DIETPI-NOTIFY(){ + + local ainput_string=("$@") + + #header_line="\e[38;5;154m─────────────────────────────────────────────────────\e[0m" + local header_line="\e[90m─────────────────────────────────────────────────────\e[0m" + + local status_text_ok="\e[32m OK \e[0m" + local status_text_error="\e[31mFAILED\e[0m" + local status_text_info="\e[0m INFO \e[0m" + + local bracket_string_l="\e[90m[\e[0m" + local bracket_string_r="\e[90m]\e[0m" + + #Funcs + + Print_Process_Animation(){ + + local bright_dot="\e[1;93m.\e[0m" + local dimmed_dot="\e[2;33m.\e[0m" + local aprocess_string=( + #\u23F9 + "$bright_dot " + "$dimmed_dot$bright_dot " + " $dimmed_dot$bright_dot " + " $dimmed_dot$bright_dot " + " $dimmed_dot$bright_dot " + " $dimmed_dot$bright_dot" + " $bright_dot$dimmed_dot" + " $bright_dot$dimmed_dot " + " $bright_dot$dimmed_dot " + " $bright_dot$dimmed_dot " + "$bright_dot$dimmed_dot " + ) + + for (( i=0; i<=${#aprocess_string[@]}; i++ )); do + + (( i == 11 )) && i=1 + [ -f /tmp/dietpi-process.pid ] && echo -ne "\r$bracket_string_l${aprocess_string[i]}$bracket_string_r " || break + sleep 0.15 + + done + + } + + Clean_Process_Animation(){ + + if [ -f /tmp/dietpi-process.pid ]; then + + kill "$( /dev/null + rm /tmp/dietpi-process.pid &> /dev/null || sudo rm /tmp/dietpi-process.pid &> /dev/null + # In case, the output took more than one line, clean from cursor (animation position) until end of terminal. + tput ed + + fi + echo -ne "\r\e[K" + + } + + Print_Process(){ + + echo -ne "\r\e[9C" + + } + + Print_Ok(){ + + Clean_Process_Animation + echo -ne "$bracket_string_l$status_text_ok$bracket_string_r " + + } + + Print_Failed(){ + + Clean_Process_Animation + echo -ne "$bracket_string_l$status_text_error$bracket_string_r " + + } + + Print_Info(){ + + Clean_Process_Animation + echo -ne "$bracket_string_l$status_text_info$bracket_string_r " + + } + + # - Print all input string on same line + # - $1 = start printing from word number $1 + Print_Input_String(){ + + local i=0 + for (( i=$1;i<${#ainput_string[@]} ;i++)) + do + echo -ne "${ainput_string[$i]}" + done + + } + + #-------------------------------------------------------------------------------------- + # Main Loop + #-------------------------------------------------------------------------------------- + #Exit code, print OK or Failed + #$2 = exit code + # - Use this at end of DietPi scripts, EG: G_DIETPI-NOTIFY -1 ${EXIT_CODE:=0} + if (( $1 == -1 )); then + + if [ "$2" = "0" ]; then + + ainput_string+=(" Completed") + Print_Ok + Print_Input_String 2 + echo '' + + else + + ainput_string+=(" An issue has occured") + Print_Failed + Print_Input_String 2 + echo '' + + fi + + #-------------------------------------------------------------------------------------- + #Status Processing + #$@ = txt desc + elif (( $1 == -2 )); then + + Print_Process + Print_Input_String 1 + # Calculate the amount of output lines and in case move cursor up for correct animation and to allow cleaning the whole output. + local string="$*" + local lines=0 + (( lines=(${#string}+6)/$(tput cols) )) + while (( lines > 0 )); do + + tput cuu1 + (( lines-- )) + + done + [ ! -f /tmp/dietpi-process.pid ] && touch /tmp/dietpi-process.pid && ( Print_Process_Animation & echo $! > /tmp/dietpi-process.pid ) + + #Status Ok + #$@ = txt desc + elif (( $1 == 0 )); then + + Print_Ok + Print_Input_String 1 + echo '' + + #Status failed + #$@ = txt desc + elif (( $1 == 1 )); then + + Print_Failed + Print_Input_String 1 + echo '' + + #Status Info + #$@ = txt desc + elif (( $1 == 2 )); then + + Print_Info + echo -ne "\e[90m" + Print_Input_String 1 + echo -e "\e[0m" + + #DietPi banner style + #$2 = txt program name + #$3 = txt mode + elif (( $1 == 3 )); then + + echo -e "\n \e[38;5;154m$2\e[0m" + echo -e "$header_line" + echo -e " \e[90mMode: \e[0m$(Print_Input_String 2)\n" + + fi + #----------------------------------------------------------------------------------- + # Unset also internal functions, otherwise they are accessible from terminal. + unset Print_Process_Animation + unset Clean_Process_Animation + unset Print_Process + unset Print_Ok + unset Print_Failed + unset Print_Info + unset Print_Input_String + #----------------------------------------------------------------------------------- + + } + + G_CHECK_ROOT_USER_VERIFIED=${G_CHECK_ROOT_USER_VERIFIED:=0} #only check once for each session + G_CHECK_ROOT_USER(){ + + if (( ! $G_CHECK_ROOT_USER_VERIFIED )); then + + G_DIETPI-NOTIFY -2 'Checking for (elevated) root access' + + if (( $UID != 0 )); then + + G_DIETPI-NOTIFY 1 'Root privileges required. Please run the command with "sudo"\n' + exit 1 + + else + + G_DIETPI-NOTIFY 0 'Root access verified.' + export G_CHECK_ROOT_USER_VERIFIED=1 + + fi + + fi + + } + + G_CHECK_ROOTFS_RW_VERIFIED=${G_CHECK_ROOTFS_RW_VERIFIED:=0} #only check once for each session + G_CHECK_ROOTFS_RW(){ + + if (( ! $G_CHECK_ROOTFS_RW_VERIFIED )); then + + #RootFS RW check + /DietPi/dietpi/dietpi-drive_manager 3 + if (( $? != 0 )); then + + G_DIETPI-NOTIFY 1 'RootFS is currently Read Only, unable to continue.\n' + exit 1 + + else + + export G_CHECK_ROOTFS_RW_VERIFIED=1 + + fi + + fi + + } + + #----------------------------------------------------------------------------------- + # DietPi Error Handler + # https://github.com/Fourdee/DietPi/issues/1311#issuecomment-353716344 + #----------------------------------------------------------------------------------- + G_ERROR_HANDLER_EXITCODE='' #input value to use with G_ERROR_HANDLER + G_ERROR_HANDLER_COMMAND='' #eg: G_AGI: moooooooo + # For export: On error, following entries will be used + G_ERROR_HANDLER_ONERROR_EXIT=1 #Do we exit the program when the error occurs? 0=no 1=yes + G_ERROR_HANDLER_ONERROR_FPLOGFILE='' #FP to logfile, if available + + #Runs automatically after G_ERROR_HANDLER to reset vars to default + G_ERROR_HANDLER_RESET(){ + + #unset originating program + unset G_ERROR_HANDLER_EXITCODE + unset G_ERROR_HANDLER_COMMAND + + unset G_ERROR_HANDLER_ONERROR_EXIT + unset G_ERROR_HANDLER_ONERROR_FPLOGFILE + + G_ERROR_HANDLER_EXITCODE='' + G_ERROR_HANDLER_COMMAND='' + + G_ERROR_HANDLER_ONERROR_EXIT=1 + G_ERROR_HANDLER_ONERROR_FPLOGFILE='' + + } + + #Handles exit code errors, as defined by G_ERROR_HANDLER_xxxx settings + # Usage: + # export G_ERROR_HANDLER_COMMAND='Doing something usefull with Owncloud' + # export G_ERROR_HANDLER_ONERROR_EXIT=0 # Don't exit program on error, continue + # export G_ERROR_HANDLER_ONERROR_FPLOGFILE=/var/log/mylogfile # to print if error occurs + # occ --doing-something-useful + # export G_ERROR_HANDLER_EXITCODE=$? + # G_ERROR_HANDLER + G_ERROR_HANDLER(){ + + #Ok + if (( $G_ERROR_HANDLER_EXITCODE == 0 )); then + + G_DIETPI-NOTIFY 0 "$G_ERROR_HANDLER_COMMAND" + + #Error + else + + local print_hw_info="VERSION:v$(sed -n 1p /DietPi/dietpi/.version).$(sed -n 2p /DietPi/dietpi/.version) | HW_MODEL:$G_HW_MODEL | HW_ARCH:$G_HW_ARCH | DISTRO:$G_DISTRO" + local print_exitcode_info="exit_code = $G_ERROR_HANDLER_EXITCODE" + local print_logfile_info="Log file contents:\n$(tail -50 $G_ERROR_HANDLER_ONERROR_FPLOGFILE)" + local print_report_to_dietpi_info='If problems persist, please report this to DietPi for investigation, including a screenshot of this error! (https://github.com/Fourdee/DietPi/issues).' + local print_unable_to_continue='Unable to continue, the program will now terminate.' + + echo '' + if [ -n "$G_PROGRAM_NAME" ]; then + + G_DIETPI-NOTIFY 1 "$G_PROGRAM_NAME: $G_ERROR_HANDLER_COMMAND" + + else + + G_DIETPI-NOTIFY 1 "$G_ERROR_HANDLER_COMMAND" + + fi + + G_DIETPI-NOTIFY 2 "$print_exitcode_info" + G_DIETPI-NOTIFY 2 "$print_hw_info" + + # - On Error: Display logfile FP, if set + if [ -n "$G_ERROR_HANDLER_ONERROR_FPLOGFILE" ]; then + + G_DIETPI-NOTIFY 2 "$print_logfile_info" + + fi + + # Display "please report to dietpi", if its one of our programs + if [ -n "$G_PROGRAM_NAME" ]; then + + G_DIETPI-NOTIFY 2 "$print_report_to_dietpi_info" + + fi + + # - On Error: Display whip version? + if (( $G_USER_INPUTS )); then + + local whip_msg=() + if [ -n "$G_PROGRAM_NAME" ]; then + + whip_msg+="$G_PROGRAM_NAME: $G_ERROR_HANDLER_COMMAND" + + else + + whip_msg+="$G_ERROR_HANDLER_COMMAND" + + fi + + whip_msg+='\n' + whip_msg+=" - $print_exitcode_info" + whip_msg+='\n' + whip_msg+=" - $print_hw_info" + whip_msg+='\n\n' + + # Display optional logfile? + if [ -n "$G_ERROR_HANDLER_ONERROR_FPLOGFILE" ]; then + + whip_msg+="$print_logfile_info" + whip_msg+='\n\n' + + fi + + # Display "please report to dietpi", if its one of our programs + if [ -n "$G_PROGRAM_NAME" ]; then + + whip_msg+="$print_report_to_dietpi_info" + + fi + + if (( $G_ERROR_HANDLER_ONERROR_EXIT )); then + + whip_msg+='\n\n' + whip_msg+="$print_unable_to_continue" + + fi + + whiptail --title 'DietPi Error Handler:' --msgbox "$whip_msg" --scrolltext 22 85 + + fi + + # - On Error: Kill current script, excluding the shell. + if (( $G_ERROR_HANDLER_ONERROR_EXIT )); then + + # - Github printout: + echo -e " +\e[41m +-------------------------------------------------------------------- +- DietPi has encounted an error, and, is unable to continue - +- Please create a ticket: https://github.com/Fourdee/DietPi/issues - +- Copy and paste the BLUE lines below, into the ticket - +-------------------------------------------------------------------- +\e[0m +\e[44m +#### Required Information: +- DietPi Version | v$(sed -n 1p /DietPi/dietpi/.version).$(sed -n 2p /DietPi/dietpi/.version) +- SBC Device | $G_HW_MODEL_DESCRIPTION (index=$G_HW_MODEL) +- Distro | $G_DISTRO_NAME (index=$G_DISTRO) +- Command | $G_ERROR_HANDLER_COMMAND +- Error Handler | G_ERROR_HANDLER + +#### Additional Information (if applicable): +- Software title | $G_PROGRAM_NAME + +#### Expected behaviour: + + +#### Actual behaviour: + + +#### Steps to reproduce: + + +#### Additional logs: +\`\`\` +$print_logfile_info +\`\`\` +\e[0m + +\e[41m--------------------------------------------------------------------\e[0m +" + + G_DIETPI-NOTIFY 1 "$print_unable_to_continue" + + # - Reset for next run + G_ERROR_HANDLER_RESET + + kill -INT $$ + + fi + + fi + + return $G_ERROR_HANDLER_EXITCODE + + # - Reset for next run + G_ERROR_HANDLER_RESET + + } + + #Run a command and send the output through the error handler. This has the same effect as running G_ERROR_HANDLER afterwards, however, allows for command used info, and log output/view when an error occurs + #NB: This command does not support inputs with redirects. For file creation, use G_FILE_EXISTS afterwards to check it exists: https://github.com/Fourdee/DietPi/issues/1311#issuecomment-354541417 + # $@ = input command + # eg: + # G_RUN_CMD mkdir /never/gonna/work + G_RUN_CMD(){ + + G_ERROR_HANDLER_COMMAND="$@" + + G_DIETPI-NOTIFY -2 "Running command: $G_ERROR_HANDLER_COMMAND" + + $G_ERROR_HANDLER_COMMAND &> /tmp/G_ERROR_HANDLER_COMMAND + G_ERROR_HANDLER_EXITCODE=$? + G_ERROR_HANDLER_ONERROR_FPLOGFILE='/tmp/G_ERROR_HANDLER_COMMAND' + + G_ERROR_HANDLER + + rm /tmp/G_ERROR_HANDLER_COMMAND &> /dev/null + + } + + #Checks if a file/folder exists + # Automatically passed through G_ERROR_HANDLER + G_FILE_EXISTS(){ + + G_ERROR_HANDLER_COMMAND="$@" + G_ERROR_HANDLER_EXITCODE=0 + + G_DIETPI-NOTIFY -2 "Checking for existance: $G_ERROR_HANDLER_COMMAND" + + local string='' + + if [ -f "$G_ERROR_HANDLER_COMMAND" ]; then + + string="File exists" + + elif [ -d "$G_ERROR_HANDLER_COMMAND" ]; then + + string="Folder exists" + + else + + string="File/folder does not exist" + G_ERROR_HANDLER_EXITCODE=1 + + fi + + string+=" | $G_ERROR_HANDLER_COMMAND" + + echo -e "$string" > /tmp/G_ERROR_HANDLER_COMMAND + G_ERROR_HANDLER_ONERROR_FPLOGFILE='/tmp/G_ERROR_HANDLER_COMMAND' + G_ERROR_HANDLER_COMMAND="$string" + + G_ERROR_HANDLER + + rm /tmp/G_ERROR_HANDLER_COMMAND &> /dev/null + + } + + #----------------------------------------------------------------------------------- + # DietPi First-Run Stage + #----------------------------------------------------------------------------------- + # -2 = PREP_SYSTEM/Unknown | -1 = first boot | 0 = run dietpi-software at login | 1 = completed + G_DIETPI_INSTALL_STAGE=-2 + if [ -f /DietPi/dietpi/.install_stage ]; then + + G_DIETPI_INSTALL_STAGE=$(cat /DietPi/dietpi/.install_stage) + + fi + + #----------------------------------------------------------------------------------- + # Hardware Details + #----------------------------------------------------------------------------------- + G_HW_MODEL=${G_HW_MODEL:-0} + G_HW_MODEL_DESCRIPTION=${G_HW_MODEL_DESCRIPTION:-NULL} + G_HW_ARCH=${G_HW_ARCH:-0} + G_HW_CPU_CORES=${G_HW_CPU_CORES:-1} + G_HW_CPUID=${G_HW_CPUID:-0} + + G_DISTRO=${G_DISTRO:-0} + G_DISTRO_NAME=${G_DISTRO_NAME:-NULL} + + # - Update + # NB: dietpi-boot service launches dietpi-obtain_hw_model to create the following file + if [ -f /DietPi/dietpi/.hw_model ]; then + + G_HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) + G_HW_MODEL_DESCRIPTION=$(sed -n 2p /DietPi/dietpi/.hw_model) + G_HW_ARCH=$(sed -n 6p /DietPi/dietpi/.hw_model) + G_HW_CPU_CORES=$(nproc --all) + G_HW_CPUID=$(sed -n 9p /DietPi/dietpi/.hw_model) + + G_DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) + G_DISTRO_NAME='jessie' + if (( $G_DISTRO == 4 )); then + + G_DISTRO_NAME='stretch' + + elif (( $G_DISTRO == 5 )); then + + G_DISTRO_NAME='buster' + + fi + + fi + + #Returns current CPU temp 'C + G_OBTAIN_CPU_TEMP(){ + + # - Array to store possible locations for temp read. + afp_temperature=( + + #'/sys/class/thermal/thermal_zone1/temp' #sparky/Asus, will break other SBC temp readouts as most have 2 zones, needs a special case + '/sys/class/thermal/thermal_zone0/temp' + '/sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input' + '/sys/class/hwmon/hwmon0/device/temp_label' + + ) + + for ((i=0; i<${#afp_temperature[@]}; i++)) + do + + if [ -f "${afp_temperature[$i]}" ]; then + + # Sparky/asus, special case: + if (( $G_HW_MODEL == 70 || $G_HW_MODEL == 52 )); then + + cpu_temp_current=$(cat /sys/class/thermal/thermal_zone1/temp) + + else + + cpu_temp_current=$(cat ${afp_temperature[$i]}) + + fi + + # - Boards that provide 2 digit output + # Pine + # NanoPi M2 + # NanoPi M3 + # H3 3.x + # H2+ 3.x + if (( $G_HW_MODEL == 40 || + $G_HW_MODEL == 61 || + $G_HW_MODEL == 62 || + ( $G_HW_CPUID == 1 && $(uname -r | grep -ci -m1 '^3.') ) || + ( $G_HW_MODEL == 32 && $(uname -r | grep -ci -m1 '^3.') ) )); then + + echo -e "Do nothing" &> /dev/null + + else + + cpu_temp_current=$( echo -e "$cpu_temp_current" | awk '{print $1/1000}' | xargs printf "%0.0f" ) + + fi + + + break + + fi + + done + + unset afp_temperature + + echo $cpu_temp_current + + } + + #Returns current CPU usage % + G_OBTAIN_CPU_USAGE(){ + + # - PS (inaccurate, but fast??) + local cpu_usage=0 + local fp_temp='/tmp/.cpu_usage_cpuinfo' + ps -axo %cpu | sed '1d' | sed 's/ //' > "$fp_temp" + while read line + do + + cpu_usage=$( echo "scale=1;$cpu_usage + $line" | bc -l ) + + done < "$fp_temp" + + # - ps returns usage of each core, so we devide the total by #n cores + cpu_usage=$(echo "scale=1;$cpu_usage / $(nproc --all)" | bc -l ) + + echo $cpu_usage + + } + + #----------------------------------------------------------------------------------- + # DietPi specific directories + #----------------------------------------------------------------------------------- + # - Default DietPi userdata location. This must NEVER change. + G_FP_DIETPI_USERDATA='/mnt/dietpi_userdata' + # - Current DietPi userdata location (actual, follows symlink of G_FP_DIETPI_USERDATA, if not on rootFS) + #G_FP_DIETPI_USERDATA_CURRENT=$(readlink -f $G_FP_DIETPI_USERDATA) + #FP_DIETPI_VAR_LIB='/var/lib/dietpi' + #FP_DIETPI_VAR_TMP='/var/tmp/dietpi' + + #----------------------------------------------------------------------------------- + # URL Connection test + #----------------------------------------------------------------------------------- + # $@ = URL + # NB: automatically error handled (G_ERROR_HANDLER) + # Prompts user to configure network if $G_USER_INPUTS=1 + G_CHECK_URL(){ + + local string="$@" + local timeout=10 + local retry_max=5 + local error_connection_failed=0 + + G_ERROR_HANDLER_EXITCODE=0 + G_ERROR_HANDLER_COMMAND="Connection test: $string" + G_ERROR_HANDLER_ONERROR_FPLOGFILE='/tmp/G_CHECK_URL' + + while true + do + + #Allow user choice to configure network on failure + if (( $G_USER_INPUTS )); then + + G_ERROR_HANDLER_ONERROR_EXIT=0 + + if (( $error_connection_failed )); then + + #Ask to check settings, + whiptail --title "URL Connection Test Failed" --yesno "DietPi was unable to establish a connection:\n - $string\n\nIf problems persist, the URL may be offline/unreachable.\n\nWould you like to configure network settings and try again?" --yes-button "Ok" --no-button "Exit" --defaultno --backtitle "$G_PROGRAM_NAME" 15 80 + CHOICE=$? + + #run dietpi config + if (( $CHOICE == 0 )); then + + whiptail --title "Launching DietPi-Config" --msgbox "DietPi-Config will now be started.\nUse the Network Options menu to change and test your network settings.\n\nWhen completed, exit DietPi-Config to resume." --backtitle "Launching DietPi-Config" 14 60 + /DietPi/dietpi/dietpi-config 8 1 + + #User aborted, exit now with current error information + else + + G_ERROR_HANDLER_ONERROR_EXIT=1 + G_ERROR_HANDLER_EXITCODE=1 + G_USER_INPUTS=0 #disable whiptail info + G_ERROR_HANDLER + #break #handled by G_ERROR_HANDLER script kill + + fi + + fi + + #Force exit on failure to end loop (overrides any export G_ERROR_HANDLER_ONERROR_EXIT in this session) + else + + G_ERROR_HANDLER_ONERROR_EXIT=1 + + fi + + for ((i=1; i<=$retry_max; i++)) + do + + G_DIETPI-NOTIFY -2 "($i/$retry_max) Testing connection to $string, please wait..." + + wget --spider --timeout=$timeout --tries=1 "$string" &> /tmp/G_CHECK_URL + G_ERROR_HANDLER_EXITCODE=$? + # Valid + if (( $G_ERROR_HANDLER_EXITCODE == 0 )); then + + break + + # Retry + 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 == 0 )); then + + break + + fi + + done + + rm /tmp/G_CHECK_URL + + return $G_ERROR_HANDLER_EXITCODE + + } + + #----------------------------------------------------------------------------------- + # APT + #----------------------------------------------------------------------------------- + G_FP_LOG_APT='/var/tmp/dietpi/logs/dietpi-software_apt.log' + + #Support for apt-fast: https://github.com/Fourdee/DietPi/issues/698 + # APT_BINARY='apt-get' + # if [ -f /usr/bin/apt-fast ]; then + + # APT_BINARY='apt-fast' + + # fi + + #apt-get install + # NB: automatically error handled (G_ERROR_HANDLER) + G_AGI(){ + + local string="$@" + local force_options='' + + if (( $G_DISTRO >= 4 )); then + + force_options='--allow-downgrades --allow-remove-essential --allow-change-held-packages --allow-unauthenticated' + + else + + force_options='--force-yes' + + fi + + G_ERROR_HANDLER_EXITCODE=0 + G_ERROR_HANDLER_COMMAND="G_AGI: $string" + G_ERROR_HANDLER_ONERROR_FPLOGFILE="$G_FP_LOG_APT" + + + #-qq can add a slight period of appearing nothing is happening, lets inform user + G_DIETPI-NOTIFY 2 "APT installation for: $string, please wait..." + + DEBIAN_FRONTEND=noninteractive apt-get install -y -qq $force_options $string 2>&1 | tee "$G_FP_LOG_APT" + G_ERROR_HANDLER_EXITCODE=${PIPESTATUS[0]} + + G_ERROR_HANDLER + + return $G_ERROR_HANDLER_EXITCODE + + } + + #apt-get purge + # NB: automatically error handled (G_ERROR_HANDLER) + G_AGP(){ + + local string="$@" + local options='' + if (( $G_DISTRO >= 4 )); then + + options+=' --allow-change-held-packages' + + fi + + G_ERROR_HANDLER_EXITCODE=0 + G_ERROR_HANDLER_COMMAND="G_AGP: $string" + G_ERROR_HANDLER_ONERROR_FPLOGFILE="$G_FP_LOG_APT" + + G_DIETPI-NOTIFY 2 "APT removal for: $string, please wait..." + + DEBIAN_FRONTEND=noninteractive apt-get purge -y $string $options 2>&1 | tee "$G_FP_LOG_APT" + G_ERROR_HANDLER_EXITCODE=${PIPESTATUS[0]} + + G_ERROR_HANDLER + + return $G_ERROR_HANDLER_EXITCODE + + } + + #apt-get autoremove + # NB: automatically error handled (G_ERROR_HANDLER) + G_AGA(){ + + G_ERROR_HANDLER_EXITCODE=0 + G_ERROR_HANDLER_COMMAND="G_AGA" + G_ERROR_HANDLER_ONERROR_FPLOGFILE="$G_FP_LOG_APT" + + G_DIETPI-NOTIFY 2 "APT autoremove + purge, please wait..." + + DEBIAN_FRONTEND=noninteractive apt-get autoremove --purge -y 2>&1 | tee "$G_FP_LOG_APT" + G_ERROR_HANDLER_EXITCODE=${PIPESTATUS[0]} + + G_ERROR_HANDLER + + return $G_ERROR_HANDLER_EXITCODE + + } + + #apt-get install -f + # NB: automatically error handled (G_ERROR_HANDLER) + G_AGF(){ + + G_ERROR_HANDLER_EXITCODE=0 + G_ERROR_HANDLER_COMMAND="G_AGF" + G_ERROR_HANDLER_ONERROR_FPLOGFILE="$G_FP_LOG_APT" + + G_DIETPI-NOTIFY 2 "APT fix, please wait..." + + DEBIAN_FRONTEND=noninteractive apt-get install -f -y 2>&1 | tee "$G_FP_LOG_APT" + G_ERROR_HANDLER_EXITCODE=${PIPESTATUS[0]} + + G_ERROR_HANDLER + + return $G_ERROR_HANDLER_EXITCODE + + } + + #apt-get update + # NB: automatically error handled (G_ERROR_HANDLER) + G_AGUP(){ + + G_ERROR_HANDLER_EXITCODE=0 + G_ERROR_HANDLER_COMMAND="G_AGUP" + G_ERROR_HANDLER_ONERROR_FPLOGFILE="$G_FP_LOG_APT" + + G_DIETPI-NOTIFY 2 "APT update, please wait..." + + DEBIAN_FRONTEND=noninteractive apt-get clean 2>&1 | tee "$G_FP_LOG_APT" + DEBIAN_FRONTEND=noninteractive apt-get update 2>&1 | tee -a "$G_FP_LOG_APT" + G_ERROR_HANDLER_EXITCODE=${PIPESTATUS[0]} + + G_ERROR_HANDLER + + return $G_ERROR_HANDLER_EXITCODE + + } + + #apt-get upgrade + # NB: automatically error handled (G_ERROR_HANDLER) + G_AGUG(){ + + G_ERROR_HANDLER_EXITCODE=0 + G_ERROR_HANDLER_COMMAND="G_AGUG" + G_ERROR_HANDLER_ONERROR_FPLOGFILE="$G_FP_LOG_APT" + + G_DIETPI-NOTIFY 2 "APT upgrade, please wait..." + + DEBIAN_FRONTEND=noninteractive apt-get upgrade -y 2>&1 | tee "$G_FP_LOG_APT" + G_ERROR_HANDLER_EXITCODE=${PIPESTATUS[0]} + + G_ERROR_HANDLER + + return $G_ERROR_HANDLER_EXITCODE + + } + + #apt-get dist-upgrade + # NB: automatically error handled (G_ERROR_HANDLER) + G_AGDUG(){ + + G_ERROR_HANDLER_EXITCODE=0 + G_ERROR_HANDLER_COMMAND="G_AGDUG" + G_ERROR_HANDLER_ONERROR_FPLOGFILE="$G_FP_LOG_APT" + + if (( $G_DISTRO >= 4 )); then + + force_options='--allow-downgrades --allow-remove-essential --allow-change-held-packages --allow-unauthenticated' + + else + + force_options='--force-yes' + + fi + + G_DIETPI-NOTIFY 2 "APT dist-upgrade, please wait..." + + DEBIAN_FRONTEND=noninteractive apt-get dist-upgrade -y 2>&1 | tee "$G_FP_LOG_APT" + G_ERROR_HANDLER_EXITCODE=${PIPESTATUS[0]} + + G_ERROR_HANDLER + + return $G_ERROR_HANDLER_EXITCODE + + } + + #Checks for required APT packages, installs if needed. + # $@ = list of required packages + # NB: automatically error handled (G_ERROR_HANDLER) + G_AG_CHECK_INSTALL_PREREQ(){ + + local fp_temp='/tmp/.G_AG_CHECK_INSTALL_PREREQ' + local exit_code=0 + local string=( "$@" ) + local packages_to_install='' + + G_DIETPI-NOTIFY 2 "Checking for pre-req APT packages: ${string[*]}" + + dpkg --get-selections > "$fp_temp" + for i in "${string[@]}" + do + + if (( ! $(grep -ci -m1 "^$i[[:space:]]" "$fp_temp") )); then + + G_DIETPI-NOTIFY 2 "($i) | Not found, flagged for installation" + packages_to_install+=" $i" + + fi + + done + + if [ -n "$packages_to_install" ]; then + + G_DIETPI-NOTIFY -2 "Installing pre-req APT packages" + G_AGI $packages_to_install + exit_code=$? + + else + + G_DIETPI-NOTIFY 2 "Pre-req APT packages are installed" + + fi + + #G_AGI now handles the error + + rm "$fp_temp" + + return $exit_code + + } + + #----------------------------------------------------------------------------------- + # HW specific + #----------------------------------------------------------------------------------- + #rpi-update + # - Holds APT packages + # - Skips backup + G_RPI_UPDATE(){ + + if (( $G_HW_MODEL < 10 )); then + + G_AG_CHECK_INSTALL_PREREQ rpi-update + export SKIP_BACKUP=1 + G_RUN_CMD rpi-update + apt-mark hold raspberrypi-bootloader raspberrypi-kernel libraspberrypi-bin + + fi + + } + + #----------------------------------------------------------------------------------- + #G_DIETPI-NOTIFY 2 'DietPi-Globals loaded\n' + #----------------------------------------------------------------------------------- + +} diff --git a/dietpi/func/dietpi-led_control b/dietpi/func/dietpi-led_control index df826594a3..66ac4e9dde 100644 --- a/dietpi/func/dietpi-led_control +++ b/dietpi/func/dietpi-led_control @@ -16,12 +16,6 @@ # - /DietPi/dietpi/func/dietpi-led_control 1 Apply from savefile #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - #Grab Input INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then @@ -30,6 +24,12 @@ fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-LED_control' + #Import DietPi-Globals --------------------------------------------------------------- + FP_SETTINGS='/DietPi/dietpi/.dietpi-led_control' aLED_NAME=0 @@ -51,7 +51,7 @@ if (( ${#aLED_NAME[@]} == 0 )); then - /DietPi/dietpi/func/dietpi-notify 1 'Unable to find any supported LEDS on this device.' + G_DIETPI-NOTIFY 1 'Unable to find any supported LEDS on this device.' exit fi @@ -62,7 +62,7 @@ rm "$FP_SETTINGS" &> /dev/null - /DietPi/dietpi/func/dietpi-notify 3 DietPi-LED_Control "Applying LED triggers" + G_DIETPI-NOTIFY 3 DietPi-LED_Control "Applying LED triggers" for ((i=0; i<${#aLED_NAME[@]}; i++)) do @@ -71,11 +71,11 @@ echo -e "${aLED_SETTING_CURRENT[$i]}" > "/sys/class/leds/${aLED_NAME[$i]}/trigger" if (( $? == 0 )); then - /DietPi/dietpi/func/dietpi-notify 0 "${aLED_NAME[$i]}: ${aLED_SETTING_CURRENT[$i]}" + G_DIETPI-NOTIFY 0 "${aLED_NAME[$i]}: ${aLED_SETTING_CURRENT[$i]}" else - /DietPi/dietpi/func/dietpi-notify 1 "${aLED_NAME[$i]}: ${aLED_SETTING_CURRENT[$i]}" + G_DIETPI-NOTIFY 1 "${aLED_NAME[$i]}: ${aLED_SETTING_CURRENT[$i]}" fi diff --git a/dietpi/func/dietpi-notify b/dietpi/func/dietpi-notify deleted file mode 100644 index 300002caea..0000000000 --- a/dietpi/func/dietpi-notify +++ /dev/null @@ -1,136 +0,0 @@ -#!/bin/bash -{ - #//////////////////////////////////// - # DietPi Function: - # - #//////////////////////////////////// - # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com - # - #//////////////////////////////////// - # - # Info: - # - - # - # Usage: - # - /DietPi/dietpi/func/dietpi-notify - #//////////////////////////////////// - - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - aINPUT_STRING=("$@") - - #HEADER_LINE="\e[38;5;154m─────────────────────────────────────────────────────\e[0m" - HEADER_LINE="\e[90m─────────────────────────────────────────────────────\e[0m" - - STATUS_TEXT_OK="\e[32mOk\e[0m" - STATUS_TEXT_FAILED="\e[31mFailed:\e[0m" - - BRACKET_STRING_L="\e[90m[\e[0m" - BRACKET_STRING_R="\e[90m]\e[0m" - - #Funcs - - Print_Ok(){ - - echo -ne " $BRACKET_STRING_L\e[32mOk\e[0m$BRACKET_STRING_R" - - } - - Print_Failed(){ - - echo -ne " $BRACKET_STRING_L\e[31mFailed\e[0m$BRACKET_STRING_R" - - } - - # - Print all input string on same line - # - $1 = start printing from word number $1 - Print_Input_String(){ - - for (( i=$1;i<${#aINPUT_STRING[@]} ;i++)) - do - echo -ne " ${aINPUT_STRING[${i}]}" - done - - echo -e "" - - # echo -e "SIZE = ${#aINPUT_STRING}" - - # aINPUT_STRING="$@" - # for (( i=$1;i<${#aINPUT_STRING} ;i++)) - # do - # echo -ne "${aINPUT_STRING:$i:1}" - # sleep 0.02 - # done - - } - - #///////////////////////////////////////////////////////////////////////////////////// - # Main Loop - #///////////////////////////////////////////////////////////////////////////////////// - #-------------------------------------------------------------------------------------- - #Exit code, print OK or Failed - #$2 = exit code - # - Use this at end of DietPi scripts, EG: /DietPi/dietpi/func/dietpi-notify -1 ${EXIT_CODE:=0} - if (( $1 == -1 )); then - - if [ "$2" = "0" ]; then - - aINPUT_STRING+=("Completed") - Print_Ok - Print_Input_String 2 - echo -e "" - - else - - aINPUT_STRING+=("An issue has occured") - Print_Failed - Print_Input_String 2 - echo -e "" - - fi - - #-------------------------------------------------------------------------------------- - #Status Ok - #$@ = txt desc - elif (( $1 == 0 )); then - - Print_Ok - Print_Input_String 1 - - #Status failed - #$@ = txt desc - elif (( $1 == 1 )); then - - Print_Failed - Print_Input_String 1 - - #Status Info - #$@ = txt desc - elif (( $1 == 2 )); then - - echo -ne " $BRACKET_STRING_L\e[0mInfo\e[0m$BRACKET_STRING_R" - echo -ne "\e[90m" - Print_Input_String 1 - echo -ne "\e[0m" - - #DietPi banner style - #$2 = txt program name - #$3 = txt mode - elif (( $1 == 3 )); then - - echo -e "\n \e[38;5;154m$2\e[0m" - echo -e "$HEADER_LINE" - echo -e " \e[90mMode:\e[0m$(Print_Input_String 2)" - echo -e " \e[90mPlease wait...\e[0m\n" - - fi - #----------------------------------------------------------------------------------- - unset aINPUT_STRING - #----------------------------------------------------------------------------------- - exit - #----------------------------------------------------------------------------------- -} diff --git a/dietpi/func/dietpi-optimal_mtu b/dietpi/func/dietpi-optimal_mtu index 72474118cb..94ef856155 100644 --- a/dietpi/func/dietpi-optimal_mtu +++ b/dietpi/func/dietpi-optimal_mtu @@ -15,17 +15,17 @@ # - dietpi-optimal_mtu URL/IP address | Tests using the provided URL/IP #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - + #Grab Input URL='www.google.com' if [ "$1" != "" ]; then URL="$1" fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + export G_PROGRAM_NAME='DietPi-Optimal_mtu' + #Import DietPi-Globals --------------------------------------------------------------- + MTU_SIZE=1500 TEST_MTU_SIZE=0 SUCCESS=0 diff --git a/dietpi/func/dietpi-set_core_environment b/dietpi/func/dietpi-set_core_environment new file mode 100644 index 0000000000..549b0c8d1d --- /dev/null +++ b/dietpi/func/dietpi-set_core_environment @@ -0,0 +1,374 @@ +#!/bin/bash +{ + #//////////////////////////////////// + # DietPi Function: + # - Configures core/basic folders/permissions/services etc for DietPi a environment + # + #//////////////////////////////////// + # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com + # + #//////////////////////////////////// + # + # Info: + # - Script does not require a DietPi ready system to exec, can be used in PREP_SYSTEM + # - DietPi sourcecode must exist in /boot or /DietPi + # - Not everything for the DietPi env is contained here, only the core/critial stuff, to prevent dupe code in patches/PREP_SYSTEM + # + # Usage: + # - /boot/dietpi/func/dietpi-set_core_environment + # - /DietPi/dietpi/func/dietpi-set_core_environment + #//////////////////////////////////// + + #Support Globals loaded on non-dietpi systems + FP_SCRIPTS='/boot' + if [ -f /DietPi/dietpi/dietpi-software ]; then + + FP_SCRIPTS='/DietPi' + + fi + + #Import DietPi-Globals ------------------------------------------------------------- + . $FP_SCRIPTS/dietpi/func/dietpi-globals # NB: HW_* info are init only, not detected. + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Set_core_environment' + #Import DietPi-Globals ------------------------------------------------------------- + + + DIETPI_USERNAME='dietpi' + DIETPI_PASSWORD='dietpi' + + #Near copy of useradd in dietpi-set_software, however, to support use in non-dietpi ready system, we manually need it here. + Create_DietPi_User(){ + + mkdir -p /home/"$DIETPI_USERNAME" + useradd -m -s /bin/bash "$DIETPI_USERNAME" + chpasswd <<< "$DIETPI_USERNAME:$DIETPI_PASSWORD" + + # Copy existing profile/bashrc + cp /root/.profile /home/"$DIETPI_USERNAME"/ + cp /root/.bashrc /home/"$DIETPI_USERNAME"/ + + # Sudo up dietpi login script + sed -i '/^\/DietPi\/dietpi\/login/c\sudo \/DietPi\/dietpi\/login' /home/$DIETPI_USERNAME/.bashrc + + chown -R "$DIETPI_USERNAME":"$DIETPI_USERNAME" /home/"$DIETPI_USERNAME" + + # Allow sudo without pw + if (( ! $(cat /etc/sudoers | grep -ci -m1 "^$DIETPI_USERNAME[[:space:]]") )); then + + cat << _EOF_ >> /etc/sudoers +$DIETPI_USERNAME ALL=NOPASSWD: ALL +_EOF_ + + fi + + # Same groups as user pi + local group_array=() + group_array+=('input') + group_array+=('netdev') + group_array+=('spi') + group_array+=('i2c') + group_array+=('gpio') + group_array+=('tty') + group_array+=('users') + group_array+=('games') + group_array+=('plugdev') + group_array+=('video') + group_array+=('audio') + group_array+=('sudo') + group_array+=('cdrom') + group_array+=('dialout') + group_array+=('adm') + + # + allow access to www-data + group_array+=('www-data') + + for ((i=0; i<${#group_array[@]}; i++)) + do + + usermod -a -G ${group_array[$i]} $DIETPI_USERNAME &> /dev/null + + done + + unset group_array + + } + + #/////////////////////////////////////////////////////////////////////////////////// + # Main Loop + #/////////////////////////////////////////////////////////////////////////////////// + G_DIETPI-NOTIFY 2 "Creating core DietPi environment, please wait..." + + #----------------------------------------------------------------------------------- + #Bash + + G_DIETPI-NOTIFY 2 "Configuring .bashrc:" + + sed -i '/DietPi/d' /root/.bashrc + cat << _EOF_ >> /root/.bashrc +/DietPi/dietpi/login +. /DietPi/dietpi/func/dietpi-globals +_EOF_ + +# G_DIETPI-NOTIFY 2 "Configuring /etc/bash.bashrc:" # Moved into dietpi-globals + + #----------------------------------------------------------------------------------- + #Create_DietPi_User + + G_DIETPI-NOTIFY 2 'Creating DietPi User Account:' + + Create_DietPi_User + + #----------------------------------------------------------------------------------- + #UID bit for sudo + # - https://github.com/Fourdee/DietPi/issues/794 + + G_DIETPI-NOTIFY 2 'Configuring Sudo UID bit:' + + chmod 4755 $(which sudo) + + #----------------------------------------------------------------------------------- + #Dir's + + G_DIETPI-NOTIFY 2 'Configuring DietPi Directories:' + + # - /var/lib/dietpi : Core storage for installed non-standard APT software, outside of /mnt/dietpi_userdata + mkdir -p /var/lib/dietpi + 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/lib/dietpi/dietpi-ramlog + mkdir -p /var/lib/dietpi/dietpi-ramlog/storage + + #mkdir -p /var/lib/dietpi/dietpi-software + mkdir -p /var/lib/dietpi/dietpi-software/services #non systemd custom services for installed software + mkdir -p /var/lib/dietpi/dietpi-software/installed #Additional storage for installed apps, eg: custom scripts and data + + # - /var/tmp/dietpi : Temp storage saved during reboots, eg: logs outside of /var/log + mkdir -p /var/tmp/dietpi/logs + chown dietpi:dietpi /var/tmp/dietpi + chmod 660 /var/tmp/dietpi + + # - /DietPi RAMdisk + mkdir -p /DietPi + chown dietpi:dietpi /DietPi + 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" + + # - Networked drives + mkdir -p /mnt/samba + mkdir -p /mnt/ftp_client + mkdir -p /mnt/nfs_client + + #----------------------------------------------------------------------------------- + #Services + + G_DIETPI-NOTIFY 2 'Configuring DietPi Services:' + + cat << _EOF_ > /etc/systemd/system/dietpi-ramdisk.service +[Unit] +Description=DietPi-RAMdisk +Before=rsyslog.service syslog.service +After=local-fs.target boot.mount + +[Service] +Type=forking +RemainAfterExit=yes +ExecStart=/bin/bash -c '/boot/dietpi/dietpi-ramdisk 0 &>> /var/tmp/dietpi/logs/dietpi-ramdisk.log' +ExecStop=/bin/bash -c '/DietPi/dietpi/dietpi-ramdisk 1 &>> /var/tmp/dietpi/logs/dietpi-ramdisk.log' + +[Install] +WantedBy=local-fs.target +_EOF_ + systemctl daemon-reload + systemctl enable dietpi-ramdisk.service + + cat << _EOF_ > /etc/systemd/system/dietpi-ramlog.service +[Unit] +Description=DietPi-RAMlog +Before=rsyslog.service syslog.service +After=local-fs.target boot.mount + +[Service] +Type=forking +RemainAfterExit=yes +ExecStart=/bin/bash -c '/boot/dietpi/dietpi-ramlog 0 &>> /var/tmp/dietpi/logs/dietpi-ramlog.log' +ExecStop=/bin/bash -c '/DietPi/dietpi/dietpi-ramlog 1 &>> /var/tmp/dietpi/logs/dietpi-ramlog.log' + +[Install] +WantedBy=local-fs.target +_EOF_ + systemctl daemon-reload + systemctl enable dietpi-ramlog.service + + cat << _EOF_ > /etc/systemd/system/dietpi-boot.service +[Unit] +Description=DietPi-Boot +After=network-online.target network.target networking.service dietpi-ramdisk.service dietpi-ramlog.service +Requires=dietpi-ramdisk.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/bash -c '/DietPi/dietpi/boot' +StandardOutput=tty + +[Install] +WantedBy=multi-user.target +_EOF_ + systemctl enable dietpi-boot.service + systemctl daemon-reload + + update-rc.d -f rc.local remove &> /dev/null + rm /etc/init.d/rc.local &> /dev/null + rm /lib/systemd/system/rc-local.service &> /dev/null + cat << _EOF_ > /etc/systemd/system/rc-local.service +[Unit] +Description=/etc/rc.local Compatibility +After=dietpi-boot.service dietpi-ramdisk.service dietpi-ramlog.service +Requires=dietpi-boot.service dietpi-ramdisk.service + +[Service] +Type=idle +ExecStart=/etc/rc.local +StandardOutput=tty +RemainAfterExit=yes + +[Install] +WantedBy=multi-user.target +_EOF_ + systemctl enable rc-local.service + systemctl daemon-reload + + cat << _EOF_ > /etc/rc.local +#!/bin/bash +#Precaution: Wait for DietPi Ramdisk to finish +while [ ! -f /DietPi/.ramdisk ] +do + + G_DIETPI-NOTIFY 2 "Waiting for DietPi-RAMDISK to finish mounting DietPi to RAM..." + sleep 1 + +done + +echo -e "\$(cat /proc/uptime | awk '{print \$1}') Seconds" > /var/log/boottime +if (( \$(cat /DietPi/dietpi/.install_stage) == 1 )); then + + /DietPi/dietpi/dietpi-services start + +fi +/DietPi/dietpi/dietpi-banner 0 +echo -e " Default Login:\n Username = root\n Password = dietpi\n" +echo -e " Please login to continue\n" +exit 0 +_EOF_ + chmod +x /etc/rc.local + systemctl daemon-reload + + cat << _EOF_ > /etc/systemd/system/kill-ssh-user-sessions-before-network.service +[Unit] +Description=Shutdown all ssh sessions before network +DefaultDependencies=no +Before=network.target shutdown.target + +[Service] +Type=oneshot +ExecStart=/bin/bash -c '/var/lib/dietpi/dietpi-software/services/kill-ssh-user-sessions-before-network.sh' + +[Install] +WantedBy=poweroff.target halt.target reboot.target +_EOF_ + systemctl daemon-reload + systemctl enable kill-ssh-user-sessions-before-network + + cat << _EOF_ > /var/lib/dietpi/dietpi-software/services/kill-ssh-user-sessions-before-network.sh +#!/bin/bash +if (( \$(ps x | grep -ci -m1 '[s]shd' ) )); then + + killall -w sshd + +elif (( \$(ps x | grep -ci -m1 '[d]ropbear' ) )); then + + killall -w dropbear + +fi + +exit 0 +_EOF_ + chmod +x /var/lib/dietpi/dietpi-software/services/kill-ssh-user-sessions-before-network.sh + + #----------------------------------------------------------------------------------- + #Cron Jobs + + G_DIETPI-NOTIFY 2 "Configuring Cron:" + + cp $FP_SCRIPTS/dietpi/conf/cron.daily_dietpi /etc/cron.daily/dietpi + chmod +x /etc/cron.daily/dietpi + cp $FP_SCRIPTS/dietpi/conf/cron.hourly_dietpi /etc/cron.hourly/dietpi + chmod +x /etc/cron.hourly/dietpi + + cat << _EOF_ > /etc/crontab +#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 +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_ + + # - ntp + rm /etc/cron.daily/ntp &> /dev/null + + #----------------------------------------------------------------------------------- + #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 + # x86_64: kernel cmd line with GRUB + # HW_ARCH not set at this stage within DietPi, using PREP_SYSTEM + if [ -f /etc/default/grub ]; then + + sed -i '/^GRUB_CMDLINE_LINUX_DEFAULT=/c\GRUB_CMDLINE_LINUX_DEFAULT="consoleblank=0 quiet"' /etc/default/grub #ipv6.disable=1 # https://github.com/Fourdee/DietPi/pull/1419#issuecomment-360452027 + sed -i '/^GRUB_CMDLINE_LINUX=/c\GRUB_CMDLINE_LINUX="net.ifnames=0"' /etc/default/grub + sed -i '/^GRUB_TIMEOUT=/c\GRUB_TIMEOUT=0' /etc/default/grub + update-grub + + fi + + #----------------------------------------------------------------------------------- + #MISC + + G_DIETPI-NOTIFY 2 "Disabling apt-daily services on Stretch+ (prevents random APT cache lock):" + + if (( $G_DISTRO > 3 )); then + + 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 + + fi + + G_DIETPI-NOTIFY 2 "Setting vm.swappiness=1:" + + sed -i '/^[[:blank:]]*vm.swappiness=/d' /etc/sysctl.conf + echo -e "vm.swappiness=1" > /etc/sysctl.d/99-dietpi.conf + + #----------------------------------------------------------------------------------- + G_DIETPI-NOTIFY 0 "Completed DietPi core environment" + exit + #----------------------------------------------------------------------------------- +} diff --git a/dietpi/func/dietpi-set_curlftpfs b/dietpi/func/dietpi-set_curlftpfs index 7fedfa3a22..b2368de29e 100644 --- a/dietpi/func/dietpi-set_curlftpfs +++ b/dietpi/func/dietpi-set_curlftpfs @@ -19,25 +19,25 @@ # - /DietPi/dietpi/func/dietpi-set_curlftpfs 1 = Apply and mount using settings in dietpi.txt #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - + #Grab Input INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then INPUT=$1 fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + export G_PROGRAM_NAME='DietPi-Set_curlftpfs' + #Import DietPi-Globals --------------------------------------------------------------- + #///////////////////////////////////////////////////////////////////////////////////// #curlftpfs data #///////////////////////////////////////////////////////////////////////////////////// OPTION=0 CHOICE=0 - curlftpfs_clientaddress=$(cat /DietPi/dietpi.txt | grep -m1 '^curlftpfs_clientaddress' | sed 's/.*=//') - curlftpfs_clientusername=$(cat /DietPi/dietpi.txt | grep -m1 '^curlftpfs_clientusername' | sed 's/.*=//') - curlftpfs_clientpassword=$(cat /DietPi/dietpi.txt | grep -m1 '^curlftpfs_clientpassword' | sed 's/.*=//') + curlftpfs_clientaddress=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CURLFTPFS_ADDRESS=' | sed 's/.*=//') + curlftpfs_clientusername=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CURLFTPFS_USERNAME=' | sed 's/.*=//') + curlftpfs_clientpassword=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_CURLFTPFS_PASSWORD=' | sed 's/.*=//') Apply_And_Mount(){ @@ -78,9 +78,9 @@ umount /mnt/ftp_client &> /dev/null #Save to Dietpi.txt - sed -i "/curlftpfs_clientaddress/c\curlftpfs_clientaddress=$curlftpfs_clientaddress" /DietPi/dietpi.txt - sed -i "/curlftpfs_clientusername/c\curlftpfs_clientusername=$curlftpfs_clientusername" /DietPi/dietpi.txt - sed -i "/curlftpfs_clientpassword/c\curlftpfs_clientpassword=$curlftpfs_clientpassword" /DietPi/dietpi.txt + sed -i "/CONFIG_CURLFTPFS_ADDRESS/c\CONFIG_CURLFTPFS_ADDRESS=$curlftpfs_clientaddress" /DietPi/dietpi.txt + sed -i "/CONFIG_CURLFTPFS_USERNAME/c\CONFIG_CURLFTPFS_USERNAME=$curlftpfs_clientusername" /DietPi/dietpi.txt + sed -i "/CONFIG_CURLFTPFS_PASSWORD/c\CONFIG_CURLFTPFS_PASSWORD=$curlftpfs_clientpassword" /DietPi/dietpi.txt Apply_And_Mount fi diff --git a/dietpi/func/dietpi-set_dphys-swapfile b/dietpi/func/dietpi-set_dphys-swapfile index f32e7afda3..a537b9a967 100644 --- a/dietpi/func/dietpi-set_dphys-swapfile +++ b/dietpi/func/dietpi-set_dphys-swapfile @@ -21,14 +21,20 @@ # - /DietPi/dietpi/func/dietpi-set_dphys-swapfile >=2 /var/swap = Enable + Set Size + Set new Location (also deletes previous swapfile) #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-dphys-swapfile' + #Import DietPi-Globals --------------------------------------------------------------- - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" + SWAP_SIZE_CURRENT=0 + SWAP_LOCATION_CURRENT='/var/swap' + if [ -f /etc/dphys-swapfile ]; then - SWAP_SIZE_CURRENT=$(cat /etc/dphys-swapfile | grep -m1 '^CONF_SWAPSIZE=' | sed 's/.*=//') - SWAP_LOCATION_CURRENT=$(cat /etc/dphys-swapfile | grep -m1 '^CONF_SWAPFILE=' | sed 's/.*=//') + SWAP_SIZE_CURRENT=$(cat /etc/dphys-swapfile | grep -m1 '^CONF_SWAPSIZE=' | sed 's/.*=//') + SWAP_LOCATION_CURRENT=$(cat /etc/dphys-swapfile | grep -m1 '^CONF_SWAPFILE=' | sed 's/.*=//') + + fi SWAP_SIZE_TARGET=$SWAP_SIZE_CURRENT if [[ $1 =~ ^-?[0-9]+$ ]]; then @@ -42,26 +48,40 @@ SERVICE_MODE="" + Generate_Default_Conf(){ + + cat << _EOF_ > /etc/dphys-swapfile +CONF_SWAPSIZE=0 +CONF_SWAPFILE=/var/swap +_EOF_ + + } + Delete_Swapfile(){ - /DietPi/dietpi/func/dietpi-notify 2 "Deleting existing swapfile ($SWAP_LOCATION_CURRENT)\n" + + G_DIETPI-NOTIFY 2 "Deleting existing swapfile ($SWAP_LOCATION_CURRENT)\n" rm "$SWAP_LOCATION_CURRENT" &> /dev/null + } Update_Conf(){ + sed -i "/CONF_SWAPSIZE/c\CONF_SWAPSIZE=$SWAP_SIZE_TARGET" /etc/dphys-swapfile sed -i "/CONF_SWAPFILE/c\CONF_SWAPFILE=$SWAP_LOCATION_TARGET" /etc/dphys-swapfile # DietPi.txt - sed -i "/^Swapfile_Size=/c\Swapfile_Size=$SWAP_SIZE_TARGET" /DietPi/dietpi.txt + sed -i "/^AUTO_SETUP_SWAPFILE_SIZE=/c\AUTO_SETUP_SWAPFILE_SIZE=$SWAP_SIZE_TARGET" /DietPi/dietpi.txt } Swap_Disable(){ - /DietPi/dietpi/func/dietpi-notify 3 DietPi Disable swapfile + G_DIETPI-NOTIFY 3 DietPi Disable swapfile SWAP_SIZE_TARGET=0 SERVICE_MODE="disable" + + Generate_Default_Conf dphys-swapfile swapoff Delete_Swapfile @@ -71,11 +91,12 @@ Swap_Enable(){ - /DietPi/dietpi/func/dietpi-notify 3 DietPi Generating new swapfile - /DietPi/dietpi/func/dietpi-notify 2 "Size = $SWAP_SIZE_TARGET MB" - /DietPi/dietpi/func/dietpi-notify 2 "Location = $SWAP_LOCATION_TARGET" + G_DIETPI-NOTIFY 3 DietPi Generating new swapfile + G_DIETPI-NOTIFY 2 "Size = $SWAP_SIZE_TARGET MB" + G_DIETPI-NOTIFY 2 "Location = $SWAP_LOCATION_TARGET" SERVICE_MODE="enable" + Generate_Default_Conf dphys-swapfile swapoff Delete_Swapfile @@ -126,7 +147,7 @@ systemctl "$SERVICE_MODE" dphys-swapfile - /DietPi/dietpi/func/dietpi-notify 2 "Completed\n" + G_DIETPI-NOTIFY 2 "Completed\n" fi #----------------------------------------------------------------------------------- diff --git a/dietpi/func/dietpi-set_hardware b/dietpi/func/dietpi-set_hardware index 3205a3cd78..b1dd66c062 100644 --- a/dietpi/func/dietpi-set_hardware +++ b/dietpi/func/dietpi-set_hardware @@ -10,46 +10,48 @@ #//////////////////////////////////// # # Usage: - # - /DietPi/dietpi/func/dietpi-set_hardware rpi3_usb_boot enable - # - /DietPi/dietpi/func/dietpi-set_hardware rpi-camera enable/disable - # - /DietPi/dietpi/func/dietpi-set_hardware gpumemsplit 64/128/256 #RPi only - # - /DietPi/dietpi/func/dietpi-set_hardware remoteir odroid_remote/justboom_ir_remote - # - /DietPi/dietpi/func/dietpi-set_hardware kernel ??see sourcode - # - /DietPi/dietpi/func/dietpi-set_hardware eth-forcespeed 10/100/1000/disable - # - /DietPi/dietpi/func/dietpi-set_hardware rpi-opengl enable/disable - # - /DietPi/dietpi/func/dietpi-set_hardware i2c enable/disable/khz - # - /DietPi/dietpi/func/dietpi-set_hardware wificountrycode code - # - /DietPi/dietpi/func/dietpi-set_hardware wifimodules enable/disable/onboard_enable/onboard_disable - # - /DietPi/dietpi/func/dietpi-set_hardware wificreds set | Generates wpa_supplicant.conf from dietpi.txt globals - # - /DietPi/dietpi/func/dietpi-set_hardware preferipversion auto/ipv4/ipv6 - # - /DietPi/dietpi/func/dietpi-set_hardware bluetooth enable/disable - # - /DietPi/dietpi/func/dietpi-set_hardware serialconsole enable/disable - # - /DietPi/dietpi/func/dietpi-set_hardware 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) - # - /DietPi/dietpi/func/dietpi-set_hardware lcdpanel target_panel (none to remove all) + 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 kernel ??see sourcode +$FP_SCRIPT eth-forcespeed 10/100/1000/disable +$FP_SCRIPT rpi-opengl enable/disable +$FP_SCRIPT i2c enable/disable/khz +$FP_SCRIPT wificountrycode code +$FP_SCRIPT wifimodules enable/disable/onboard_enable/onboard_disable +$FP_SCRIPT wificreds set | Generates wpa_supplicant.conf from dietpi.txt globals +$FP_SCRIPT preferipversion auto/ipv4/ipv6 +$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 lcdpanel target_panel (none to remove all) +" #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 + #Grab Inputs + INPUT_DEVICE_NAME=$(echo -e "$1" | tr '[:upper:]' '[:lower:]') + INPUT_DEVICE_VALUE=$(echo -e "$2" | tr '[:upper:]' '[:lower:]') + # - support for 0/1 inputs for enable/disable + if [ "$INPUT_DEVICE_VALUE" = "1" ]; then - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" + INPUT_DEVICE_VALUE='enable' - #Exit path for non-root logins. - if (( $UID != 0 )); then + elif [ "$INPUT_DEVICE_VALUE" = "0" ]; then - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit + INPUT_DEVICE_VALUE='disable' fi - #RootFS RW check - /DietPi/dietpi/dietpi-drive_manager 3 - if (( $? != 0 )); then - - exit - - fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Set_Hardware' + #Import DietPi-Globals --------------------------------------------------------------- #Semi support non-dietpi Raspbian FP_RPI_CONFIG='/DietPi/config.txt' @@ -59,39 +61,23 @@ fi - INPUT_DEVICE_NAME=$(echo -e "$1" | tr '[:upper:]' '[:lower:]') - INPUT_DEVICE_VALUE=$(echo -e "$2" | tr '[:upper:]' '[:lower:]') - - #support for 0/1 inputs for enable/disable - if [ "$INPUT_DEVICE_VALUE" = "1" ]; then - - INPUT_DEVICE_VALUE='enable' - - elif [ "$INPUT_DEVICE_VALUE" = "0" ]; then - - INPUT_DEVICE_VALUE='disable' - - fi - EXIT_CODE=0 - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) - HW_ARCH=$(sed -n 6p /DietPi/dietpi/.hw_model) - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) - HW_CPUID=$(sed -n 9p /DietPi/dietpi/.hw_model) HW_ONBOARD_WIFI=$(sed -n 10p /DietPi/dietpi/.hw_model) Unknown_Input_Name(){ EXIT_CODE=1 - /DietPi/dietpi/func/dietpi-notify 2 "Unknown input name ($INPUT_DEVICE_NAME). Nothing has been applied." + G_DIETPI-NOTIFY 2 "Unknown input name ($INPUT_DEVICE_NAME). Nothing has been applied." + + echo -e "$AVAIABLE_COMMANDS" } Unknown_Input_Mode(){ EXIT_CODE=1 - /DietPi/dietpi/func/dietpi-notify 2 "Unknown input value ($INPUT_DEVICE_VALUE). Nothing has been applied." + G_DIETPI-NOTIFY 2 "Unknown input value ($INPUT_DEVICE_VALUE). Nothing has been applied." } @@ -203,10 +189,10 @@ systemctl enable dietpi-rm_program_usb_boot_mode.service # - LIRC if (( ! $(dpkg --get-selections | grep -ci -m1 '^lirc') )); then - apt-get install -y lirc + G_AGI lirc if (( $? != 0 )); then - /DietPi/dietpi/func/dietpi-notify 1 "apt-get install lirc" + G_DIETPI-NOTIFY 1 "apt-get install lirc" EXIT_CODE=1 fi @@ -240,7 +226,7 @@ systemctl enable dietpi-rm_program_usb_boot_mode.service RemoteIR_Reset_All &> /dev/null # - xu4 Cloudshell - if (( $HW_MODEL == 11 )); then + if (( $G_HW_MODEL == 11 )); then # - modules local string="options gpioplug_ir_recv gpio_nr=24 active_low=1" @@ -265,7 +251,7 @@ systemctl enable dietpi-rm_program_usb_boot_mode.service fi # - c1/c2 - elif (( $HW_MODEL == 10 || $HW_MODEL == 12 )); then + elif (( $G_HW_MODEL == 10 || $G_HW_MODEL == 12 )); then # - Module if (( ! $(cat /etc/modules | grep -ci -m1 '^meson_ir') )); then @@ -396,7 +382,7 @@ _EOF_ # + MPD control if (( ! $(dpkg --get-selections | grep -ci -m1 '^mpc[[:space:]]') )); then - apt-get install -y mpc + G_AGI mpc fi @@ -479,131 +465,6 @@ _EOF_ } - #///////////////////////////////////////////////////////////////////////////////////// - #Kernel - #///////////////////////////////////////////////////////////////////////////////////// - Kernel_Main(){ - - if [[ "$INPUT_DEVICE_VALUE" = "dietpi_rpi"* ]]; then - - local update_required=1 - local current_kernel='4.9.62-' - - #Avoid updating main kernel, if latest is already installed - if (( $(uname -r | grep -ci -m1 "$current_kernel") )); then - - update_required=0 - - fi - - # Default - local install_url_address='http://dietpi.com/downloads/binaries/rpi/dietpi_rpi_kernel_4.9.zip' - if [ "$INPUT_DEVICE_VALUE" = "dietpi_rpi_4.4" ]; then - - install_url_address='http://dietpi.com/downloads/binaries/rpi/dietpi_rpi_kernel_4.4.zip' - update_required=1 #Always update alternative kernel - - elif [ "$INPUT_DEVICE_VALUE" = "dietpi_rpi_rt" ]; then - - install_url_address='http://dietpi.com/downloads/binaries/rpi/dietpi_rpi_kernel_rt.zip' - update_required=1 #Always update alternative kernel - - fi - - if (( $update_required )); then - - /DietPi/dietpi/func/check_connection "$install_url_address" - - # Install - if (( $? == 0 )); then - - # - Prevent kernel/firmware/bootloader upgrades from Raspbian repo - apt-mark hold raspberrypi-bootloader raspberrypi-kernel - - wget "$install_url_address" -O package.zip - # Cleanup disabled: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298343932 - # rm -R /boot/overlays/* - # rm -R /lib/modules/* - # rm -R /lib/firmware/* - # rm /boot/*.img - - unzip -o package.zip -d / - if (( $? != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 "Failed to extract $INPUT_DEVICE_NAME." - - fi - - rm package.zip - - # - flag - echo 1 > /etc/dietpi/.dietpi_rpi - - else - - /DietPi/dietpi/func/dietpi-notify 1 "Failed to install $INPUT_DEVICE_NAME. $install_url_address may be offline or unreachable." - - fi - - else - - /DietPi/dietpi/func/dietpi-notify 2 "$INPUT_DEVICE_NAME: Currently running latest kernel, no updates required." - - fi - - elif [[ "$INPUT_DEVICE_VALUE" = "sparky_sbc"* ]]; then - - local install_url_address='http://dietpi.com/downloads/binaries/sparky/sparky_kernel.zip' - - # if [ "$INPUT_DEVICE_VALUE" = "sparky_sbc_rt" ]; then - - # install_url_address='http://dietpi.com/downloads/binaries/sparky/sparky_kernel_rt.zip' - - # fi - - /DietPi/dietpi/func/check_connection "$install_url_address" - if (( $? == 0 )); then - - wget "$install_url_address" -O package.zip - - unzip -o package.zip -d / - if (( $? != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 "Failed to extract kernel $INPUT_DEVICE_NAME." - - fi - - rm package.zip - - fi - - elif [ "$INPUT_DEVICE_VALUE" = "nanopim3" ]; then - - local install_url_address='http://dietpi.com/downloads/binaries/nanopi/dietpi_m3_kernel.7z' - - /DietPi/dietpi/func/check_connection "$install_url_address" - - # Install - if (( $? == 0 )); then - - wget "$install_url_address" -O package.7z - 7z x -y package.7z -o/ - rm package.7z - - else - - /DietPi/dietpi/func/dietpi-notify 1 "Failed to install $INPUT_DEVICE_NAME. $install_url_address may be offline or unreachable." - - fi - - else - - Unknown_Input_Mode - - fi - - } - #///////////////////////////////////////////////////////////////////////////////////// #Ethernet force link speed #///////////////////////////////////////////////////////////////////////////////////// @@ -650,7 +511,7 @@ _EOF_ if [ "$INPUT_DEVICE_VALUE" = "enable" ]; then #RPi 2/3+ only - if (( $HW_MODEL >= 2 && $HW_MODEL < 10 )); then + if (( $G_HW_MODEL >= 2 && $G_HW_MODEL < 10 )); then #install pre-reqs @@ -658,16 +519,16 @@ _EOF_ /DietPi/dietpi/dietpi-software install 6 # - GL packages - /DietPi/dietpi/func/dietpi-notify 2 "Installing additional OpenGL packages, please wait...\n" + G_DIETPI-NOTIFY 2 "Installing additional OpenGL packages, please wait...\n" sleep 1 - apt-get install -y libgl1-mesa-dri mesa-utils + G_AGI libgl1-mesa-dri mesa-utils sed -i '/dtoverlay=vc4-kms-v3d/d' "$FP_RPI_CONFIG" echo -e "\ndtoverlay=vc4-kms-v3d" >> "$FP_RPI_CONFIG" else - /DietPi/dietpi/func/dietpi-notify 1 "OpenGL requires a RPi 2 or higher" + G_DIETPI-NOTIFY 1 "OpenGL requires a RPi 2 or higher" sleep 2 fi @@ -690,7 +551,7 @@ _EOF_ Lcd_Panel_Not_Available_For_Device(){ EXIT_CODE=1 - /DietPi/dietpi/func/dietpi-notify 2 "$INPUT_DEVICE_VALUE is not available for this device. Nothing has been applied." + G_DIETPI-NOTIFY 2 "$INPUT_DEVICE_VALUE is not available for this device. Nothing has been applied." } @@ -727,7 +588,7 @@ _EOF_ #Update dietpi.txt entry? if (( $update_dietpitxt )); then - sed -i "/^lcdpanel=/c\lcdpanel=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt + sed -i "/^CONFIG_LCDPANEL=/c\CONFIG_LCDPANEL=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt fi @@ -736,7 +597,7 @@ _EOF_ Lcd_Panel_Xorg_All_Enable(){ #Xinput calibrator - apt-get install -y xinput-calibrator + G_AGI xinput-calibrator mkdir -p /etc/X11/xorg.conf.d @@ -787,7 +648,7 @@ _EOF_ Lcd_Panel_Waveshare32_Disable #RPi - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then # + X11 Lcd_Panel_Xorg_All_Enable @@ -817,7 +678,7 @@ _EOF_ mv /usr/share/X11/xorg.conf.d/99-fbturbo.conf /usr/share/X11/99-fbturbo.conf #Odroids - elif (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then + elif (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )); then # + X11 Lcd_Panel_Xorg_All_Enable @@ -877,7 +738,7 @@ _EOF_ rm /usr/share/applications/xinput_calibrator.desktop #RPi - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then rm /boot/overlays/waveshare32b.dtbo sed -i 's/ fbcon=map:10 fbcon=font:ProFont6x11 logo.nologo//' /boot/cmdline.txt @@ -895,7 +756,7 @@ _EOF_ mv /usr/share/X11/99-fbturbo.conf /usr/share/X11/xorg.conf.d/99-fbturbo.conf #Odroids - elif (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then + elif (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )); then rm /etc/systemd/system/con2fbmap.service systemctl daemon-reload @@ -937,7 +798,7 @@ _EOF_ # - Odroid LCD 3.5 Lcd_Panel_OdroidLCD35_Enable(){ - if (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then + if (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )); then #Reset to disabled: Lcd_Panel_OdroidLCD35_Disable @@ -952,7 +813,7 @@ _EOF_ if (( ! $(cat /etc/modules | grep -ci -m1 'flexfb') )); then # - XU4 - if (( $HW_MODEL == 11 )); then + if (( $G_HW_MODEL == 11 )); then cat << _EOF_ >> /etc/modules fbtft_device @@ -981,7 +842,7 @@ _EOF_ #Service # - XU4 - if (( $HW_MODEL == 11 )); then + if (( $G_HW_MODEL == 11 )); then cat << _EOF_ > /etc/systemd/system/odroid-lcd35.service [Unit] @@ -1082,9 +943,9 @@ _EOF_ #Check/install pre-reqs if (( $(dpkg -l | grep -ci -m1 'i2c-tools') == 0 )); then - /DietPi/dietpi/func/dietpi-notify 2 "Installing Python-smbus, i2c-tools, pre-reqs.\nPlease wait...\n" + G_DIETPI-NOTIFY 2 "Installing Python-smbus, i2c-tools, pre-reqs.\nPlease wait...\n" sleep 1 - apt-get install python-smbus i2c-tools -y + G_AGI python-smbus i2c-tools fi @@ -1155,7 +1016,7 @@ _EOF_ if [ "$INPUT_DEVICE_VALUE" = "disable" ]; then # + all Broadcom-based models that need brcm_patchram_plus - if (( $HW_MODEL == 61 || $HW_MODEL == 62 )); then + if (( $G_HW_MODEL == 61 || $G_HW_MODEL == 62 )); then systemctl stop brcm_patchram_plus 2> /dev/null systemctl disable brcm_patchram_plus 2> /dev/null @@ -1164,7 +1025,7 @@ _EOF_ # + RPi 3 (apply to all, as pi-bluetooth package is default installed on all RPi's now) # + Asus TB - if (( $HW_MODEL < 10 || $HW_MODEL == 100 )); then + if (( $G_HW_MODEL < 10 || $G_HW_MODEL == 52 )); then systemctl stop hciuart systemctl disable hciuart @@ -1173,12 +1034,6 @@ _EOF_ #bluetooth last systemctl stop bluetooth 2> /dev/null - if (( $? != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 2 "Bluetooth service failed to stop. Is it installed?" - EXIT_CODE=1 - - fi systemctl disable bluetooth 2> /dev/null for ((i=$(( ${#aBLUETOOTH_MODULES[@]} - 1 )); i>=0; i--)) @@ -1189,9 +1044,25 @@ _EOF_ done + #Purge packages + if (( $G_DIETPI_INSTALL_STAGE >= 0 )); then + + G_AGP bluetooth bluez-firmware + G_AGA + + fi + # - Enable elif [ "$INPUT_DEVICE_VALUE" = "enable" ]; then + #Pre-Reqs + G_AG_CHECK_INSTALL_PREREQ bluetooth bluez-firmware + if (( $G_HW_MODEL < 10 )); then + + G_AG_CHECK_INSTALL_PREREQ pi-bluetooth + + fi + #bluetooth first for ((i=0; i<${#aBLUETOOTH_MODULES[@]}; i++)) do @@ -1201,70 +1072,21 @@ _EOF_ done # + all Broadcom-based models that need brcm_patchram_plus - if (( $HW_MODEL == 61 || $HW_MODEL == 62 )); then + if (( $G_HW_MODEL == 61 || $G_HW_MODEL == 62 )); then systemctl enable brcm_patchram_plus 2> /dev/null - systemctl start brcm_patchram_plus 2> /dev/null - if (( $? != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 2 "brcm_patchram_plus service failed to start. Is it installed?" - EXIT_CODE=1 - - fi + G_RUN_CMD systemctl start brcm_patchram_plus fi systemctl enable bluetooth 2> /dev/null - systemctl start bluetooth 2> /dev/null - if (( $? != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 2 "Bluetooth service failed to start. Is it installed?" - EXIT_CODE=1 - - fi - - # + RPi 3/ZeroW - if (( $HW_ONBOARD_WIFI == 1 )); then + G_RUN_CMD systemctl start bluetooth - #pi-bluetooth contains hciuart service and also pulls in firmware: https://github.com/Fourdee/DietPi/issues/693 - # Installed by default as of v142 - if (( ! $(dpkg --get-selections | grep -ci -m1 '^pi-bluetooth') )); then - - apt-get install -y pi-bluetooth - - fi + # + RPi / Asus TB + if (( $G_HW_MODEL < 10 || $G_HW_MODEL == 52 )); then systemctl enable hciuart - - #Start service again, if it fails: https://github.com/Fourdee/DietPi/issues/376#issuecomment-230149754 - loop_count=0 - max_count=3 - while (( $(systemctl start hciuart;echo $?) != 0 )) - do - - if (( $loop_count >= $max_count )); then - - /DietPi/dietpi/func/dietpi-notify 1 "hciuart failed to start after $loop_count attempts." - EXIT_CODE=1 - break - - else - - /DietPi/dietpi/func/dietpi-notify 2 "hciuart failed to start. Attempting to restart it, please wait..." - ((loop_count++)) - sleep 1 - - fi - - done - - fi - - # + Asus TB - if (( $HW_MODEL == 100 )); then - - systemctl enable hciuart - systemctl start hciuart + G_RUN_CMD systemctl start hciuart fi @@ -1286,15 +1108,33 @@ _EOF_ if [ "$INPUT_DEVICE_VALUE" = "ipv4" ]; then - echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99force-ipv + # - APT force IPv4 + echo 'Acquire::ForceIPv4 "true";' > /etc/apt/apt.conf.d/99-dietpi-force-ipv4 + # - Wget prefer IPv4 + grep -q '^[[:blank:]]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]]*prefer-family =/c\prefer-family = IPv4' /etc/wgetrc || + grep -q '^[[:blank:]#;]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]#;]*prefer-family =/c\prefer-family = IPv4' /etc/wgetrc || + echo 'prefer-family = IPv4' >> /etc/wgetrc elif [ "$INPUT_DEVICE_VALUE" = "ipv6" ]; then - echo 'Acquire::ForceIPv6 "true";' > /etc/apt/apt.conf.d/99force-ipv + # - APT allow IPv6 + rm /etc/apt/apt.conf.d/99-dietpi-force-ipv4 &> /dev/null + # - Wget prefer IPv6 + grep -q '^[[:blank:]]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]]*prefer-family =/c\prefer-family = IPv6' /etc/wgetrc || + grep -q '^[[:blank:]#;]*prefer-family =' /etc/wgetrc && + sed -i '/^[[:blank:]#;]*prefer-family =/c\prefer-family = IPv6' /etc/wgetrc || + echo 'prefer-family = IPv6' >> /etc/wgetrc elif [ "$INPUT_DEVICE_VALUE" = "auto" ]; then - rm /etc/apt/apt.conf.d/99force-ipv &> /dev/null + # - APT allow IPv6 + rm /etc/apt/apt.conf.d/99-dietpi-force-ipv4 &> /dev/null + # - Wget back to default + grep -q '^[[:blank:]]*prefer-family =' /etc/wgetrc && + sed -i 's/^[[:blank:]]*prefer-family =/#prefer-family =/' /etc/wgetrc else @@ -1303,7 +1143,7 @@ _EOF_ fi #Update dietpi.txt global - sed -i "/^prefer_ipversion=/c\prefer_ipversion=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt + sed -i "/^CONFIG_PREFER_IPVERSION=/c\CONFIG_PREFER_IPVERSION=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt } @@ -1314,7 +1154,7 @@ _EOF_ # - All aWIFI_MODULES=("cfg80211") - #NB: we need to start doing these device specific via $HW_MODEL index. This prevents unnecessary modules getting loaded. + #NB: we need to start doing these device specific via $G_HW_MODEL index. This prevents unnecessary modules getting loaded. # + RPi 3 aWIFI_MODULES+=("brcmfmac") #onboard WiFi aWIFI_MODULES+=("brcmutil") #onboard WiFi @@ -1323,22 +1163,22 @@ _EOF_ aWIFI_MODULES+=("ap6211") #onboard # + OrangePi Zero - if (( $HW_MODEL == 32 )); then + if (( $G_HW_MODEL == 32 )); then aWIFI_MODULES+=("xradio_wlan") # + OrangePi Plus - elif (( $HW_MODEL == 34 )); then + elif (( $G_HW_MODEL == 34 )); then aWIFI_MODULES+=("8189es") # + Pine A64 / Asus tinker board (onboard) - elif (( ( $HW_MODEL >= 40 && $HW_MODEL <= 42 ) || $HW_MODEL == 100 )); then + elif (( $G_HW_MODEL == 40 || $G_HW_MODEL == 52 )); then aWIFI_MODULES+=("8723bs") # + NanoPi NEO Air / Zero 2+ - elif (( $HW_MODEL == 35 || $HW_MODEL == 64 )); then + 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 @@ -1367,12 +1207,20 @@ _EOF_ done #Disable powersave being applied - systemctl disable wifi_disable_powersave + systemctl disable wifi_disable_powersave &> /dev/null rm /etc/systemd/system/wifi_disable_powersave.service &> /dev/null # - Enable elif [ "$INPUT_DEVICE_VALUE" = "enable" ]; then + # - Install prereqs + G_AG_CHECK_INSTALL_PREREQ crda firmware-atheros firmware-brcm80211 firmware-ralink iw rfkill wireless-tools wpasupplicant + if (( $? != 0 )); then + + exit 1 + + fi + rm /etc/modprobe.d/disable_wifi.conf &> /dev/null # - Disable known powersaving options for specific chipsets @@ -1391,7 +1239,7 @@ _EOF_ done # - Delay. Without this, kernel reports wifi device not found with RPi 3 and Pine A64 addon board, when ran straight after this script. - /DietPi/dietpi/func/dietpi-notify 2 "Please wait, enabling WiFi Modules..." + G_DIETPI-NOTIFY 2 "Please wait, enabling WiFi Modules..." sleep 3 #Update our networking file (refresh active wlan index) @@ -1447,12 +1295,13 @@ _EOF_ if [ "$INPUT_DEVICE_VALUE" = "set" ]; then - local Wifi_KEYMGR=$(grep -m1 '^Wifi_KEYMGR' /DietPi/dietpi.txt | sed 's/.*=//') - local Wifi_KEY="$(grep -m1 '^Wifi_KEY' /DietPi/dietpi.txt | sed 's/.*=//')" - local Wifi_SSID="$(grep -m1 '^Wifi_SSID' /DietPi/dietpi.txt | sed 's/.*=//')" + local Wifi_KEYMGR=$(grep -m1 '^AUTO_SETUP_NET_WIFI_KEYMGR=' /DietPi/dietpi.txt | sed 's/.*=//') + local Wifi_KEY="$(grep -m1 '^AUTO_SETUP_NET_WIFI_KEY=' /DietPi/dietpi.txt | sed 's/.*=//')" + local Wifi_SSID="$(grep -m1 '^AUTO_SETUP_NET_WIFI_SSID=' /DietPi/dietpi.txt | sed 's/.*=//')" + mkdir -p /etc/wpa_supplicant cat << _EOF_ > /etc/wpa_supplicant/wpa_supplicant.conf -country=$(grep -m1 '^wifi_country_code=' /DietPi/dietpi.txt | sed 's/.*=//') +country=$(grep -m1 '^CONFIG_WIFI_COUNTRY_CODE=' /DietPi/dietpi.txt | sed 's/.*=//') ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 @@ -1509,7 +1358,7 @@ _EOF_ INPUT_DEVICE_VALUE=$(echo -e "$INPUT_DEVICE_VALUE" | tr '[:lower:]' '[:upper:]') # - Apply value to DietPi.txt - sed -i "/^wifi_country_code=/c\wifi_country_code=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt + sed -i "/^CONFIG_WIFI_COUNTRY_CODE=/c\CONFIG_WIFI_COUNTRY_CODE=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt # - Update wpa_supplicant.conf if [ -f /etc/wpa_supplicant/wpa_supplicant.conf ]; then @@ -1541,7 +1390,7 @@ _EOF_ #systemctl enable serial-getty@*.service # Wildcard does not work, we need to specify each possible tty device name #systemctl enable serial-getty@ttyAMA[0-9].service # Number wildcards do not work, we need to specify each possible tty device number - /DietPi/dietpi/func/dietpi-notify 2 "Enabling known serial-getty services, please wait..." + G_DIETPI-NOTIFY 2 "Enabling known serial-getty services, please wait..." systemctl enable serial-getty@.service for ((i=0; i<=$MAX_SERIAL_CONSOLES; i++)) do @@ -1554,7 +1403,7 @@ _EOF_ #Device Specific: # - RPi - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then if (( ! $(cat /boot/cmdline.txt | grep -ci -m1 'console=ttyAMA0,115200 ') )); then @@ -1562,7 +1411,7 @@ _EOF_ fi - if (( $HW_MODEL == 3 )); then + if (( $G_HW_MODEL == 3 )); then # - Must use 250mhz core frequency, else, corrupt characters: https://github.com/Fourdee/DietPi/issues/306#issuecomment-222304202 sed -i '/core_freq=/c\core_freq=250' "$FP_RPI_CONFIG" @@ -1570,12 +1419,12 @@ _EOF_ fi # - Odroid C1 - elif (( $HW_MODEL == 10 )); then + elif (( $G_HW_MODEL == 10 )); then sed -i '/^setenv condev/c\setenv condev "console=tty0 console=ttyS0,115200n8"' /DietPi/boot.ini # - Odroid XU4 - elif (( $HW_MODEL == 11 )); then + elif (( $G_HW_MODEL == 11 )); then if (( ! $(cat /DietPi/boot.ini | grep -ci -m1 'console=ttySAC2,115200n8 ') )); then @@ -1584,12 +1433,12 @@ _EOF_ fi # - Odroid C2 - elif (( $HW_MODEL == 12 )); then + elif (( $G_HW_MODEL == 12 )); then sed -i '/^setenv condev/c\setenv condev "console=tty0 console=ttyS0,115200n8"' /DietPi/boot.ini # - Pine A64 - elif (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then + elif (( $G_HW_MODEL == 40 )); then if (( ! $(cat /DietPi/uEnv.txt | grep -ci -m1 'console=ttyS0,115200n8 ') )); then @@ -1600,7 +1449,7 @@ _EOF_ fi # - Update dietpi.txt global var - sed -i '/^serial_console_enabled=/c\serial_console_enabled=1' /DietPi/dietpi.txt + sed -i '/^CONFIG_SERIAL_CONSOLE_ENABLE=/c\CONFIG_SERIAL_CONSOLE_ENABLE=1' /DietPi/dietpi.txt #------------------------------------------------------------------------------------- @@ -1608,7 +1457,7 @@ _EOF_ elif [ "$INPUT_DEVICE_VALUE" = "disable" ]; then #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. - /DietPi/dietpi/func/dietpi-notify 2 "Disabling known serial-getty services, please wait..." + G_DIETPI-NOTIFY 2 "Disabling known serial-getty services, please wait..." systemctl disable serial-getty@.service for ((i=0; i<=$MAX_SERIAL_CONSOLES; i++)) do @@ -1621,7 +1470,7 @@ _EOF_ #Device Specific: # - RPi - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then # RPi 1/2 sed -i 's/console=ttyAMA0,115200 //' /boot/cmdline.txt @@ -1630,7 +1479,7 @@ _EOF_ sed -i 's/console=ttyS0,115200 //' /boot/cmdline.txt # RPi 3 - Put core freq back to default (400mhz), if set to 250mhz. - if (( $HW_MODEL == 3 && + if (( $G_HW_MODEL == 3 && $(cat "$FP_RPI_CONFIG" | grep -m1 'core_freq=' | sed 's/.*=//') == 250 )); then sed -i '/core_freq=/c\#core_freq=400' "$FP_RPI_CONFIG" @@ -1638,29 +1487,29 @@ _EOF_ fi # - Odroid C1 - elif (( $HW_MODEL == 10 )); then + elif (( $G_HW_MODEL == 10 )); then sed -i '/^setenv condev/c\setenv condev "console=tty0"' /DietPi/boot.ini # - Odroid XU4 - elif (( $HW_MODEL == 11 )); then + elif (( $G_HW_MODEL == 11 )); then sed -i 's/console=ttySAC2,115200n8 //' /DietPi/boot.ini # - Odroid C2 - elif (( $HW_MODEL == 12 )); then + elif (( $G_HW_MODEL == 12 )); then sed -i '/^setenv condev/c\setenv condev "console=tty0"' /DietPi/boot.ini # - Pine A64 - elif (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then + elif (( $G_HW_MODEL == 40 )); then sed -i 's/console=ttyS0,115200n8 //' /DietPi/uEnv.txt fi # - Update dietpi.txt global var - sed -i '/^serial_console_enabled=/c\serial_console_enabled=0' /DietPi/dietpi.txt + sed -i '/^CONFIG_SERIAL_CONSOLE_ENABLE=/c\CONFIG_SERIAL_CONSOLE_ENABLE=0' /DietPi/dietpi.txt else Unknown_Input_Mode @@ -1689,54 +1538,49 @@ _EOF_ # - Pre-Reqs for any soundcard if (( ! $(dpkg --get-selections | grep -ci -m1 '^alsa-utils') )); then - /DietPi/dietpi/func/dietpi-notify 2 "Installing alsa-utils. Please wait..." - apt-get install -y alsa-utils - if (( $? != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 "Unable to install alsa-utils." - - fi + G_DIETPI-NOTIFY 2 "Installing alsa-utils. Please wait..." + G_AGI alsa-utils fi #HW specific # - RPI - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then Soundcard_Reset_RPi # - Odroid - elif (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then + elif (( $G_HW_MODEL >= 10 && $G_HW_MODEL < 20 )); then Soundcard_Reset_Odroid # - OPi Zero (H2+) - elif (( $HW_MODEL == 32 )); then + elif (( $G_HW_MODEL == 32 )); then Soundcard_Reset_H2 # - H3 - elif (( $HW_CPUID == 1 )); then + elif (( $G_HW_CPUID == 1 )); then Soundcard_Reset_H3 # - Pine a64 - elif (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then + elif (( $G_HW_MODEL == 40 )); then Soundcard_Reset_PineA64 # - BPi Pro - elif (( $HW_MODEL == 51 )); then + elif (( $G_HW_MODEL == 51 )); then Soundcard_Reset_BPi_Pro #Sparky SBC - elif (( $HW_MODEL == 70 )); then + elif (( $G_HW_MODEL == 70 )); then Soundcard_Reset_SparkySBC #ASUS - elif (( $HW_MODEL == 100 )); then + elif (( $G_HW_MODEL == 52 )); then Soundcard_Reset_Asus @@ -1766,6 +1610,7 @@ _EOF_ 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" # - Disable i2s maps @@ -1835,6 +1680,8 @@ _EOF_ SOUNDCARD_TARGET_DEVICE=1 amixer -c 0 sset 'audio output mode switch' 'hdmi' + sed -i 's/aotg.aotg1_speed=1/aotg.aotg1_speed=0/' /DietPi/uEnv.txt + } Soundcard_Reset_PineA64(){ @@ -1877,10 +1724,10 @@ _EOF_ fi # - Update DietPi global soundcard var - sed -i "/^soundcard=/c\soundcard=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt + sed -i "/^CONFIG_SOUNDCARD=/c\CONFIG_SOUNDCARD=$INPUT_DEVICE_VALUE" /DietPi/dietpi.txt # - RPi: Enable DTPARAM audio setting - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then # - Enable dtparam audio sed -i '/dtparam=audio=/c\dtparam=audio=on' "$FP_RPI_CONFIG" @@ -1913,16 +1760,23 @@ _EOF_ # - Not found else - /DietPi/dietpi/func/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 - sed -i "/^soundcard=/c\soundcard=none" /DietPi/dietpi.txt + sed -i "/^CONFIG_SOUNDCARD=/c\CONFIG_SOUNDCARD=none" /DietPi/dietpi.txt fi SOUNDCARD_TARGET_DEVICE=0 + # - SparkySBC, enable aotg.aotg1_speed compatibility setting for USB 1.1, when USB-DAC configured: https://github.com/Fourdee/DietPi/issues/1301 + if (( $G_HW_MODEL == 70 )); then + + sed -i 's/aotg.aotg1_speed=0/aotg.aotg1_speed=1/' /DietPi/uEnv.txt + + fi + ;; #RPi ------------------------------------------------------------------------------- @@ -2017,7 +1871,7 @@ _EOF_ echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> "$FP_RPI_CONFIG" # + Sparky SBC - if (( $HW_MODEL == 70 )); then + if (( $G_HW_MODEL == 70 )); then echo -e "$INPUT_DEVICE_VALUE" >> /etc/modules SOUNDCARD_TARGET_CARD=1 @@ -2062,7 +1916,7 @@ _EOF_ # - Install binaries local install_url_address='http://dietpi.com/downloads/binaries/rpi/I-Sabre-K2M_binaries.zip' - /DietPi/dietpi/func/check_connection "$install_url_address" + G_CHECK_URL "$install_url_address" if (( $? == 0 )); then wget "$install_url_address" -O package.zip @@ -2080,7 +1934,7 @@ _EOF_ else - /DietPi/dietpi/func/dietpi-notify 1 "Failed to install $INPUT_DEVICE_NAME. $install_url_address may be offline or unreachable." + G_DIETPI-NOTIFY 1 "Failed to install $INPUT_DEVICE_NAME. $install_url_address may be offline or unreachable." fi @@ -2117,6 +1971,15 @@ _EOF_ ;; + #dionaudio-loco + #dionaudio-loco-v2 + dionaudio-loco*) + + # - enable dtoverlay + echo -e "\ndtoverlay=$INPUT_DEVICE_VALUE" >> "$FP_RPI_CONFIG" + + ;; + #Odroid ------------------------------------------------------------------------------- odroid-hifishield-plus) @@ -2274,7 +2137,7 @@ _EOF_ if (( ! $(dpkg --get-selections | grep -ci -m1 '^libasound2-plugin-equal') )); then - apt-get install -y libasound2-plugin-equal + G_AGI libasound2-plugin-equal fi @@ -2303,7 +2166,7 @@ _EOF_ #----------------------------------------------------------------------------------- #info - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Set_Hardware "$INPUT_DEVICE_NAME ($INPUT_DEVICE_VALUE)" + G_DIETPI-NOTIFY 3 DietPi-Set_Hardware "$INPUT_DEVICE_NAME ($INPUT_DEVICE_VALUE)" #----------------------------------------------------------------------------------- if [ "$INPUT_DEVICE_NAME" = "soundcard" ]; then @@ -2350,10 +2213,6 @@ _EOF_ Eth_Force_Speed_Main - elif [ "$INPUT_DEVICE_NAME" = "kernel" ]; then - - Kernel_Main - elif [ "$INPUT_DEVICE_NAME" = "remoteir" ]; then RemoteIR_Main @@ -2377,7 +2236,7 @@ _EOF_ fi #----------------------------------------------------------------------------------- - /DietPi/dietpi/func/dietpi-notify -1 $EXIT_CODE "$INPUT_DEVICE_NAME $INPUT_DEVICE_VALUE |" + G_DIETPI-NOTIFY -1 $EXIT_CODE "$INPUT_DEVICE_NAME $INPUT_DEVICE_VALUE |" #----------------------------------------------------------------------------------- exit $EXIT_CODE #----------------------------------------------------------------------------------- diff --git a/dietpi/func/dietpi-set_nfsclient b/dietpi/func/dietpi-set_nfsclient index 6ccfa0699b..f74839328e 100644 --- a/dietpi/func/dietpi-set_nfsclient +++ b/dietpi/func/dietpi-set_nfsclient @@ -19,23 +19,23 @@ # - /DietPi/dietpi/func/dietpi-set_nfsclient 1 = Apply and mount using settings in dietpi.txt #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then INPUT=$1 fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Set_nfsclient' + #Import DietPi-Globals --------------------------------------------------------------- + #///////////////////////////////////////////////////////////////////////////////////// #curlftpfs data #///////////////////////////////////////////////////////////////////////////////////// OPTION=0 CHOICE=0 - nfsclient_ipaddress=$(cat /DietPi/dietpi.txt | grep -m1 '^nfsclient_ipaddress=' | sed 's/.*=//') + nfsclient_ipaddress=$(grep -m1 '^CONFIG_NFSCLIENT_ADDRESS=' /DietPi/dietpi.txt | sed 's/.*=//') Apply_And_Mount(){ @@ -66,7 +66,7 @@ umount /mnt/nfs_client &> /dev/null #Save to Dietpi.txt - sed -i "/nfsclient_ipaddress=/c\nfsclient_ipaddress=$nfsclient_ipaddress" /DietPi/dietpi.txt + sed -i "/CONFIG_NFSCLIENT_ADDRESS=/c\CONFIG_NFSCLIENT_ADDRESS=$nfsclient_ipaddress" /DietPi/dietpi.txt Apply_And_Mount diff --git a/dietpi/func/dietpi-set_smbclient b/dietpi/func/dietpi-set_smbclient index 775c658324..ea85edf474 100644 --- a/dietpi/func/dietpi-set_smbclient +++ b/dietpi/func/dietpi-set_smbclient @@ -19,26 +19,27 @@ # - /DietPi/dietpi/func/dietpi-set_smbclient 1 = Apply and mount using settings in dietpi.txt #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - + #Grab Input INPUT=0 if [[ $1 =~ ^-?[0-9]+$ ]]; then INPUT=$1 fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Set_smbclient' + #Import DietPi-Globals --------------------------------------------------------------- + #///////////////////////////////////////////////////////////////////////////////////// #smbclient data #///////////////////////////////////////////////////////////////////////////////////// OPTION=0 CHOICE=0 - samba_clientname=$(cat /DietPi/dietpi.txt | grep -m1 '^SambaClient_ComputerName' | sed 's/.*=//') - samba_clientshare=$(cat /DietPi/dietpi.txt | grep -m1 '^SambaClient_ShareName' | sed 's/.*=//') - samba_clientusename=$(cat /DietPi/dietpi.txt | grep -m1 '^SambaClient_Username' | sed 's/.*=//') - samba_clientpassword=$(cat /DietPi/dietpi.txt | grep -m1 '^SambaClient_Password' | sed 's/.*=//') + samba_clientname=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_SMBCLIENT_COMPUTERNAME=' | sed 's/.*=//') + samba_clientshare=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_SMBCLIENT_SHARENAME=' | sed 's/.*=//') + samba_clientusename=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_SMBCLIENT_USERNAME=' | sed 's/.*=//') + samba_clientpassword=$(cat /DietPi/dietpi.txt | grep -m1 '^CONFIG_SMBCLIENT_PASSWORD=' | sed 's/.*=//') Apply_And_Mount(){ @@ -87,10 +88,10 @@ umount /mnt/samba &> /dev/null #Save to Dietpi.txt - sed -i "/SambaClient_ComputerName/c\SambaClient_ComputerName=$samba_clientname" /DietPi/dietpi.txt - sed -i "/SambaClient_ShareName/c\SambaClient_ShareName=$samba_clientshare" /DietPi/dietpi.txt - sed -i "/SambaClient_Username/c\SambaClient_Username=$samba_clientusename" /DietPi/dietpi.txt - sed -i "/SambaClient_Password/c\SambaClient_Password=$samba_clientpassword" /DietPi/dietpi.txt + sed -i "/CONFIG_SMBCLIENT_COMPUTERNAME/c\CONFIG_SMBCLIENT_COMPUTERNAME=$samba_clientname" /DietPi/dietpi.txt + sed -i "/CONFIG_SMBCLIENT_SHARENAME/c\CONFIG_SMBCLIENT_SHARENAME=$samba_clientshare" /DietPi/dietpi.txt + sed -i "/CONFIG_SMBCLIENT_USERNAME/c\CONFIG_SMBCLIENT_USERNAME=$samba_clientusename" /DietPi/dietpi.txt + sed -i "/CONFIG_SMBCLIENT_PASSWORD/c\CONFIG_SMBCLIENT_PASSWORD=$samba_clientpassword" /DietPi/dietpi.txt Apply_And_Mount fi diff --git a/dietpi/func/dietpi-set_software b/dietpi/func/dietpi-set_software index 617dde8372..aba476bdc0 100644 --- a/dietpi/func/dietpi-set_software +++ b/dietpi/func/dietpi-set_software @@ -11,36 +11,20 @@ # # Usage: # - # - /DietPi/dietpi/func/dietpi-set_software allo eth_dhcp / eth_static - # - /DietPi/dietpi/func/dietpi-set_software useradd X=create user with name X and default permissions, using global DietPi password (dietpi) - # - /DietPi/dietpi/func/dietpi-set_software userdel X=delete user with name X - # - /DietPi/dietpi/func/dietpi-set_software apt-mirror url/default - # - /DietPi/dietpi/func/dietpi-set_software ntpd-mirror url/default - # - /DietPi/dietpi/func/dietpi-set_software ntpd-mode configures NTPD mode (eg: ntp/systemd) + FP_SCRIPT='/DietPi/dietpi/func/dietpi-set_software' + AVAIABLE_COMMANDS=" +Available commands +$FP_SCRIPT locale en_GB.UTF-8 +$FP_SCRIPT allo eth_dhcp / eth_static +$FP_SCRIPT useradd X=create user with name X and default permissions, using global DietPi password (dietpi) +$FP_SCRIPT userdel X=delete user with name X +$FP_SCRIPT apt-mirror url/default +$FP_SCRIPT ntpd-mode configures NTPD mode (eg: ntp/systemd) +$FP_SCRIPT verify_dietpi.txt verifies dietpi.txt entries, adds missing entries if required +" #//////////////////////////////////// - #Exit path for non-root logins. - if (( $UID != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit - - fi - - #RootFS RW check - /DietPi/dietpi/dietpi-drive_manager 3 - if (( $? != 0 )); then - - exit - - fi - - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - + #Grab inputs INPUT_MODE_NAME="$1" INPUT_MODE_VALUE="$2" @@ -49,80 +33,123 @@ INPUT_ADDITIONAL_3="$5" INPUT_ADDITIONAL_4="$6" - EXIT_CODE=0 + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Set_software' + #Import DietPi-Globals --------------------------------------------------------------- - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) + EXIT_CODE=0 Unknown_Input_Name(){ EXIT_CODE=1 - /DietPi/dietpi/func/dietpi-notify 2 "Unknown input name ($INPUT_MODE_NAME). Nothing has been applied." + G_DIETPI-NOTIFY 2 "Unknown input name ($INPUT_MODE_NAME). Nothing has been applied." + echo -e "$AVAIABLE_COMMANDS" } Unknown_Input_Mode(){ EXIT_CODE=1 - /DietPi/dietpi/func/dietpi-notify 2 "Unknown input value ($INPUT_MODE_VALUE). Nothing has been applied." + G_DIETPI-NOTIFY 2 "Unknown input value ($INPUT_MODE_VALUE). Nothing has been applied." } #///////////////////////////////////////////////////////////////////////////////////// - # Set Apt Mirror + # locale + # NB: auto installs en_GB.UTF-8 alongside any input option #///////////////////////////////////////////////////////////////////////////////////// - AptMirror_Main(){ + Locale_Main(){ if [ -n "$INPUT_MODE_VALUE" ]; then - local apt_distro='jessie' #3 - if (( $DISTRO == 4 )); then + cat << _EOF_ > /etc/locale.gen +$INPUT_MODE_VALUE UTF-8 +en_GB.UTF-8 UTF-8 +_EOF_ + G_RUN_CMD dpkg-reconfigure -f noninteractive locales + + # - and force locale for remote access, especially dropbear, where receiving locale from client can't be suppressed: + cat << _EOF_ > /etc/profile.d/99-dietpi-force-locale.sh +# To force server locales on SSH access, as dropbear does automatically overwrite them by client values: +export LANG=$INPUT_MODE_VALUE +export LC_ALL=$INPUT_MODE_VALUE +export LANGUAGE=$( echo $INPUT_MODE_VALUE | sed 's/\..*//' ):$( echo $INPUT_MODE_VALUE | sed 's/_.*//' ) +_EOF_ + chmod +x /etc/profile.d/99-dietpi-force-locale.sh - apt_distro='stretch' + sed -i "/AUTO_SETUP_LOCALE=/c\AUTO_SETUP_LOCALE=$INPUT_MODE_VALUE" /DietPi/dietpi.txt - fi + else + + Unknown_Input_Mode + + fi + + } + + #///////////////////////////////////////////////////////////////////////////////////// + # Set Apt Mirror + #///////////////////////////////////////////////////////////////////////////////////// + AptMirror_Main(){ + + if [ -n "$INPUT_MODE_VALUE" ]; then # - Set defaults? if [ "$INPUT_MODE_VALUE" = "default" ]; then - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then INPUT_MODE_VALUE='https://www.mirrorservice.org/sites/archive.raspbian.org/raspbian' else - INPUT_MODE_VALUE='http://ftp.debian.org/debian/' + INPUT_MODE_VALUE='https://deb.debian.org/debian/' fi fi # - Set raspbian - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then cat << _EOF_ > /etc/apt/sources.list -deb $INPUT_MODE_VALUE $apt_distro main contrib non-free rpi +deb $INPUT_MODE_VALUE $G_DISTRO_NAME main contrib non-free rpi _EOF_ cat << _EOF_ > /etc/apt/sources.list.d/raspi.list -deb https://archive.raspberrypi.org/debian/ $apt_distro main ui +deb https://archive.raspberrypi.org/debian/ $G_DISTRO_NAME main ui _EOF_ # Update dietpi.txt entry - sed -i "/Apt_Raspbian_Mirror=/c\Apt_Raspbian_Mirror=$INPUT_MODE_VALUE" /DietPi/dietpi.txt + sed -i "/CONFIG_APT_RASPBIAN_MIRROR=/c\CONFIG_APT_RASPBIAN_MIRROR=$INPUT_MODE_VALUE" /DietPi/dietpi.txt # - Set debian else - cat << _EOF_ > /etc/apt/sources.list -deb $INPUT_MODE_VALUE $apt_distro main contrib non-free -deb $INPUT_MODE_VALUE $apt_distro-updates main contrib non-free -deb http://security.debian.org $apt_distro/updates main contrib non-free -deb $INPUT_MODE_VALUE $apt_distro-backports main contrib non-free + cat << _EOF_ > /etc/apt/sources.list +deb $INPUT_MODE_VALUE $G_DISTRO_NAME main contrib non-free +deb $INPUT_MODE_VALUE $G_DISTRO_NAME-updates main contrib non-free +deb https://deb.debian.org/debian-security/ $G_DISTRO_NAME/updates main contrib non-free +deb $INPUT_MODE_VALUE $G_DISTRO_NAME-backports main contrib non-free _EOF_ + # Jessie, switch deb.debian.org to http: https://github.com/Fourdee/DietPi/issues/1285#issuecomment-351830101 + if (( $G_DISTRO < 4 )); then + + sed -i 's|https://deb.debian.org|http://deb.debian.org|g' /etc/apt/sources.list + + # Buster, remove backports: https://github.com/Fourdee/DietPi/issues/1285#issuecomment-351830101 + elif (( $G_DISTRO > 4 )); then + + sed -i '/backports/d' /etc/apt/sources.list + + fi + # Update dietpi.txt entry - sed -i "/Apt_Debian_Mirror=/c\Apt_Debian_Mirror=$INPUT_MODE_VALUE" /DietPi/dietpi.txt + sed -i "/CONFIG_APT_DEBIAN_MIRROR=/c\CONFIG_APT_DEBIAN_MIRROR=$INPUT_MODE_VALUE" /DietPi/dietpi.txt fi @@ -135,74 +162,90 @@ _EOF_ } #///////////////////////////////////////////////////////////////////////////////////// - # Set NTPD mirror + # Set NTPD Mode + # NB: also sets mirror as defined in dietpi.txt CONFIG_NTP_MIRROR + # NB: Also restarts NTP updates and waits for them to complete #///////////////////////////////////////////////////////////////////////////////////// - NtpdMirror_Main(){ + NtpdMode_Main(){ if [ -n "$INPUT_MODE_VALUE" ]; then + # - Reset global to disabled, prevents run_ntpd in dietpi-software + sed -i "/CONFIG_NTP_MODE=/c\CONFIG_NTP_MODE=0" /DietPi/dietpi.txt + + # Kill all existing ntp + killall -w /DietPi/dietpi/func/run_ntpd &> /dev/null + killall -w ntpd &> /dev/null + rm /var/lib/dietpi/.ntpd_exit_status &> /dev/null + + local ntpd_mirror=$(grep -m1 '^CONFIG_NTP_MIRROR=' /DietPi/dietpi.txt | sed 's/.*=//') # - Set defaults? - if [ "$INPUT_MODE_VALUE" = "default" ]; then + if [ "$ntpd_mirror" = "default" ]; then - INPUT_MODE_VALUE='debian.pool.ntp.org' + ntpd_mirror='debian.pool.ntp.org' fi - sed -i '/^server [0-9]/d' /etc/ntp.conf - for ((i=0; i<4; i++)) - do + #Install ntp if required + if (( $INPUT_MODE_VALUE >= 1 && $INPUT_MODE_VALUE <= 3 )); then - echo -e "server $i.$INPUT_MODE_VALUE iburst" >> /etc/ntp.conf + # - avoid dpsoftware install if system first run is not completed + if (( $G_DIETPI_INSTALL_STAGE >= 0 )); then - done + /DietPi/dietpi/dietpi-software install 170 - # - Update DietPi.txt - sed -i "/NTPD_Mirror=/c\NTPD_Mirror=$INPUT_MODE_VALUE" /DietPi/dietpi.txt + fi - else + # - Set NTPD mirror + # - Remove obsolete 'server' entries. + sed -i '/^[[:blank:]#;]*server [0-9]/d' /etc/ntp.conf + for ((i=0; i<4; i++)) do - Unknown_Input_Mode + if grep "^[[:blank:]]*pool $i" /etc/ntp.conf; then - fi + sed -i "s/^[[:blank:]]*pool $i.*/pool $i.$ntpd_mirror iburst/" /etc/ntp.conf - } + elif grep "^[[:blank:]#;]*pool $i" /etc/ntp.conf; then - #///////////////////////////////////////////////////////////////////////////////////// - # Set NTPD Mode - #///////////////////////////////////////////////////////////////////////////////////// - NtpdMode_Main(){ + sed -i "s/^[[:blank:]#;]*pool $i.*/pool $i.$ntpd_mirror iburst/" /etc/ntp.conf - if [ -n "$INPUT_MODE_VALUE" ]; then + else - # - Reset global to disabled, prevents run_ntpd in dietpi-software - sed -i "/ntpd_update_mode=/c\ntpd_update_mode=0" /DietPi/dietpi.txt + echo -e "pool $i.$ntpd_mirror iburst" >> /etc/ntp.conf - #Install ntp if required - if (( $INPUT_MODE_VALUE >= 1 && $INPUT_MODE_VALUE <= 3 )); then + fi - /DietPi/dietpi/dietpi-software install 170 + done #Uninstall ntp if not required else - /DietPi/dietpi/dietpi-software uninstall 170 + # - avoid dpsoftware uninstall if system first run is not completed + if (( $G_DIETPI_INSTALL_STAGE >= 0 )); then + + /DietPi/dietpi/dietpi-software uninstall 170 + + else + + G_AGP ntp + + fi fi #Setup Drift mode, use SystemD if (( $INPUT_MODE_VALUE == 4 )); then - # - Set default pool servers + # - Set NTPD mirror cat << _EOF_ > /etc/systemd/timesyncd.conf [Time] -Servers=0.debian.pool.ntp.org 1.debian.pool.ntp.org 2.debian.pool.ntp.org 3.debian.pool.ntp.org +Servers=0.$ntpd_mirror 1.$ntpd_mirror 2.$ntpd_mirror 3.$ntpd_mirror _EOF_ # - enable systemctl daemon-reload timedatectl set-ntp true - #Disable SystemD and allow "run_ntpd" script to take control else @@ -212,7 +255,7 @@ _EOF_ fi # - Update DietPi.txt - sed -i "/ntpd_update_mode=/c\ntpd_update_mode=$INPUT_MODE_VALUE" /DietPi/dietpi.txt + sed -i "/CONFIG_NTP_MODE=/c\CONFIG_NTP_MODE=$INPUT_MODE_VALUE" /DietPi/dietpi.txt # - Update now /DietPi/dietpi/func/run_ntpd status @@ -266,7 +309,7 @@ _EOF_ mkdir -p /home useradd -m -s /bin/bash "$INPUT_MODE_VALUE" - chpasswd <<< "$INPUT_MODE_VALUE:$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_Global_Password=' | sed 's/.*=//')" + chpasswd <<< "$INPUT_MODE_VALUE:$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_GLOBAL_PASSWORD=' | sed 's/.*=//')" # Copy existing profile/bashrc cp /root/.profile /home/$INPUT_MODE_VALUE/ @@ -343,13 +386,71 @@ _EOF_ } + Verify_DietPi_Txt(){ + + #Verify entries with git dietpi.txt + local gitbranch=$(grep -m1 '^DEV_GITBRANCH=' /DietPi/dietpi.txt | sed 's/.*=//') + if [ -z "$gitbranch" ]; then + + gitbranch='master' + + fi + + INSTALL_URL="https://raw.githubusercontent.com/Fourdee/DietPi/$gitbranch/dietpi.txt" + G_CHECK_URL "$INSTALL_URL" + if (( $? == 0 )); then + + G_DIETPI-NOTIFY 0 "Patching dietpi.txt" + wget "$INSTALL_URL" -O /tmp/dietpi.txt_patch + + local entry=0 + local value=0 + while read line + do + + entry=$(echo -e "$line" | grep "^[^#;/]" ) + + if [ -n "$entry" ]; then + + value=$(echo -e "${entry##*=}") #*=X + entry=$(echo -e "${entry%%=*}") #X* + + # - Patch new entry if required + if (( ! $(grep -ci -m1 "^$entry=" /DietPi/dietpi.txt) )); then + + G_DIETPI-NOTIFY 2 "Updating dietpi.txt with new entry: $entry=$value" + cat << _EOF_ >> /DietPi/dietpi.txt +$entry=$value +_EOF_ + + else + + G_DIETPI-NOTIFY 0 "Verified: $entry" + + fi + + fi + + done < /tmp/dietpi.txt_patch + rm /tmp/dietpi.txt_patch + + G_DIETPI-NOTIFY 0 "dietpi.txt verification completed" + + else + + G_DIETPI-NOTIFY 1 "Failed to verify dietpi.txt, $INSTALL_URL is offline and/or inaccessible" + + fi + + } + #///////////////////////////////////////////////////////////////////////////////////// # Main Loop #///////////////////////////////////////////////////////////////////////////////////// #----------------------------------------------------------------------------------- #info - /DietPi/dietpi/func/dietpi-notify 3 DietPi-Set_Software "$INPUT_MODE_NAME ($INPUT_MODE_VALUE)" + G_DIETPI-NOTIFY 3 DietPi-Set_Software "$INPUT_MODE_NAME ($INPUT_MODE_VALUE)" #----------------------------------------------------------------------------------- if [ "$INPUT_MODE_NAME" = "apt-mirror" ]; then @@ -376,6 +477,14 @@ _EOF_ Allo_Main + elif [ "$INPUT_MODE_NAME" = "verify_dietpi.txt" ]; then + + Verify_DietPi_Txt + + elif [ "$INPUT_MODE_NAME" = 'locale' ]; then + + Locale_Main + else Unknown_Input_Name @@ -383,8 +492,8 @@ _EOF_ fi #----------------------------------------------------------------------------------- - /DietPi/dietpi/func/dietpi-notify -1 $EXIT_CODE "$INPUT_MODE_NAME $INPUT_MODE_VALUE |" + G_DIETPI-NOTIFY -1 $EXIT_CODE "$INPUT_MODE_NAME $INPUT_MODE_VALUE |" #----------------------------------------------------------------------------------- exit $EXIT_CODE #----------------------------------------------------------------------------------- -} \ No newline at end of file +} diff --git a/dietpi/func/dietpi-set_userdata b/dietpi/func/dietpi-set_userdata index 90dee30e96..dc7df06345 100644 --- a/dietpi/func/dietpi-set_userdata +++ b/dietpi/func/dietpi-set_userdata @@ -14,20 +14,17 @@ # - Also moves the Dphys swapfile to $TARGET_DIRECTORY. Required to prevent locked .swapfile from allow us to delete $SOURCE_DIRECTORY. # # Usage: - # - /DietPi/dietpi/func/dietpi-set_userdata return_source | Return current user data directory FP # - /DietPi/dietpi/func/dietpi-set_userdata SOURCE_DIRECTORY TARGET_DIRECTORY | Setup user data directory, move data if needed. if TARGET_DIRECTORY='auto' , auto target location.Returns 1 if failed. #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Set_userdata' + #Import DietPi-Globals --------------------------------------------------------------- EXIT_CODE=0 - DIETPI_USERDATA_DIRECTORY='/mnt/dietpi_userdata' # Global, must match same var in dietpi-software in dietpi-uninstall. Probably a good idea to never change this. - SOURCE_DIRECTORY="$1" TARGET_DIRECTORY="$2" @@ -60,8 +57,8 @@ # - Copy source to target, if it contains any files/folders if [ -z "$(find $SOURCE_DIRECTORY -maxdepth 0 -empty)" ]; then - /DietPi/dietpi/func/dietpi-notify 0 "Moving your existing data from $SOURCE_DIRECTORY to $TARGET_DIRECTORY" - /DietPi/dietpi/func/dietpi-notify 2 "Please wait...\n" + G_DIETPI-NOTIFY 0 "Moving your existing data from $SOURCE_DIRECTORY to $TARGET_DIRECTORY" + G_DIETPI-NOTIFY 2 "Please wait...\n" sleep 1 @@ -78,8 +75,8 @@ if (( $(ls -lha "$fp_test_target" | grep -ci -m1 "www-data") )); then cp_options+='p' - /DietPi/dietpi/func/dietpi-notify 2 "Target filesystem supports user permissions:" - /DietPi/dietpi/func/dietpi-notify 2 " - Attempting to preserve permissions during transfer." + G_DIETPI-NOTIFY 2 "Target filesystem supports user permissions:" + G_DIETPI-NOTIFY 2 " - Attempting to preserve permissions during transfer." sleep 1 fi @@ -115,11 +112,11 @@ fi - # - Create symlink to DIETPI_USERDATA_DIRECTORY if required - if [ "$TARGET_DIRECTORY" != "$DIETPI_USERDATA_DIRECTORY" ]; then + # - Create symlink to G_FP_DIETPI_USERDATA if required + if [ "$TARGET_DIRECTORY" != "$G_FP_DIETPI_USERDATA" ]; then - rm -R "$DIETPI_USERDATA_DIRECTORY" &> /dev/null - ln -sf "$TARGET_DIRECTORY" "$DIETPI_USERDATA_DIRECTORY" + rm -R "$G_FP_DIETPI_USERDATA" &> /dev/null + ln -sf "$TARGET_DIRECTORY" "$G_FP_DIETPI_USERDATA" fi @@ -136,20 +133,11 @@ #///////////////////////////////////////////////////////////////////////////////////// #init - # - If there is no directory or symlink for $DIETPI_USERDATA_DIRECTORY, always create a directory. - if [ ! -d "$DIETPI_USERDATA_DIRECTORY" ] && [ ! -L "$DIETPI_USERDATA_DIRECTORY" ]; then - - mkdir -p "$DIETPI_USERDATA_DIRECTORY" - - fi - - #------------------------------------------------------------------------------------- - #Returns - # - Return current userdata dir - if [ "$1" = "return_source" ]; then + # - If there is no directory or symlink for $G_FP_DIETPI_USERDATA, always create a directory. + if [ ! -d "$G_FP_DIETPI_USERDATA" ] && [ ! -L "$G_FP_DIETPI_USERDATA" ]; then - echo -e "$(readlink -f $DIETPI_USERDATA_DIRECTORY)" - exit + #Run full core_env set + /DietPi/dietpi/func/dietpi-set_core_environment fi @@ -157,10 +145,10 @@ #Run target_to_lowercase=$(echo -e "$TARGET_DIRECTORY" | tr '[:upper:]' '[:lower:]') - /DietPi/dietpi/func/dietpi-notify 3 DietPi Updating user data location - /DietPi/dietpi/func/dietpi-notify 2 " - From : $SOURCE_DIRECTORY" - /DietPi/dietpi/func/dietpi-notify 2 " - To : $TARGET_DIRECTORY" - /DietPi/dietpi/func/dietpi-notify 2 "Please wait..." + G_DIETPI-NOTIFY 3 DietPi Updating user data location + G_DIETPI-NOTIFY 2 " - From : $SOURCE_DIRECTORY" + G_DIETPI-NOTIFY 2 " - To : $TARGET_DIRECTORY" + G_DIETPI-NOTIFY 2 "Please wait..." while (( $RUN_MOVE_DATA )); do @@ -174,9 +162,9 @@ break # - Check if symlink is already pointing to target directory. - elif [ "$(readlink -f $DIETPI_USERDATA_DIRECTORY)" = "$TARGET_DIRECTORY" ]; then + elif [ "$(readlink -f $G_FP_DIETPI_USERDATA)" = "$TARGET_DIRECTORY" ]; then - LOGFILE_OUTPUT_TEXT="$DIETPI_USERDATA_DIRECTORY is already symlinked to target directory." + LOGFILE_OUTPUT_TEXT="$G_FP_DIETPI_USERDATA is already symlinked to target directory." EXIT_CODE=0 #return ok break @@ -232,7 +220,7 @@ #Ensure enough freespace in target FREESPACE_AVAILABLE_TARGET=$(( $(df -Pk "$TARGET_DIRECTORY" | awk '{print $4}' | sed -n 2p) * 1024 )) #bytes - /DietPi/dietpi/func/dietpi-notify 2 "Calculating space required for moving data, please wait..." + G_DIETPI-NOTIFY 2 "Calculating space required for moving data, please wait..." FREESPACE_REQUIRED_SOURCE=$(du -cbs "$SOURCE_DIRECTORY" | awk '{print $1}' | sed -n 1p) #bytes echo -e " - Available $FREESPACE_AVAILABLE_TARGET bytes" @@ -263,12 +251,12 @@ # - Info if (( $EXIT_CODE == 0 )); then - /DietPi/dietpi/func/dietpi-notify 2 "$LOGFILE_OUTPUT_TEXT" + G_DIETPI-NOTIFY 2 "$LOGFILE_OUTPUT_TEXT" # - Error else - /DietPi/dietpi/func/dietpi-notify 1 "$LOGFILE_OUTPUT_TEXT" + G_DIETPI-NOTIFY 1 "$LOGFILE_OUTPUT_TEXT" fi @@ -279,14 +267,14 @@ else - /DietPi/dietpi/func/dietpi-notify 2 User data location setup completed. + G_DIETPI-NOTIFY 2 User data location setup completed. echo -e "" fi #----------------------------------------------------------------------------------- - /DietPi/dietpi/func/dietpi-notify -1 ${EXIT_CODE:=0} + G_DIETPI-NOTIFY -1 ${EXIT_CODE:=0} #----------------------------------------------------------------------------------- exit $EXIT_CODE #----------------------------------------------------------------------------------- diff --git a/dietpi/func/obtain_network_details b/dietpi/func/obtain_network_details index 0da82f9975..64fe56b378 100644 --- a/dietpi/func/obtain_network_details +++ b/dietpi/func/obtain_network_details @@ -24,11 +24,10 @@ # - IP Address #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + export G_PROGRAM_NAME='DietPi-Obtain_network_details' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// # Global diff --git a/dietpi/func/run_ntpd b/dietpi/func/run_ntpd index 326aa69a87..b5882c0e60 100644 --- a/dietpi/func/run_ntpd +++ b/dietpi/func/run_ntpd @@ -18,25 +18,25 @@ # - /DietPi/dietpi/func/run_ntpd status blocking mode (max Xs), wait for exit code of NTPD and return it. Launches ntpd if process and exit file does not exist #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Run_ntpd' + #Import DietPi-Globals --------------------------------------------------------------- INPUT_MODE=$1 EXIT_CODE=-1 - FP_EXIT_CODE='/etc/dietpi/.ntpd_exit_status' - NTPD_UPDATE_MODE=$(grep -m1 '^ntpd_update_mode=' /DietPi/dietpi.txt | sed 's/.*=//') + FP_EXIT_CODE='/var/lib/dietpi/.ntpd_exit_status' + NTPD_UPDATE_MODE=$(grep -m1 '^CONFIG_NTP_MODE=' /DietPi/dietpi.txt | sed 's/.*=//') Update_NTPD(){ #Dont run twice if (( $(ps aux | grep -ci -m1 '[[:space:]][n]tpd[[:space:]]') )); then - /DietPi/dietpi/func/dietpi-notify 2 "NTPD: is already running" + G_DIETPI-NOTIFY 2 "NTPD: is already running" else @@ -50,14 +50,29 @@ #NTPD: run, exit when updated. if (( $NTPD_UPDATE_MODE >= 1 && $NTPD_UPDATE_MODE <= 3 )); then - /DietPi/dietpi/func/dietpi-notify 2 "NTPD: Running time sync update ($NTPD_UPDATE_MODE)" + G_DIETPI-NOTIFY 2 "NTPD: Running time sync update ($NTPD_UPDATE_MODE)" ntpd -gq -l /var/log/ntpd.log &> /dev/null EXIT_CODE=$? - #systemD-timesyncd/other method: assume status is ok + #systemd-timesyncd + elif (( $NTPD_UPDATE_MODE == 4 )); then + + if (( $(systemctl is-active systemd-timesyncd | grep -ci -m1 '^active') )); then + + G_DIETPI-NOTIFY 0 "NTPD: systemd-timesyncd detected" + EXIT_CODE=0 + + else + + G_DIETPI-NOTIFY 1 "NTPD: systemd-timesyncd is not active" + EXIT_CODE=1 + + fi + + #other method: assume status is ok else - /DietPi/dietpi/func/dietpi-notify 0 "NTPD: non-NTPD mode detected. Completed" + G_DIETPI-NOTIFY 0 "NTPD: manual mode detected" EXIT_CODE=0 fi @@ -75,18 +90,19 @@ #----------------------------------------------------------------------------------- if [ "$INPUT_MODE" = "status" ]; then + MAX_LOOPS=30 + CURRENT_LOOP=1 + #NTPD: if (( $NTPD_UPDATE_MODE >= 1 && $NTPD_UPDATE_MODE <= 3 )); then - MAX_LOOPS=30 - CURRENT_LOOP=1 while (( $CURRENT_LOOP <= $MAX_LOOPS )) do # Update NTPD if its not running, and, no exit file exists if [ ! -f "$FP_EXIT_CODE" ] && (( ! $(ps aux | grep -ci -m1 '[[:space:]][n]tpd[[:space:]]') )); then - /DietPi/dietpi/func/dietpi-notify 2 "NTPD: Has not yet been launched, running now, please wait..." + G_DIETPI-NOTIFY 2 "NTPD: Has not yet been launched, running now, please wait..." Update_NTPD & sleep 1 @@ -97,7 +113,7 @@ else - /DietPi/dietpi/func/dietpi-notify 2 "NTPD: Waiting for completion of time sync ($CURRENT_LOOP/$MAX_LOOPS)" + G_DIETPI-NOTIFY 2 "NTPD: Waiting for completion of time sync ($CURRENT_LOOP/$MAX_LOOPS)" sleep 1 ((CURRENT_LOOP++)) @@ -105,10 +121,39 @@ done - #systemD-timesyncd/other method: assume status is ok + #systemd-timesyncd + elif (( $NTPD_UPDATE_MODE == 4 )); then + + while true + do + + TIME_SYNCED=$(timedatectl status --no-pager | grep -ci -m1 'NTP synchronized: yes') + if (( $CURRENT_LOOP >= $MAX_LOOPS )); then + + G_DIETPI-NOTIFY 2 "NTPD: time out waiting for systemd-timesyncd" + EXIT_CODE=1 + break + + elif (( $TIME_SYNCED )); then + + G_DIETPI-NOTIFY 0 "NTPD: systemd-timesyncd" + EXIT_CODE=0 + break + + else + + G_DIETPI-NOTIFY 2 "NTPD: Waiting for completion of systemd-timesyncd ($CURRENT_LOOP/$MAX_LOOPS)" + sleep 1 + ((CURRENT_LOOP++)) + + fi + + done + + #other method: assume status is ok else - /DietPi/dietpi/func/dietpi-notify 0 "NTPD: non-NTPD mode detected. Completed" + G_DIETPI-NOTIFY 0 "NTPD: manual mode detected" EXIT_CODE=0 fi @@ -121,11 +166,24 @@ fi #----------------------------------------------------------------------------------- #Always return status - /DietPi/dietpi/func/dietpi-notify -1 $EXIT_CODE 'NTPD: time sync |' + G_DIETPI-NOTIFY -1 $EXIT_CODE 'NTPD: time sync |' if (( $EXIT_CODE != 0 )); then - /DietPi/dietpi/func/dietpi-notify 2 "NTPD: Please check the log file for more information:" - /DietPi/dietpi/func/dietpi-notify 2 "NTPD: /var/log/ntpd.log" + if (( $NTPD_UPDATE_MODE >= 1 && $NTPD_UPDATE_MODE <= 3 )); then + + G_DIETPI-NOTIFY 2 "NTPD: Please check the log file for more information:" + G_DIETPI-NOTIFY 2 "NTPD: /var/log/ntpd.log" + + elif (( $NTPD_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" + + fi fi #----------------------------------------------------------------------------------- diff --git a/dietpi/login b/dietpi/login index f3917b9cb1..8225a3fafb 100644 --- a/dietpi/login +++ b/dietpi/login @@ -14,34 +14,27 @@ # - 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 filesystem expansion) #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - #Exit Paths # - SCP connection exit path. Fix for dumb or unset TERM provided by tdaitx export TERM=${TERM:-dumb} if [ "$TERM" = "dumb" ]; then - exit - fi - - # - Exit path for non-root logins. - if (( $UID != 0 )); then - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' exit fi + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + export G_PROGRAM_NAME='DietPi-Login' + #Import DietPi-Globals --------------------------------------------------------------- + #///////////////////////////////////////////////////////////////////////////////////// #Globals #///////////////////////////////////////////////////////////////////////////////////// - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) - DIETPI_INSTALL_STAGE=$(cat /DietPi/dietpi/.install_stage) - FP_DIETPI_FIRSTRUNSETUP_LOG='/etc/dietpi/logs/dietpi-firstrun-setup.log' + G_HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) + G_DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) + FP_DIETPI_FIRSTRUNSETUP_LOG='/var/tmp/dietpi/logs/dietpi-firstrun-setup.log' #///////////////////////////////////////////////////////////////////////////////////// #DietPi-Autostart @@ -56,7 +49,7 @@ local screen_valid=0 #OrangePi - # if (( $HW_MODEL >= 30 && $HW_MODEL < 40 )); then + # if (( $G_HW_MODEL >= 30 && $G_HW_MODEL < 40 )); then # if [ "$(tty)" = "/dev/pts/0" ]; then # screen_valid=1 # fi @@ -124,7 +117,7 @@ done - /mnt/dietpi_userdata/dxx-rebirth/run.sh + "$G_FP_DIETPI_USERDATA"/dxx-rebirth/run.sh #CAVA elif (( $AUTO_START_INDEX == 10 )); then @@ -176,7 +169,7 @@ while [ ! -f /DietPi/.ramdisk ] do - /DietPi/dietpi/func/dietpi-notify 2 "Waiting for DietPi-RAMDISK to finish mounting DietPi to RAM..." + G_DIETPI-NOTIFY 2 "Waiting for DietPi-RAMDISK to finish mounting DietPi to RAM..." sleep 1 done @@ -186,19 +179,22 @@ #---------------------------------------------------------------- #Normal Login - if (( $DIETPI_INSTALL_STAGE == 1 )); then + if (( $G_DIETPI_INSTALL_STAGE == 1 )); then /DietPi/dietpi/dietpi-banner 1 if (( $AUTO_START_INDEX > 0 )); then + #??? testing required + #Set non-interactive (as .bashrc via STDIN check is interactive) + #export G_USER_INPUTS=0 Run_AutoStart fi #---------------------------------------------------------------- #Run DietPi-Software (1st run setup) - elif (( $DIETPI_INSTALL_STAGE == 0 )); then + elif (( $G_DIETPI_INSTALL_STAGE == 0 )); then /DietPi/dietpi/dietpi-banner 0 @@ -207,14 +203,14 @@ do # - Automated - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^AUTO_Install_Enable=1') )); then + if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^AUTO_SETUP_AUTOMATED=1') )); then - /DietPi/dietpi/func/dietpi-notify 2 'DietPi is currently installing and configuring your system. Please wait for this to complete, check back later.' + G_DIETPI-NOTIFY 2 'DietPi is currently installing and configuring your system. Please wait for this to complete, check back later.' else - /DietPi/dietpi/func/dietpi-notify 2 'DietPi-Software is already running on another terminal/screen. Please complete or exit, before continuing.' + G_DIETPI-NOTIFY 2 'DietPi-Software is already running on another terminal/screen. Please complete or exit, before continuing.' fi @@ -223,16 +219,26 @@ done #Start DietPi-Software if required - DIETPI_INSTALL_STAGE=$(cat /DietPi/dietpi/.install_stage) - if (( $DIETPI_INSTALL_STAGE == 0 )); then + G_DIETPI_INSTALL_STAGE=$(cat /DietPi/dietpi/.install_stage) + if (( $G_DIETPI_INSTALL_STAGE == 0 )); then + + #Set non-interactive shell, if automated installation (as .bashrc run via STDIN check is interactive) + if (( $(grep -ci -m1 '^AUTO_SETUP_AUTOMATED=1' /DietPi/dietpi.txt) )); then + + export G_USER_INPUTS=0 + + fi /DietPi/dietpi/dietpi-software | tee "$FP_DIETPI_FIRSTRUNSETUP_LOG" + # reset to auto detection + unset G_USER_INPUTS + fi #---------------------------------------------------------------- #DietPi finishing up bootloader. - elif (( $DIETPI_INSTALL_STAGE == -1 )); then + elif (( $G_DIETPI_INSTALL_STAGE == -1 )); then /DietPi/dietpi/dietpi-banner 0 echo -e " >> DietPi System prep is nearly completed: \n Please run /DietPi/dietpi/login after a few seconds" diff --git a/dietpi/misc/dietpi-justboom b/dietpi/misc/dietpi-justboom index ea7883b9c6..d0888ec864 100644 --- a/dietpi/misc/dietpi-justboom +++ b/dietpi/misc/dietpi-justboom @@ -14,29 +14,12 @@ # - /DietPi/dietpi/misc/dietpi-justboom #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #Exit path for non-root logins. - if (( $UID != 0 )); then - - /DietPi/dietpi/func/dietpi-notify 1 'Error: Root privileges required. Please run the command with "sudo"\n' - exit - - fi - - #RootFS RW check - /DietPi/dietpi/dietpi-drive_manager 3 - if (( $? != 0 )); then - - exit - - fi - - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + G_CHECK_ROOT_USER + G_CHECK_ROOTFS_RW + export G_PROGRAM_NAME='DietPi-Justboom' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// #Globals @@ -50,7 +33,6 @@ fi - # - MPD OUTPUT_FREQ_CURRENT=0 OUTPUT_FREQ_TARGET=0 @@ -118,7 +100,7 @@ Read_Globals(){ - SOUNDCARD_CURRENT=$(cat /DietPi/dietpi.txt | grep -m1 'soundcard=' | sed 's/.*=//') + SOUNDCARD_CURRENT=$(cat /DietPi/dietpi.txt | grep -m1 'CONFIG_SOUNDCARD=' | sed 's/.*=//') EQ_ENABLED=$(cat /etc/asound.conf | grep -ci -m1 '^pcm.plugequal') @@ -371,18 +353,18 @@ if [ "$OPTION" = "ALSA Output Info" ]; then - /DietPi/dietpi/func/dietpi-notify 3 DietPi-JustBoom "ALSA Output Info" + G_DIETPI-NOTIFY 3 DietPi-JustBoom "ALSA Output Info" local stream_result=$(cat /proc/asound/card*/pcm0p/sub0/hw_params) echo -e "$stream_result" echo -e "" if [ "$stream_result" = "closed" ]; then - /DietPi/dietpi/func/dietpi-notify 1 "Detailed info is only available when audio is being played, play some music first!" + G_DIETPI-NOTIFY 1 "Detailed info is only available when audio is being played, play some music first!" fi - /DietPi/dietpi/func/dietpi-notify 0 "Completed, press any key to exit...\n" + G_DIETPI-NOTIFY 0 "Completed, press any key to exit...\n" read -p "Press any key to exit..." elif [ "$OPTION" = "Subwoofer Mode" ]; then diff --git a/dietpi/misc/start_kodi b/dietpi/misc/start_kodi index 0d3e17e29c..6cd98bc88f 100644 --- a/dietpi/misc/start_kodi +++ b/dietpi/misc/start_kodi @@ -18,24 +18,17 @@ # - startkodi (if alias is created in /etc/bash.bashrc) #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 - - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" - - #///////////////////////////////////////////////////////////////////////////////////// - #Globals - #///////////////////////////////////////////////////////////////////////////////////// - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) + #Import DietPi-Globals --------------------------------------------------------------- + . /DietPi/dietpi/func/dietpi-globals + export G_PROGRAM_NAME='DietPi-Start_kodi' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// # Main Loop #///////////////////////////////////////////////////////////////////////////////////// #----------------------------------------------------------------------------------- #Raspberry Pi - if (( $HW_MODEL < 10 )); then + if (( $G_HW_MODEL < 10 )); then kodi-standalone @@ -47,7 +40,7 @@ if [ "$DISPLAY" ]; then #C2 fix for stuttering and laggy audio: https://github.com/Fourdee/DietPi/issues/399#issuecomment-229413994 - if (( $HW_MODEL == 12 )); then + if (( $G_HW_MODEL == 12 )); then killall -w xcompmgr xcompmgr -a & diff --git a/dietpi/patch_file b/dietpi/patch_file index d7f191c006..cd5f996e2f 100644 --- a/dietpi/patch_file +++ b/dietpi/patch_file @@ -13,26 +13,22 @@ # - Runs from dietpi-update # # Usage: - # - /DietPi/dietpi/patch_file iCurrentVersion iServerVersion + # - /DietPi/dietpi/patch_file $SUBVERSION_CURRENT $SUBVERSION_SERVER #//////////////////////////////////// - #Force en_GB Locale for whole script. Prevents incorrect parsing with non-english locales. - LANG=en_GB.UTF-8 + #Grab input + SUBVERSION_CURRENT=$1 + SUBVERSION_SERVER=$2 - #Ensure we are in users home dir: https://github.com/Fourdee/DietPi/issues/905#issuecomment-298223705 - cd "$HOME" + #Import DietPi-Globals --------------------------------------------------------------- + /DietPi/dietpi/dietpi-obtain_hw_model # Always update + . /DietPi/dietpi/func/dietpi-globals + export G_PROGRAM_NAME='DietPi-Patchfile' + #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// #Globals #///////////////////////////////////////////////////////////////////////////////////// - VERSION_CURRENT=$1 - VERSION_SERVER=$2 - - HW_MODEL=$(sed -n 1p /DietPi/dietpi/.hw_model) - HW_MODEL_DESCRIPTION=$(sed -n 2p /DietPi/dietpi/.hw_model) - DISTRO=$(sed -n 3p /DietPi/dietpi/.hw_model) - HW_ARCH=$(sed -n 6p /DietPi/dietpi/.hw_model) - ALLO_GUI_IMAGE=0 if [ -f /DietPi/dietpi/.installed ] && (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 '^aSOFTWARE_INSTALL_STATE\[159\]=2') )); then @@ -40,2914 +36,93 @@ fi - AUTOINSTALL_ENABLED=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_Install_Enable=' | sed 's/.*=//') - USER_INPUTS=1 - if (( $AUTOINSTALL_ENABLED == 1 && $(cat /DietPi/dietpi/.install_stage) <= 0 )); then #Automated - - USER_INPUTS=0 - - fi - - #Apt-get upgrade, noninteractive func - AGU(){ - - DEBIAN_FRONTEND='noninteractive' apt-get upgrade -y - - } + AUTOINSTALL_ENABLED=$(cat /DietPi/dietpi.txt | grep -m1 '^AUTO_SETUP_AUTOMATED=' | sed 's/.*=//') - AGDU(){ + # FP_EMR='/DietPi/dietpi/.patch_emr' + # EMR_INDEX=0 - DEBIAN_FRONTEND='noninteractive' apt-get dist-upgrade -y + # Obtain_EMR_Index(){ - } + # if [ ! -f "$FP_EMR" ]; then - FP_EMR='/DietPi/dietpi/.patch_emr' - EMR_INDEX=0 + # echo 0 > "$FP_EMR" - Obtain_EMR_Index(){ + # else - if [ ! -f "$FP_EMR" ]; then + # EMR_INDEX=$(cat "$FP_EMR") - echo 0 > "$FP_EMR" + # fi - else + # } - EMR_INDEX=$(cat "$FP_EMR") + # Update_EMR_Index(){ - fi - - } - - Update_EMR_Index(){ - - ((EMR_INDEX++)) - echo $EMR_INDEX > "$FP_EMR" + # ((EMR_INDEX++)) + # echo $EMR_INDEX > "$FP_EMR" - } - - #///////////////////////////////////////////////////////////////////////////////////// - # Main - #///////////////////////////////////////////////////////////////////////////////////// - #Always update HW_* indexs - /DietPi/dietpi/dietpi-obtain_hw_model + # } #///////////////////////////////////////////////////////////////////////////////////// #Emergency Patch System: # This runs before all standard incremental patches. Useful for when shi* hits the ... + # Obtain_EMR_Index - Obtain_EMR_Index - - # - https://github.com/Fourdee/DietPi/issues/669 - # deb security repo now has a forced https redirect, which requires apt-transport-https to be installed, but is only installable from deb security repo........ - if (( $EMR_INDEX == 0 )); then - - if (( ! $(dpkg --get-selections | grep -ci -m1 '^apt-transport-https') )); then - - apt-get install -y apt-transport-https - if (( $? != 0 )); then - - # - armv7 - if (( $HW_ARCH == 2 )); then - - INSTALL_URL='http://security.debian.org/debian-security/pool/updates/main/c/curl/libcurl3-gnutls_7.38.0-4+deb8u5_armhf.deb' - - # - arm64 - elif (( $HW_ARCH == 3 )); then - - INSTALL_URL='http://security.debian.org/debian-security/pool/updates/main/c/curl/libcurl3-gnutls_7.38.0-4+deb8u5_arm64.deb' - - # - x86_64 - elif (( $HW_ARCH == 10 )); then - - INSTALL_URL='http://security.debian.org/debian-security/pool/updates/main/c/curl/libcurl3-gnutls_7.38.0-4+deb8u5_amd64.deb' - - fi - - wget "$INSTALL_URL" -O package.deb - dpkg -i package.deb - rm package.deb - - # - armv7 - if (( $HW_ARCH == 2 )); then - - INSTALL_URL='http://security.debian.org/debian-security/pool/updates/main/a/apt/libapt-pkg4.12_1.0.9.8.4_armhf.deb' - - # - arm64 - elif (( $HW_ARCH == 3 )); then - - INSTALL_URL='http://security.debian.org/debian-security/pool/updates/main/a/apt/libapt-pkg4.12_1.0.9.8.4_arm64.deb' - - # - x86_64 - elif (( $HW_ARCH == 10 )); then - - INSTALL_URL='http://security.debian.org/debian-security/pool/updates/main/a/apt/libapt-pkg4.12_1.0.9.8.4_amd64.deb' + # if (( $EMR_INDEX == 0 )); then - fi - - wget "$INSTALL_URL" -O package.deb - dpkg -i package.deb - rm package.deb - - # - armv7 - if (( $HW_ARCH == 2 )); then - - INSTALL_URL='http://security.debian.org/debian-security/pool/updates/main/a/apt/apt-transport-https_1.0.9.8.4_armhf.deb' - - # - arm64 - elif (( $HW_ARCH == 3 )); then - - INSTALL_URL='http://security.debian.org/debian-security/pool/updates/main/a/apt/apt-transport-https_1.0.9.8.4_arm64.deb' - - # - x86_64 - elif (( $HW_ARCH == 10 )); then - - INSTALL_URL='http://security.debian.org/debian-security/pool/updates/main/a/apt/apt-transport-https_1.0.9.8.4_amd64.deb' - - fi - - wget "$INSTALL_URL" -O package.deb - dpkg -i package.deb - rm package.deb - - fi - - fi - - Update_EMR_Index - - fi - - #Debian apt mirror fix: https://github.com/Fourdee/DietPi/issues/755 - if (( $EMR_INDEX == 1 )); then - - #------------------------------------------------------------------------------- - sed -i "s@debian.org/debian[[:space:]]@debian.org/debian/ @g" /etc/apt/sources.list - #------------------------------------------------------------------------------- - Update_EMR_Index - - fi - - #Placeholder - # if (( $EMR_INDEX == 2 )); then - - # Update_EMR_Index + # echo 0 # fi #///////////////////////////////////////////////////////////////////////////////////// #Incremental patch system: + if (( $SUBVERSION_CURRENT == -1 )); then - if (( $VERSION_CURRENT == 102 )); then - #------------------------------------------------------------------------------- - #DNS fixes for STATIC. We MUST supply DNS servers if using STATIC, else /etc/resolv.conf will be empty. - # - Update curret network details - /DietPi/dietpi/func/obtain_network_details - # - Add missing disabled dns-nameservers to wlan. - sed -i "/wpa-psk /a #dns-nameservers 8.8.8.8 8.8.4.4" /etc/network/interfaces - # - If static IP is currently in use, enable google dns-nameservers. - active_network_adapter=$(sed -n 3p /DietPi/dietpi/.network) - if (( $( cat /etc/network/interfaces | grep -ci -m1 "iface $active_network_adapter inet static") == 1 )); then - sed -i 's/^#dns-nameservers/dns-nameservers/g' /etc/network/interfaces - fi - # - Delete 'Uncomment for Google DNS servers reference' - sed -i '/Uncomment for Google/d' /etc/network/interfaces - # - Add DNS entry to dietpi.txt - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'Static_DNS=') == 0 )); then - sed -i "/Static_Gateway=/a Static_DNS=8.8.8.8" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - #Missing Resolvconf - /DietPi/dietpi/dietpi-apt-get_update 1 - apt-get install resolvconf -y - #------------------------------------------------------------------------------- - #New Bash Alias's - if (( $(cat /etc/bash.bashrc | grep -ci -m1 'dietpi-autostart=') == 0 )); then - sed -i "/#DietPi Additions/a alias dietpi-autostart='/DietPi/dietpi/dietpi-autostart'" /etc/bash.bashrc - fi - - if (( $(cat /etc/bash.bashrc | grep -ci -m1 'dietpi-affinity=') == 0 )); then - sed -i "/#DietPi Additions/a alias dietpi-affinity='/DietPi/dietpi/dietpi-affinity'" /etc/bash.bashrc - fi - - if (( $(cat /etc/bash.bashrc | grep -ci -m1 'dietpi-letsencrypt=') == 0 )); then - sed -i "/#DietPi Additions/a alias dietpi-letsencrypt='/DietPi/dietpi/dietpi-letsencrypt'" /etc/bash.bashrc - fi - # - DietPi-Cloudshell input cli changes - if (( $(cat /etc/bash.bashrc | grep -ci -m1 'dietpi-cloudshell=') == 1 )); then - sed -i '/alias dietpi-cloudshell=/d' /etc/bash.bashrc &> /dev/null - sed -i "/#DietPi Additions/a alias dietpi-cloudshell='/DietPi/dietpi/dietpi-cloudshell'" /etc/bash.bashrc - fi - #------------------------------------------------------------------------------- - #NTPD drift file ownership must match user that NTPD runs as, or it wont write to drift file (even though its ran as root.......) - chown root:root /var/lib/ntp/ntp.drift - #------------------------------------------------------------------------------- - #Information change for crontab (DietPi-Cron instead of dietpi-config) - sed -i '/#Please use dietpi-config/c\#Please use DietPi-Cron to change cron start times' /etc/crontab &> /dev/null - #------------------------------------------------------------------------------- - #Proftpd patch | to stop logging wtmp /var/log/wtmp: No such file or directory -Gordon Williams change - if [ -f /etc/proftpd/proftpd.conf ]; then - if (( $(cat /etc/proftpd/proftpd.conf | grep -ci -m1 'WtmpLog') == 0 )); then - sed -i "/SystemLog /a #to stop logging wtmp /var/log/wtmp: No such file or directory -Gordon Williams change\nWtmpLog off" /etc/proftpd/proftpd.conf - fi - fi - #------------------------------------------------------------------------------- - - - elif (( $VERSION_CURRENT == 103 )); then - #------------------------------------------------------------------------------- - # New automation/misc options > dietpi.txt - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^AUTO_AutoLogin=') == 0 )); then - sed -i "/# >> Automation Options/a #Automatically logs the root user in to start 1st run setup.\nAUTO_AutoLogin=0" /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^Hostname=') == 0 )); then - sed -i "/# >> Automation Options/a Hostname=DietPi" /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^Swapfile_Size=') == 0 )); then - sed -i "/# >> Automation Options/a Swapfile_Size=100" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - #FP name change for autoboot (now DietPi-Autostart) - mv /DietPi/dietpi/.auto_boot_index /DietPi/dietpi/.dietpi-autostart_index - #------------------------------------------------------------------------------- - #DietPi-Cloudshell - 'c / 'f option / Target output - if [ -f /DietPi/dietpi/.dietpi-cloudshell ]; then - sed -i '4s/.*/1/' /DietPi/dietpi/.dietpi-cloudshell - sed -i '5s/.*/0/' /DietPi/dietpi/.dietpi-cloudshell - fi - #------------------------------------------------------------------------------- - #dphys-swapfile - add location to conf - if (( $(cat /etc/dphys-swapfile | grep -ci -m1 '^CONF_SWAPFILE=') == 0 )); then - echo -e "CONF_SWAPFILE=/var/swap" >> /etc/dphys-swapfile - fi - #------------------------------------------------------------------------------- - #PiHole Update - if [ -f /usr/local/bin/gravity.sh ]; then - #remove old lists (we need to regenerate) - rm /etc/pihole/list.* - rm /etc/pihole/pihole.* - rm /etc/pihole/gravity.list - - cp /DietPi/dietpi/conf/pihole_gravity /usr/local/bin/gravity.sh - chmod +x /usr/local/bin/gravity.sh - /usr/local/bin/gravity.sh - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 104 )); then - #------------------------------------------------------------------------------- - #DietPi-Software additions - # - automation add option - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_WIFIHOTSPOT=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_WEBSERVER_MYADMINPHP=/a AUTO_DietpiSoftware_Install_WIFIHOTSPOT=0" /DietPi/dietpi.txt - fi - - #------------------------------------------------------------------------------- - #dietpi-cleaner alias missing from bashrc - if (( $(cat /etc/bash.bashrc | grep -ci -m1 'dietpi-cleaner=') == 0 )); then - sed -i "/#DietPi Additions/a alias dietpi-cleaner='/DietPi/dietpi/dietpi-cleaner'" /etc/bash.bashrc - fi - #------------------------------------------------------------------------------- - #Wifi Hotspot settings - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'wifi_hotspot_ssid=') == 0 )); then - sed -i "/ntpd_update_mode=/a\ \n#Wifi Hotspot\nwifi_hotspot_ssid=DietPi-HotSpot\n# - minimum of 8 characters\nwifi_hotspot_key=dietpihotspot\nwifi_hotspot_channel=3" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 105 )); then - #------------------------------------------------------------------------------- - #DietPi-Software additions - # - automation add option - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_SHAIRPORTSYNC=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_WEBSERVER_MYADMINPHP=/a AUTO_DietpiSoftware_Install_SHAIRPORTSYNC=0" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - #dbus-x11 now installed by default with xserver installations. Required for ibus, fcitx etc. inputs. - if [ -f /DietPi/dietpi/.installed ]; then - if (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'XSERVERXORG 2') == 1 )); then - /DietPi/dietpi/dietpi-apt-get_update 1 - apt-get install dbus-x11 -y - fi - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 106 )); then - #------------------------------------------------------------------------------- - # DietPi-Process Tool - # - bash alias add dietpi-process_control - if (( $(cat /etc/bash.bashrc | grep -ci -m1 'dietpi-process_tool=') == 0 )); then - sed -i "/#DietPi Additions/a alias dietpi-process_tool='/DietPi/dietpi/dietpi-process_tool'" /etc/bash.bashrc - fi - # - bash alias, remove nice/affinity - sed -i '/dietpi-nice/d' /etc/bash.bashrc - sed -i '/dietpi-affinity/d' /etc/bash.bashrc - #remove .dietpi-nice .dietpi-affinity settings - rm /DietPi/dietpi/.dietpi-nice - rm /DietPi/dietpi/.dietpi-affinity - #------------------------------------------------------------------------------- - #Prompt user regarding nice/affinity changes - if [ -f /DietPi/dietpi/.installed ]; then - whiptail --title "Info: DietPi-Process_Tool" --msgbox "DietPi-Affinity and DietPi-Nice has now been replaced by DietPi-Process_Tool.\n\nIf you have used these programs in the past, you will need to reapply your nice and affinity settings by running the following command, after you reboot the system.\n\ndietpi-process_tool" 14 70 - fi - #------------------------------------------------------------------------------- - #Enable IPv6 for all DietPi images by default - rm /etc/modprobe.d/blacklist-ipv6.conf &> /dev/null - #Update /etc/hosts with ipv6 - if (( $(cat /etc/hosts | grep -ci -m1 'ip6-localhost') == 0 )); then - cat << _EOF_ >> /etc/hosts -::1 localhost ip6-localhost ip6-loopback -ff02::1 ip6-allnodes -ff02::2 ip6-allrouters -_EOF_ - fi - #------------------------------------------------------------------------------- - #DietPi-Software additions - # - automation add option - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_BRUTEFIR=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_WEBSERVER_MYADMINPHP=/a AUTO_DietpiSoftware_Install_BRUTEFIR=0" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 107 )); then - #------------------------------------------------------------------------------- - #DietPi-Software additions - # - automation add option - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_PYDIO=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_WEBSERVER_MYADMINPHP=/a AUTO_DietpiSoftware_Install_PYDIO=0" /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_SQUEEZELITE=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_WEBSERVER_MYADMINPHP=/a AUTO_DietpiSoftware_Install_SQUEEZELITE=0" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - #DESKTOP_LXDE dietpi-nice > dietpi-process_tool - if [ -f /DietPi/dietpi/.installed ]; then - if (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'DESKTOP_LXDE 2') == 1 )); then - rm /usr/share/applications/dietpi-nice.desktop - ln -sf /DietPi/dietpi/conf/desktop/dietpi-process_tool.desktop /usr/share/applications/dietpi-process_tool.desktop - fi - fi - #------------------------------------------------------------------------------- - elif (( $VERSION_CURRENT == 108 )); then - #------------------------------------------------------------------------------- - #Pydrio: Impossible write into the AJXP_DATA_PATH folder https://github.com/Fourdee/DietPi/issues/186 - chown -R www-data:www-data /pydio_data &> /dev/null - chown -R www-data:www-data /mnt/usb_1/pydio_data &> /dev/null - #------------------------------------------------------------------------------- - #PiHole webstats patch https://github.com/Fourdee/DietPi/issues/187#issue-131328814 - if [ -f /usr/local/bin/gravity.sh ]; then - wget https://raw.githubusercontent.com/pi-hole/pi-hole/master/advanced/Scripts/chronometer.sh -O /usr/local/bin/chronometer.sh - chmod +x /usr/local/bin/chronometer.sh - - /DietPi/dietpi/dietpi-apt-get_update 1 - apt-get install -y bc - fi - #------------------------------------------------------------------------------- - #DietPi-Software additions - # - Lighttpd - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_WEBSERVER_LLMP=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_WEBSERVER_MYADMINPHP=/a AUTO_DietpiSoftware_Install_WEBSERVER_LLMP=0" /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_WEBSERVER_LLSP=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_WEBSERVER_MYADMINPHP=/a AUTO_DietpiSoftware_Install_WEBSERVER_LLSP=0" /DietPi/dietpi.txt - fi - - # - MariaDB - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_WEBSERVER_LAAP=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_WEBSERVER_MYADMINPHP=/a AUTO_DietpiSoftware_Install_WEBSERVER_LAAP=0" /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_WEBSERVER_LEAP=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_WEBSERVER_MYADMINPHP=/a AUTO_DietpiSoftware_Install_WEBSERVER_LEAP=0" /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_WEBSERVER_LLAP=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_WEBSERVER_MYADMINPHP=/a AUTO_DietpiSoftware_Install_WEBSERVER_LLAP=0" /DietPi/dietpi.txt - fi - - #------------------------------------------------------------------------------- - #Disable powersaving for 8188eu wifi chipsets - echo -e "options 8188eu rtw_power_mgnt=0" > /etc/modprobe.d/8188eu.conf - #------------------------------------------------------------------------------- - #debconf-get-selections mising from odroid's - /DietPi/dietpi/dietpi-apt-get_update 1 - apt-get install -y debconf-utils - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 109 )); then - #------------------------------------------------------------------------------- - #Put XU4 kernel updates on hold to prevent automated installations causing broken kernel/modules. - #https://github.com/Fourdee/DietPi/issues/185#issuecomment-183343474 - if (( $HW_MODEL == 11 )); then - apt-mark hold linux-headers-armhf-odroid-xu3 linux-image-armhf-odroid-xu3 - fi - #------------------------------------------------------------------------------- - #LXDE desktop, remove dietpi-nice.desktop links, add dietpi-process_tool - if [ -f /DietPi/dietpi/.installed ]; then - if (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'DESKTOP_LXDE 2') == 1 )); then - rm /usr/share/applications/dietpi-nice.desktop - ln -sf /DietPi/dietpi/conf/desktop/dietpi-process_tool.desktop /usr/share/applications/dietpi-process_tool.desktop - fi - fi - #------------------------------------------------------------------------------- - #DietPi.txt | new option to override user/personal data target directory in DietPi-Software: https://github.com/Fourdee/DietPi/issues/198 - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'dietpi_userdata_basedirectory=') == 0 )); then - sed -i "/wifi_hotspot_channel=/a #------------------------------------------------------------------------------------------------------\n# D I E T - P I\n# DietPi-Software settings.\n#------------------------------------------------------------------------------------------------------\n#Override target directory for user/personal data.\n#This is applied to software configurations when installing software (eg: owncloud, bittorrent downloads etc).\n# Auto = Automatic (default). If USB dedicated drive was setup /mnt/usb_1, else, /root\n# /mnt/Where/I/Want/My/Data = Example\n# /mnt/user_data = Example\ndietpi_userdata_basedirectory=Auto\n" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - #Updated network details script , rerun - /DietPi/dietpi/func/obtain_network_details - #------------------------------------------------------------------------------- - #BC is now installed by default on all DietPi systems. bc is needed for bash floating point calculations that many scripts rely on. - /DietPi/dietpi/dietpi-apt-get_update 1 - apt-get install -y bc - #------------------------------------------------------------------------------- - #Cloudshell new option | NETWORK_USAGE_CURRENT_OUTPUT_TYPE - if [ -f /DietPi/dietpi/.dietpi-cloudshell ]; then - sed -i '6s/.*/0/' /DietPi/dietpi/.dietpi-cloudshell - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 110 )); then - #------------------------------------------------------------------------------- - #DietPi-Software additions: - # - Oracle Java 8 jdk - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_ORACLEJAVA=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_FFMPEG=/a AUTO_DietpiSoftware_Install_ORACLEJAVA=0" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - #RPI Jessie: - # - remove /etc/apt/sources.list.d/collabora.list. This was left over from Wheezy dist-upgrade and is not required. - # - Update /etc/apt/sources.list.d/raspi.list to match Raspbian Jessie raspi.list. - if (( $HW_MODEL < 10 )) && (( $DISTRO == 3 )); then - rm /etc/apt/sources.list.d/collabora.list - cat << _EOF_ > /etc/apt/sources.list.d/raspi.list -deb http://archive.raspberrypi.org/debian/ jessie main ui -# Uncomment line below then 'apt-get update' to enable 'apt-get source' -#deb-src http://archive.raspberrypi.org/debian/ jessie main ui -_EOF_ - /DietPi/dietpi/dietpi-apt-get_update 2 - fi - #------------------------------------------------------------------------------- - #RPI - snd-bcm2835 is now disabled by default. - if (( $HW_MODEL < 10 )) && (( $(dpkg -l | grep -ci -m1 'alsa') == 0 )); then - /DietPi/dietpi/func/dietpi-set_hardware soundcard none - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 111 )); then - #------------------------------------------------------------------------------- - #RPi 3 - WiFi hotspot. Internal Wifi fix. - # - Disable driver definition - # - Use non-modified hostapd binary from Jessie repo. - if (( $HW_MODEL == 3 )) && (( $(dpkg -l | grep -ci -m1 'hostapd') == 1 )); then - apt-get remove hostapd -y - apt-get install hostapd -y - sed -i '/driver=/c\#driver=rtl871xdrv/' /etc/hostapd/hostapd.conf - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 112 )); then - #------------------------------------------------------------------------------- - #/DietPi/dietpi/dietpi-apt-get_update 1 is now called in dietpi-update, before this patch file is launched. - # - Run it now for previous DietPi versions. As dietpi-update is loaded into memory, it wont be updated until a reboot. - /DietPi/dietpi/dietpi-apt-get_update 1 - #------------------------------------------------------------------------------- - #New location for dietpi-software installed "non-service" based control scripts - mkdir -p /etc/dietpi/dietpi-software/services - - # - move to new location, if installed - mv /etc/deluge_init /etc/dietpi/dietpi-software/services/deluge.service &> /dev/null - mv /etc/raspimjpeg_init /etc/dietpi/dietpi-software/services/raspimjpeg.service &> /dev/null - mv /etc/squeezeboxserver_init /etc/dietpi/dietpi-software/services/squeezeboxserver.service &> /dev/null - mv /etc/BruteFIR/brutefir.service /etc/dietpi/dietpi-software/services/brutefir.service &> /dev/null - chmod -R +x /etc/dietpi/dietpi-software/services - #------------------------------------------------------------------------------- - #DietPi-Software additions: - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_WEBSERVER_REDIS=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_WEBSERVER_MYADMINPHP=/a AUTO_DietpiSoftware_Install_WEBSERVER_REDIS=0" /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_EMONHUB=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_SQUEEZELITE=/a AUTO_DietpiSoftware_Install_EMONHUB=0" /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_EMONCMS=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_SQUEEZELITE=/a AUTO_DietpiSoftware_Install_EMONCMS=0" /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_NODEJS=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_BUILDESSENTIAL=/a AUTO_DietpiSoftware_Install_NODEJS=0" /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_RPIMONITOR=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_SQUEEZELITE=/a AUTO_DietpiSoftware_Install_RPIMONITOR=0" /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_BAIKAL=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_SQUEEZELITE=/a AUTO_DietpiSoftware_Install_BAIKAL=0" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - #PiHole webstats update - if [ -f /var/www/pihole/index.php ]; then - cd ~/ - rm -R /var/www/pihole/* - wget https://github.com/Fourdee/AdminLTE/archive/master.zip -O package.zip - unzip package.zip - rm package.zip - mv AdminLTE*/* /var/www/pihole/ - rm -R AdminLTE* - fi - #------------------------------------------------------------------------------- - #RPi Jessie DietPi v111 image missing ipv6 in hosts. Add if it doesnt exist - if (( $(cat /etc/hosts | grep -ci -m1 'ip6-localhost') == 0 )); then - cat << _EOF_ >> /etc/hosts -::1 localhost ip6-localhost ip6-loopback -ff02::1 ip6-allnodes -ff02::2 ip6-allrouters -_EOF_ - fi - #------------------------------------------------------------------------------- - #Odroid C2 - Kodi sound fix - if (( $HW_MODEL == 12 )); then - if (( $(dpkg -l | grep -ci -m1 'kodi-odroid') == 1 )); then - - # - upgrade kodi - apt-get update - AGU - - # - Remove pulse audio workaround fix we used. - apt-get purge pulseaudio -y - apt-get autoremove --purge -y - - # - Asound.conf by Oversun. - cat << _EOF_ > /etc/asound.conf -pcm.!default { - type plug - slave { - pcm "hw:0,0" - format S32_LE - } -} -_EOF_ - fi - fi - #------------------------------------------------------------------------------- - #fbset now installed by default - apt-get install -y fbset - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 113 )); then - #------------------------------------------------------------------------------- - #DietPi-Software Additions - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_TORHOTSPOT=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_WIFIHOTSPOT=/a AUTO_DietpiSoftware_Install_TORHOTSPOT=0" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - # New dietpi-software options > dietpi.txt - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^dietpi_emonhub_apikey=') == 0 )); then - sed -i "/dietpi_userdata_basedirectory=/a #Enter your EmonCMS.org write API key here. It will be applied automatically during EmonPi/Hub installation.\n# - eg: dietpi_emonhub_apikey=b4dfmk2o203mmxx93a\ndietpi_emonhub_apikey=" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - #C1 - Ondemand does not work, replace with interactive: https://github.com/Fourdee/DietPi/issues/248 - if (( $HW_MODEL == 10 )) && (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^cpu_governor=ondemand') == 1 )); then - sed -i "/cpu_governor=/c\cpu_governor=interactive" /DietPi/dietpi.txt - /DietPi/dietpi/dietpi-cpu_set - fi - #------------------------------------------------------------------------------- - #RPi | Enable max usb current by default - sed -i '/max_usb_current=/c\max_usb_current=1' /DietPi/config.txt - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 114 )); then - #------------------------------------------------------------------------------- - #OPi PC - Comminuty Fix vcore/freq: https://github.com/Fourdee/DietPi/issues/263 - if (( $HW_MODEL == 30 )); then - - # - Warn user of OPi-PC only support after this is run. - whiptail --title "OPi-PC vcore/stability fix" --yesno "This will apply the community vcore/stability fix on your system. The fix resolves known issues with the H3 clockspeeds and vcore voltages. Whilst this patch has been tested on OPi-PC systems, there is no guarantee the fix will work, and, could render your system unbootable.\n\nNB: If you NOT using an OPi-PC, say no.\n\nDo you wish to apply the community H3 patch?" --backtitle "DietPi-Update" --defaultno 16 70 - CHOICE=$? - if (( $CHOICE == 0 )); then - wget http://dietpi.com/downloads/misc/community/h3_fix_vcore_clock.sh -O patch - chmod +x patch - ./patch - rm patch - fi - - fi - #------------------------------------------------------------------------------- - #Webserver preference system - # - update .installed file with new options. - if [ -f /DietPi/dietpi/.installed ]; then - - index=-2 #lighttpd - - if (( $(dpkg -l | awk '{print $2}' | grep -ci -m1 'apache2') )); then - index=0 - elif (( $(dpkg -l | awk '{print $2}' | grep -ci -m1 'nginx') )); then - index=-1 - fi - - cat << _EOF_ >> /DietPi/dietpi/.installed -#DietPi Preference System: Webserver base -INDEX_WEBSERVER_CURRENT $index -INDEX_WEBSERVER_TARGET $index -_EOF_ - - fi - - # - Add automation support for Webserver preference to dietpi.txt. - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_WebserverIndex=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_LoggingIndex=/a #Webserver Preference Selection:\n# NB: This will get ignored, if you have manually selected any WEBSERVER_Stacks.\n# 0=Apache2\n# -1=Nginx\n# -2=Lighttpd\nAUTO_DietpiSoftware_WebserverIndex=-2" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - # Possible missing dietpi.txt global vars for < v109 images. Add them if required. - # - To prevent this from occuring again: - # For AUTO_ entries, use sed to insert at specific line - # For global VARs, just echo the value to the end of dietpi.txt - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'wifi_hotspot_ssid=') == 0 )); then - echo -e "wifi_hotspot_ssid=DietPi-HotSpot" >> /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'wifi_hotspot_key=') == 0 )); then - echo -e "wifi_hotspot_key=dietpihotspot" >> /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'wifi_hotspot_channel=') == 0 )); then - echo -e "wifi_hotspot_channel=3" >> /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'dietpi_userdata_basedirectory=') == 0 )); then - echo -e "dietpi_userdata_basedirectory=Auto" >> /DietPi/dietpi.txt - fi - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'dietpi_emonhub_apikey=') == 0 )); then - echo -e "dietpi_emonhub_apikey=" >> /DietPi/dietpi.txt - fi #------------------------------------------------------------------------------- + #Asus TB G_HW_MODEL change + if [ -f /etc/.dietpi_hw_model_identifier ] && + (( $(sed -n 1p /etc/.dietpi_hw_model_identifier) == 100 )); then - elif (( $VERSION_CURRENT == 115 )); then - #------------------------------------------------------------------------------- - # Add netdata to existing dietpi.txt automation file - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_NETDATA=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_LINUXDASH=/a AUTO_DietpiSoftware_Install_NETDATA=0" /DietPi/dietpi.txt - fi - - # + DietPi.txt Proxy settings - # NB: Always add extra line to cat feed: https://github.com/Fourdee/DietPi/issues/301#issue-151214787 - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^proxy_address=') == 0 )); then - cat << _EOF_ >> /DietPi/dietpi.txt - -#Proxy settings | System-wide proxy settings. Use dietpi-config > networking options to apply. -proxy_enabled=0 -proxy_address=MyProxyServer.com -proxy_port=8080 -proxy_username= -proxy_password= -_EOF_ - fi - #------------------------------------------------------------------------------- - #Odroid C1 WiFi fix (missing packages): https://github.com/Fourdee/DietPi/issues/273#issuecomment-210410651 - if (( $HW_MODEL == 10 )); then - apt-get install -y wireless-regdb iw crda wpasupplicant - fi - #------------------------------------------------------------------------------- + export G_HW_MODEL=52 + echo $G_HW_MODEL > /etc/.dietpi_hw_model_identifier + /DietPi/dietpi/dietpi-obtain_hw_model - elif (( $VERSION_CURRENT == 116 )); then - #------------------------------------------------------------------------------- - #DietPi-Software additions - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'AUTO_DietpiSoftware_Install_MUMBLESERVER=') == 0 )); then - sed -i "/AUTO_DietpiSoftware_Install_EMONHUB=/a AUTO_DietpiSoftware_Install_MUMBLESERVER=0" /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - #update .installed file to new format - if [[ -f /DietPi/dietpi/.installed ]]; then - sed -i -re 's/(^[^#]\S*) (.*)/\1=\2/' /DietPi/dietpi/.installed - fi - - #update cron jobs to use new .installed format - cp /DietPi/dietpi/conf/cron.daily_dietpi /etc/cron.daily/dietpi - chmod +x /etc/cron.daily/dietpi - cp /DietPi/dietpi/conf/cron.hourly_dietpi /etc/cron.hourly/dietpi - chmod +x /etc/cron.hourly/dietpi - #------------------------------------------------------------------------------- - #ifmetric: https://github.com/Fourdee/DietPi/issues/273#issuecomment-213951519 - apt-get install -y ifmetric - if (( $(cat /etc/network/interfaces | grep -ci -m1 '^metric ') == 0 )); then - # - eth - sed -i "/iface eth$(sed -n 1p /DietPi/dietpi/.network)/a metric 0" /etc/network/interfaces - # - wlan - sed -i "/iface wlan$(sed -n 2p /DietPi/dietpi/.network)/a metric 1" /etc/network/interfaces fi #------------------------------------------------------------------------------- - #netplug. Resolves issues with unplugging eth and breaking all connections, when WiFi is also active: https://github.com/Fourdee/DietPi/issues/273#issuecomment-215996025 - apt-get install netplug -y - cat << _EOF_ > /etc/netplug/netplugd.conf -eth* -wlan* -_EOF_ - #------------------------------------------------------------------------------- - #Roll out allow-hotplug as default: https://github.com/Fourdee/DietPi/issues/305 - # - Active - # eth - sed -i "/^auto eth$(sed -n 1p /DietPi/dietpi/.network)/c\allow-hotplug eth$(sed -n 1p /DietPi/dietpi/.network)" /etc/network/interfaces - # wlan - sed -i "/^auto wlan$(sed -n 2p /DietPi/dietpi/.network)/c\allow-hotplug wlan$(sed -n 2p /DietPi/dietpi/.network)" /etc/network/interfaces - # - inactive - # eth - sed -i "/^#auto eth$(sed -n 1p /DietPi/dietpi/.network)/c\#allow-hotplug eth$(sed -n 1p /DietPi/dietpi/.network)" /etc/network/interfaces - # wlan - sed -i "/^#auto wlan$(sed -n 2p /DietPi/dietpi/.network)/c\#allow-hotplug wlan$(sed -n 2p /DietPi/dietpi/.network)" /etc/network/interfaces - #------------------------------------------------------------------------------- - #apply to all DietPi systems (but targeted at Odroid XU4) - missing WiFi packages. - apt-get install -y wireless-regdb iw crda wpasupplicant - #------------------------------------------------------------------------------- - #Missing line at EOF - echo -e "" >> /etc/network/interfaces + #bash.bashrc removal of any outstanding dietpi entries (moved to globals). Just incase I missed any manually during PREP... + sed -i '/#DietPi_Entries/Q' /etc/bash.bashrc + sed -i '/#Apply system locale/Q' /etc/bash.bashrc + sed -i '/#DietPi Additions/Q' /etc/bash.bashrc #------------------------------------------------------------------------------- + #Fix locales according to: https://github.com/Fourdee/DietPi/pull/1402 + if [ -f /etc/environment ]; then - elif (( $VERSION_CURRENT == 117 )); then - #------------------------------------------------------------------------------- - #DietPi-Software additions: - # NB: We no longer need to do this. - # Users can download and copy the latest dietpi.txt file to SD, prior to boot, which will contain all current automation options. - # Theres no need for us to add them in during patching to their dietpi.txt. - #------------------------------------------------------------------------------- - #WiFi country code - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'wifi_country_code=') == 0 )); then - echo -e "\n#WiFi country code. 2 character value (eg GB US DE JP): https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2\nwifi_country_code=" >> /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - #Remove _ from installed file: https://github.com/Fourdee/DietPi/issues/322 - if [ -f /DietPi/dietpi/.installed ]; then - sed -i '/^_$/d' /DietPi/dietpi/.installed - fi - #------------------------------------------------------------------------------- - #Subsonic now has two installation versions, v5 being the previous installation option.: https://github.com/Fourdee/DietPi/issues/330 - if [ -f /DietPi/dietpi/.installed ]; then - sed -i 's/^SUBSONIC=/SUBSONIC5=/' /DietPi/dietpi/.installed - fi - #------------------------------------------------------------------------------- - #Patch PineA64 to include xz-utils for firmware upgrades (only needed w/ alpha v118 image - if (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then - apt-get update - apt-get install -y --no-install-recommends xz-utils + rm /etc/environment + [ -f /etc/default/locales ] && rm /etc/default/locales + locale_value="$(grep '^[[:blank:]]*AUTO_SETUP_LOCALE=' /DietPi/dietpi.txt | sed 's/^.*=//')" + [ -n $locale_value ] || locale_value='en_GB.UTF-8' + /DietPi/dietpi/func/dietpi-set_software locale "$locale_value" + unset locale_value - /usr/local/sbin/pine64_update_uboot.sh - /usr/local/sbin/pine64_update_kernel.sh - /usr/local/sbin/pine64_fix_whatever.sh fi #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 118 )); then + #Fix doubled and renamed config files: + #https://github.com/Fourdee/DietPi/commit/68148cec6b49afc787deca638456e1c4689e1cab#diff-8370b86e635383d521462994afe04a2d + [ -f /etc/apt/apt.conf.d/99force-ipv ] && rm /etc/apt/apt.conf.d/99force-ipv + [ -f /etc/sysctl.d/97-dietpi.conf ] && mv /etc/sysctl.d/97-dietpi.conf /etc/sysctl.d/99-dietpi.conf #------------------------------------------------------------------------------- - #Transmission, service starts before network via SystemD, instead of "dietpi-services start": https://github.com/Fourdee/DietPi/issues/350 - if [ -f /DietPi/dietpi/.installed ] && - (( $DISTRO == 3 )) && - (( $( cat /DietPi/dietpi/.installed | grep -ci -m1 '^TRANSMISSION=2' ) )); then - - rm /etc/init.d/transmission-daemon - rm /etc/systemd/system/transmission-daemon.service - cat << _EOF_ > /etc/systemd/system/transmission-daemon.service -[Unit] -Description=Barebones transmission-daemon service -DefaultDependencies=no - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/usr/bin/transmission-daemon --config-dir /var/lib/transmission-daemon/info -ExecStop=/usr/bin/killall -w transmission-daemon -StandardOutput=tty - -[Install] -WantedBy=multi-user.target -_EOF_ - systemctl enable transmission-daemon.service - systemctl daemon-reload - /DietPi/dietpi/dietpi-services dietpi_controlled - - fi + #Core_ENV update: https://github.com/Fourdee/DietPi/pull/1419 + # IPv6 disable x86_64 + # consoleblank disable x86_64 + /DietPi/dietpi/func/dietpi-set_core_environment #------------------------------------------------------------------------------- - #dietpi.txt global vnc settings - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^dietpi_vncserver_height=') )); then - echo -e "\n#VNC Server Options\ndietpi_vncserver_width=1280\ndietpi_vncserver_height=720\ndietpi_vncserver_depth=16\ndietpi_vncserver_display=0" >> /DietPi/dietpi.txt - fi + #Remove -dev keyring + G_AGP debian-keyring #------------------------------------------------------------------------------- - #VNC servers, now start automatically during boot via service. - if [ -f /DietPi/dietpi/.installed ] && - (( $( cat /DietPi/dietpi/.installed | grep -ci -m1 '^TIGHTVNCSERVER=2' ) )); then - - #Wheezy - if (( $DISTRO == 1 )); then - - cat << _EOF_ > /etc/init.d/vncserver -#!/bin/bash -e -### BEGIN INIT INFO -# Provides: VNC server -# Required-Start: \$all -# Should-Start: -# Required-Stop: \$local_fs \$network -# Should-Stop: -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Description: DietPi VNC server control -### END INIT INFO - -#Wheezy, to prevent "vncserver: The HOME/USER environment variable is not set" -export USER=root -export HOME='/root' - -start(){ - - /usr/local/bin/vncserver start - -} - -stop(){ - - /usr/local/bin/vncserver stop - -} - -case "\$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop - start - ;; - *) - echo "Usage: \$0 {start|stop|restart}" - ;; -esac -_EOF_ - - chmod +x /etc/init.d/vncserver - update-rc.d vncserver defaults 00 80 - - - #Jessie - elif (( $DISTRO == 3 )); then - - cat << _EOF_ > /etc/systemd/system/vncserver.service -[Unit] -Description=Manage VNC Server -After=dietpi-service.service -After=rc.local.service -[Service] -Type=idle -RemainAfterExit=yes -ExecStart=/bin/bash /usr/local/bin/vncserver start -ExecStop=/bin/bash /usr/local/bin/vncserver stop -User=root - -[Install] -WantedBy=multi-user.target -_EOF_ - - systemctl enable vncserver.service - systemctl daemon-reload - - fi - - # - Both - cat << _EOF_ > /usr/local/bin/vncserver -#!/bin/bash - -#Globals -VNC_INSTALLED=0 -BINARY_FP=0 - -WIDTH=\$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_vncserver_width=' | sed 's/.*=//') -HEIGHT=\$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_vncserver_height=' | sed 's/.*=//') -DEPTH=\$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_vncserver_depth=' | sed 's/.*=//') -DISPLAY=\$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_vncserver_display=' | sed 's/.*=//') - -#TightVNC or VNC4server? -if [ -f /usr/bin/vnc4server ]; then - BINARY_FP='/usr/bin/vnc4server' - VNC_INSTALLED=1 -elif [ -f /usr/bin/vncserver ]; then - BINARY_FP='/usr/bin/vncserver' - VNC_INSTALLED=1 -fi - -#Exit if no VNC binary found -if (( ! \$VNC_INSTALLED )); then - exit 1 -fi - -case "\$1" in - start) - \$BINARY_FP :\$DISPLAY -geometry \$WIDTH'x'\$HEIGHT -depth \$DEPTH - ;; - - stop) - \$BINARY_FP -kill :\$DISPLAY - ;; - -esac - -exit 0 -_EOF_ - chmod +x /usr/local/bin/vncserver - - fi - #------------------------------------------------------------------------------- - #Removal of VNC server from DietPi-Autostart. Reset to console, manual login. - if (( $(cat /DietPi/dietpi/.dietpi-autostart_index) == 6 )); then - echo 0 > /DietPi/dietpi/.dietpi-autostart_index - fi - #------------------------------------------------------------------------------- - #dietpi.txt | Serial console global var - # - Set this to 0 disabled (the previous default for all DietPi images). Future images will have this enabled by default. - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'serial_console_enabled=') == 0 )); then - echo -e "\n#Serial Console: If you dont know what this is, you can safely disable it (=0) to reduce system resource usage.\nserial_console_enabled=0" >> /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - #dietpi.txt | Soundcard global var - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'soundcard=') == 0 )); then - echo -e "\n#Soundcard\nsoundcard=none" >> /DietPi/dietpi.txt - fi - #------------------------------------------------------------------------------- - #Odroid C2 boot.ini changes: https://github.com/Fourdee/DietPi/issues/366#issue-157399983 - # I dont want to risk patching these additional options in, so lets overwrite the users boot.ini with the new one. - if (( $HW_MODEL == 12 )); then - - DEBIAN_FRONTEND='noninteractive' apt-get upgrade -y linux-headers-arm64-odroid-c2 linux-image-arm64-odroid-c2 - - whiptail --title "Kernel Upgrade" --msgbox "If the next screen shows a Yes/No prompt. Select No." 8 60 - DEBIAN_FRONTEND='noninteractive' apt-get autoremove --purge -y - - # - Because removing 3.14.29 also removes 3.14.65 (most likley same locations) we need to reinstall 3.14.65+ - DEBIAN_FRONTEND='noninteractive' apt-get install -y --reinstall linux-headers-3.14.65+ linux-image-3.14.65+ - - wget https://raw.githubusercontent.com/Fourdee/DietPi/e8e0edf7193c61d6084bf252397561081e335dc5/boot_c2.ini -O /DietPi/boot.ini - - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 119 )); then - #------------------------------------------------------------------------------- - #RPi 3 75 thermal limit: https://github.com/Fourdee/DietPi/issues/356#issuecomment-223282185 - if (( $HW_MODEL == 3 )); then - - sed -i '/temp_limit=/c\temp_limit=75' /DietPi/config.txt - - fi - #------------------------------------------------------------------------------- - #Disable internal WiFi and BT by default on new installs - if [ ! -f /DietPi/dietpi/.installed ]; then - - # - changed from RPi3 only script to all devices, remove old references - rm /etc/modprobe.d/disable_rpi3_bt.conf &> /dev/null - rm /etc/modprobe.d/disable_rpi3_wifi.conf &> /dev/null - - /DietPi/dietpi/func/dietpi-set_hardware bluetooth disable - - #enable WiFi for automation - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'Wifi_Enabled=1') )); then - /DietPi/dietpi/func/dietpi-set_hardware wifimodules enable - else - /DietPi/dietpi/func/dietpi-set_hardware wifimodules disable - fi - - fi - #------------------------------------------------------------------------------- - #Pine A64 image, disable systemd-timesyncd as we use ntp/d. New installs only. - if (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )) && [ ! -f /DietPi/dietpi/.installed ]; then - systemctl disable systemd-timesyncd - systemctl mask systemd-timesyncd - fi - #------------------------------------------------------------------------------- - #Netplug is now installed on demand in dietpi-config, when both adapters are enabled. - apt-get purge netplug -y - #------------------------------------------------------------------------------- - #DietPi-Cloudshell - New poweroff screen at specific time - if [ -f /DietPi/dietpi/.dietpi-cloudshell ]; then - sed -i '7s/.*/0/' /DietPi/dietpi/.dietpi-cloudshell #Enabled? - sed -i '8s/.*/22/' /DietPi/dietpi/.dietpi-cloudshell #Start time (hour) - sed -i '9s/.*/8/' /DietPi/dietpi/.dietpi-cloudshell #End time (hour) - fi - #------------------------------------------------------------------------------- - #Pine A64, now using fbturbo driver: https://github.com/Fourdee/DietPi/issues/380 - if (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )) && - [ -f /DietPi/dietpi/.installed ] && - (( $( cat /DietPi/dietpi/.installed | grep -ci -m1 '^XSERVERXORG=2' ) )); then - - wget http://dietpi.com/downloads/binaries/all/libump_1-1_arm64.deb -O package.deb - dpkg -i package.deb - rm package.deb - - wget http://dietpi.com/downloads/binaries/all/xf86-video-fbturbo_1-1_arm64.deb -O package.deb - dpkg -i package.deb - rm package.deb - - fi - #------------------------------------------------------------------------------- - #Always ensure dietpi_userdata directory exists - mkdir -p /mnt/dietpi_userdata &> /dev/null - - #Setup dietpi_userdata symlink for existing installs, if not on flash drive - if [ -f /DietPi/dietpi/.installed ]; then - - DIETPI_USERDATA_BASEDIRECTORY=$(cat /DietPi/dietpi.txt | grep -m1 '^dietpi_userdata_basedirectory=' | sed 's/.*=//' | tr '[:upper:]' '[:lower:]') - - if [ -n "$DIETPI_USERDATA_BASEDIRECTORY" ]; then - - #Auto - if [ "$DIETPI_USERDATA_BASEDIRECTORY" = "auto" ]; then - - #USBDRIVE - if (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'USBDRIVE=2') && $(df | grep -ci -m1 '/mnt/usb_1') )); then - /DietPi/dietpi/func/dietpi-set_userdata /mnt/dietpi_userdata /mnt/usb_1 - fi - - #CUSTOM - else - /DietPi/dietpi/func/dietpi-set_userdata /mnt/dietpi_userdata "$DIETPI_USERDATA_BASEDIRECTORY" - fi - - # - dietpi-set_userdata restarts services, so stop them. - /DietPi/dietpi/dietpi-services stop - - else - - read -p "Error: Unable to setup DietPi Userdata directories. dietpi_userdata_basedirectory= is missing or invalid value in dietpi.txt. It is highly recommended you backup any personal data on this system, then reinstall DietPi using the latest image available from http://dietpi.com/download. Press any key to continue..." - - fi - - fi - #------------------------------------------------------------------------------- - #xz-utils missing from some images, required for decompress tar.xz support. - apt-get install -y xz-utils - #------------------------------------------------------------------------------- - #I left the serial console enabled for all the v120 images (my bad). Disable if not enabled in dietpi.txt - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^serial_console_enabled=1') )); then - /DietPi/dietpi/func/dietpi-set_hardware serialconsole disable - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 120 )); then - #------------------------------------------------------------------------------- - #Update cron daily (Added daily filesystem TRIM for capable devices, eg: flash) - cp /DietPi/dietpi/conf/cron.daily_dietpi /etc/cron.daily/dietpi - chmod +x /etc/cron.daily/dietpi - #------------------------------------------------------------------------------- - #Xterm now installed by default with xserverxorg: https://github.com/Fourdee/DietPi/issues/388 - if [ -f /DietPi/dietpi/.installed ]; then - - if (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'XSERVERXORG=2') )); then - apt-get install xterm -y - fi - - # Mate: https://github.com/Fourdee/DietPi/issues/388 - if (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'DESKTOP_MATE=2') )); then - - # - Set execute to prevent "untrusted" prompt in Mate, and possibily other desktops. - chmod +x /usr/share/applications/* - - # - remove pcmanfm link - rm "$HOME"/Desktop/pcmanfm.desktop - - fi - - fi - #------------------------------------------------------------------------------- - #C2 X11 GPU/VPU patches: https://github.com/Fourdee/DietPi/issues/399 - # - boot.ini - if (( $HW_MODEL == 12 )); then - - if [ -f /DietPi/dietpi/.installed ]; then - - whiptail --title "boot.ini updated" --msgbox "/DietPi/boot.ini has been overwritten and updated with the latest C2 options. Values such as display resolution and serial console have been reset.\nPlease check the file and adjust as needed." 10 70 - - fi - - wget http://raw.githubusercontent.com/Fourdee/DietPi/f289eb0b3d1ab54980adf8e5d025b46d4c55c85d/boot_c2.ini -O /DietPi/boot.ini - - # - Xserver/LXDE - if [ -f /DietPi/dietpi/.installed ]; then - - # - Xserver - if (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'XSERVERXORG=2') )); then - - # - Update/Upgrade apt - /DietPi/dietpi/dietpi-apt-get_update 2 - AGU - - # - Reinstall all packages, including the X11 additions (xf86-video-mali-odroid libump-odroid) - apt-get install -y xcompmgr aml-libs-odroid mali450-odroid xf86-video-mali-odroid libump-odroid --no-install-recommends - cp /DietPi/dietpi/conf/xorg_c2.conf /etc/X11/xorg.conf - - fi - - # - LXDE xcompmgr - if (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'DESKTOP_LXDE=2') )); then - - cat << _EOF_ > /etc/xdg/lxsession/LXDE/autostart -xcompmgr -a -@lxpanel --profile LXDE -@pcmanfm --desktop --profile LXDE -@xscreensaver -no-splash -_EOF_ - - fi - - fi - - fi - #------------------------------------------------------------------------------- - #Weekly cronjob to update Pihole adlist - if [ -f /DietPi/dietpi/.installed ] && (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'PIHOLE=2') )); then - - cat << _EOF_ > /etc/cron.weekly/pihole_adlist_update -#!/bin/bash -{ - service dnsmasq stop - - echo -e "--------------------------------------------------------------------\n\n\$(date)\nDietPi - Running weekly adlist update" >> /var/log/pihole.log - /usr/local/bin/gravity.sh &>> /var/log/pihole.log - echo -e "--------------------------------------------------------------------\n" >> /var/log/pihole.log - - service dnsmasq start - - exit 0 -} - -_EOF_ - - chmod +x /etc/cron.weekly/pihole_adlist_update - - fi - #------------------------------------------------------------------------------- - #MineOS requires rsync: https://github.com/Fourdee/DietPi/issues/403 - if [ -f /DietPi/dietpi/.installed ] && (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'MINEOS=2') )); then - - apt-get install -y rsync - - fi - #------------------------------------------------------------------------------- - - - elif (( $VERSION_CURRENT == 121 )); then - #------------------------------------------------------------------------------- - echo -e "Nothing here" &> /dev/null - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 122 )); then - #------------------------------------------------------------------------------- - #Pine a64 resolution option in dietpi-config: https://github.com/Fourdee/DietPi/issues/398 - if (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then - - if (( ! $(cat /DietPi/uEnv.txt | grep -ci -m1 '^optargs=disp.screen0_output_mode=') )); then - - echo -e "\noptargs=disp.screen0_output_mode=1080p60" >> /DietPi/uEnv.txt - - fi - - fi - #------------------------------------------------------------------------------- - #MPD software mixer control - if [ -f /DietPi/dietpi/.installed ] && (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'HIFI=2') )); then - - sed -i '/mixer_device/c\mixer_type "software"' /etc/mpd.conf - - fi - #------------------------------------------------------------------------------- - #PiHole, prevent warning of a "file not found" when running gravity.sh: https://github.com/Fourdee/DietPi/issues/311#issuecomment-230342269 - # + log-async for rsyslog - if [ -f /DietPi/dietpi/.installed ] && (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'PIHOLE=2') )); then - - echo -e "#nothing here" > /etc/dnsmasq.d/01-pihole.conf - - if (( ! $(cat /etc/dnsmasq.conf | grep -ci -m1 'log-async') )); then - - echo -e "log-async" >> /etc/dnsmasq.conf - - fi - - fi - #------------------------------------------------------------------------------- - #RPi Monitor USB drive patch - if [ -f /DietPi/dietpi/.installed ] && - (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'RPIMONITOR=2') )) && - (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'USBDRIVE=2') )) && - (( ! $(cat /etc/rpimonitor/data.conf | grep -ci -m1 'usb_hdd.conf') )); then - - sed -i '\/include=\/etc\/rpimonitor\/template\/sdcard.conf/a include=\/etc\/rpimonitor\/template\/usb_hdd.conf' /etc/rpimonitor/data.conf - - cat << _EOF_ > /etc/rpimonitor/template/usb_hdd.conf -######################################################################## -# Extract USB HDD (sda1) information -# Page: 1 -# Information Status Statistics -# - USBHDD1 total - yes - yes -# - USBHDD1 used - yes - yes -######################################################################## -static.10.name=usbhdd_total -static.10.source=df -t ext4 -static.10.regexp=sda1\s+(\d+) -static.10.postprocess=\$1/1024 - -dynamic.14.name=usbhdd_used -dynamic.14.source=df -t ext4 -dynamic.14.regexp=sda1\s+\d+\s+(\d+) -dynamic.14.postprocess=\$1/1024 -dynamic.14.rrd=GAUGE - -web.status.1.content.9.name=USB HDD -web.status.1.content.9.icon=usb_hdd.png -web.status.1.content.9.line.1="/sda1 Used: "+KMG(data.usbhdd_used,'M')+" ("+Percent(data.udbhdd_used,data.usbhdd_total,'M')+") Free: "+KMG(data.usbhdd_total-data.usbhdd_used,'M')+ " Total: "+ KMG(data.usbhdd_total,'M') +"" -web.status.1.content.9.line.2=ProgressBar(data.usbhdd_used,data.usbhdd_total) - -web.statistics.1.content.9.name=USB HDD -web.statistics.1.content.9.graph.1=usbhdd_total -web.statistics.1.content.9.graph.2=usbhdd_used -web.statistics.1.content.9.ds_graph_options.usbhdd_total.label=USB HDD total space (MB) -web.statistics.1.content.9.ds_graph_options.usbhdd_total.color="#FF7777" -web.statistics.1.content.9.ds_graph_options.usbhdd_used.label=USB HDD used space (MB) -web.statistics.1.content.9.ds_graph_options.usbhdd_used.lines={ fill: true } -web.statistics.1.content.9.ds_graph_options.usbhdd_used.color="#7777FF" -_EOF_ - fi - #------------------------------------------------------------------------------- - #Kodi add NFS support: - if [ -f /DietPi/dietpi/.installed ] && (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'KODI=2') )); then - - apt-get install -y libnfs4 - - fi - #------------------------------------------------------------------------------- - #Odroid C2, define default pulseaudio sink: https://github.com/Fourdee/DietPi/issues/415 - if (( $HW_MODEL == 12 )) && - [ -f /DietPi/dietpi/.installed ] && - (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 'DESKTOP_MATE=2') )) && - (( ! $(cat /etc/pulse/default.pa | grep -ci -m1 '^set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo') )); then - - echo -e "set-default-sink alsa_output.platform-odroid_hdmi.37.analog-stereo" >> /etc/pulse/default.pa - - fi - #------------------------------------------------------------------------------- - #ARMbian images, install armbian repo and update packages - if (( $HW_MODEL == 30 || $HW_MODEL == 50 || $HW_MODEL == 51 )) && - [ ! -f /proc/sunxi_debug/sunxi_debug ]; then # Skip the replaced OPi PC loboris image. - - echo "deb http://apt.armbian.com jessie main" > /etc/apt/sources.list.d/armbian.list - apt-key adv --keyserver keys.gnupg.net --recv-keys 0x93D6889F9F0E78D5 - apt-get update - - # - remove ye-olde packages - apt-get purge -y armbian-firmware - - #BPi m2+ - if (( $HW_MODEL == 50 )); then - - apt-get install -y linux-u-boot-bananapim2plus-default linux-firmware-image-sun8i linux-image-sun8i - - #OPi PC - elif (( $HW_MODEL == 30 )); then - - # - remove ye-olde packages - apt-get purge -y linux-jessie-root-orangepih3 linux-u-boot-orangepih3-default - - apt-get install -y linux-u-boot-orangepipc-default linux-firmware-image-sun8i linux-image-sun8i - - #BPi pro - elif (( $HW_MODEL == 51 )); then - - apt-get install -y linux-image-sun7i linux-firmware-image-sun7i linux-u-boot-bananapipro-default - - fi - - fi - - #------------------------------------------------------------------------------- - #alias sudo='sudo ' # https://github.com/Fourdee/DietPi/issues/424#issuecomment-232016646 - if (( ! $(cat /etc/bash.bashrc | grep -ci -m1 '^alias sudo=') )); then - - echo -e "alias sudo='sudo ' # https://github.com/Fourdee/DietPi/issues/424" >> /etc/bash.bashrc - - fi - #------------------------------------------------------------------------------- - #RPi add dtparam=spi=off to config by default - if (( $HW_MODEL < 10 && - ! $(cat /DietPi/config.txt | grep -ci -m1 'dtparam=spi=') )); then - - echo -e "\ndtparam=spi=off" >> /DietPi/config.txt - - fi - - #------------------------------------------------------------------------------- - #DietPi-Config > LCD Panel addon - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^lcdpanel=') )); then - - echo -e "\nlcdpanel=none" >> /DietPi/dietpi.txt - - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 123 )); then - #------------------------------------------------------------------------------- - #Pine remove vim-* (was left on latest image) for new installations. - if [ ! -f /DietPi/dietpi/.installed ] && (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then - - apt-get purge -y vim-common vim-tiny - - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 124 )); then - #------------------------------------------------------------------------------- - #Disable daily fstrim until testing can be performed to ensure this isnt causing the recent influx of filesystem corruptions. - cp /DietPi/dietpi/conf/cron.daily_dietpi /etc/cron.daily/dietpi - chmod +x /etc/cron.daily/dietpi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 125 )); then - #------------------------------------------------------------------------------- - #libcurl3-gnutls required for C2. But lets apply to all: https://github.com/Fourdee/DietPi/issues/446 - if [ -f /DietPi/dietpi/.installed ] && - (( $( cat /DietPi/dietpi/.installed | grep -ci -m1 '^KODI=2' ) )); then - - apt-get install -y libcurl3-gnutls - - fi - #------------------------------------------------------------------------------- - #C2 remove asound.conf for hdmi: https://github.com/Fourdee/DietPi/issues/447 - if (( $HW_MODEL == 12 )) && [ -f /etc/asound.conf ] && - (( $(cat /etc/asound.conf | grep -ci -m1 'format S32_LE') )); then - - rm /etc/asound.conf - - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 126 )); then - #------------------------------------------------------------------------------- - #NanoPi Neo, left test account on image, remove it - if (( $HW_MODEL == 60 )); then - - userdel -f test - - fi - #------------------------------------------------------------------------------- - #remove dietpi-uninstall from bash alias - sed -i '/alias dietpi-uninstall/d' /etc/bash.bashrc - #------------------------------------------------------------------------------- - #Update dietpi.txt automation var name change - sed -i 's/AUTO_Install_Index=/AUTO_Install_Enable=/g' /DietPi/dietpi.txt - #------------------------------------------------------------------------------- - #patch: Convert all .installed files to the new array system - if [ -f /DietPi/dietpi/.installed ]; then - - sed -i "s/^SSHCLIENT=/aSOFTWARE_INSTALL_STATE[0]=/g" /DietPi/dietpi/.installed - sed -i "s/^SMBCLIENT=/aSOFTWARE_INSTALL_STATE[1]=/g" /DietPi/dietpi/.installed - sed -i "s/^CURLFTPFS=/aSOFTWARE_INSTALL_STATE[2]=/g" /DietPi/dietpi/.installed - sed -i "s/^MIDNIGHTCOMMANDER=/aSOFTWARE_INSTALL_STATE[3]=/g" /DietPi/dietpi/.installed - sed -i "s/^VIFM=/aSOFTWARE_INSTALL_STATE[4]=/g" /DietPi/dietpi/.installed - sed -i "s/^ALSABASE=/aSOFTWARE_INSTALL_STATE[5]=/g" /DietPi/dietpi/.installed - sed -i "s/^XSERVERXORG=/aSOFTWARE_INSTALL_STATE[6]=/g" /DietPi/dietpi/.installed - sed -i "s/^FFMPEG=/aSOFTWARE_INSTALL_STATE[7]=/g" /DietPi/dietpi/.installed - sed -i "s/^ORACLEJAVA=/aSOFTWARE_INSTALL_STATE[8]=/g" /DietPi/dietpi/.installed - sed -i "s/^NODEJS=/aSOFTWARE_INSTALL_STATE[9]=/g" /DietPi/dietpi/.installed - sed -i "s/^IFTOP=/aSOFTWARE_INSTALL_STATE[10]=/g" /DietPi/dietpi/.installed - sed -i "s/^IPTRAF=/aSOFTWARE_INSTALL_STATE[11]=/g" /DietPi/dietpi/.installed - sed -i "s/^IPERF=/aSOFTWARE_INSTALL_STATE[12]=/g" /DietPi/dietpi/.installed - sed -i "s/^MTRTINY=/aSOFTWARE_INSTALL_STATE[13]=/g" /DietPi/dietpi/.installed - sed -i "s/^NLOAD=/aSOFTWARE_INSTALL_STATE[14]=/g" /DietPi/dietpi/.installed - sed -i "s/^TCPDUMP=/aSOFTWARE_INSTALL_STATE[15]=/g" /DietPi/dietpi/.installed - sed -i "s/^BUILDESSENTIAL=/aSOFTWARE_INSTALL_STATE[16]=/g" /DietPi/dietpi/.installed - sed -i "s/^GITCLIENT=/aSOFTWARE_INSTALL_STATE[17]=/g" /DietPi/dietpi/.installed - sed -i "s/^GNUEMACS=/aSOFTWARE_INSTALL_STATE[18]=/g" /DietPi/dietpi/.installed - sed -i "s/^JED=/aSOFTWARE_INSTALL_STATE[19]=/g" /DietPi/dietpi/.installed - sed -i "s/^VIMFULL=/aSOFTWARE_INSTALL_STATE[20]=/g" /DietPi/dietpi/.installed - sed -i "s/^VIMTINY=/aSOFTWARE_INSTALL_STATE[21]=/g" /DietPi/dietpi/.installed - sed -i "s/^QUITERSS=/aSOFTWARE_INSTALL_STATE[22]=/g" /DietPi/dietpi/.installed - sed -i "s/^DESKTOP_LXDE=/aSOFTWARE_INSTALL_STATE[23]=/g" /DietPi/dietpi/.installed - sed -i "s/^DESKTOP_MATE=/aSOFTWARE_INSTALL_STATE[24]=/g" /DietPi/dietpi/.installed - sed -i "s/^DESKTOP_XFCE=/aSOFTWARE_INSTALL_STATE[25]=/g" /DietPi/dietpi/.installed - sed -i "s/^DESKTOP_GNUSTEP=/aSOFTWARE_INSTALL_STATE[26]=/g" /DietPi/dietpi/.installed - sed -i "s/^TIGHTVNCSERVER=/aSOFTWARE_INSTALL_STATE[27]=/g" /DietPi/dietpi/.installed - sed -i "s/^VNC4SERVER=/aSOFTWARE_INSTALL_STATE[28]=/g" /DietPi/dietpi/.installed - sed -i "s/^XRDP=/aSOFTWARE_INSTALL_STATE[29]=/g" /DietPi/dietpi/.installed - sed -i "s/^NOMACHINE=/aSOFTWARE_INSTALL_STATE[30]=/g" /DietPi/dietpi/.installed - sed -i "s/^KODI=/aSOFTWARE_INSTALL_STATE[31]=/g" /DietPi/dietpi/.installed - sed -i "s/^HIFI=/aSOFTWARE_INSTALL_STATE[32]=/g" /DietPi/dietpi/.installed - sed -i "s/^SUBSONIC5=/aSOFTWARE_INSTALL_STATE[33]=/g" /DietPi/dietpi/.installed - sed -i "s/^SUBSONIC6=/aSOFTWARE_INSTALL_STATE[34]=/g" /DietPi/dietpi/.installed - sed -i "s/^SQUEEZEBOXSERVER=/aSOFTWARE_INSTALL_STATE[35]=/g" /DietPi/dietpi/.installed - sed -i "s/^SQUEEZELITE=/aSOFTWARE_INSTALL_STATE[36]=/g" /DietPi/dietpi/.installed - sed -i "s/^SHAIRPORTSYNC=/aSOFTWARE_INSTALL_STATE[37]=/g" /DietPi/dietpi/.installed - sed -i "s/^BRUTEFIR=/aSOFTWARE_INSTALL_STATE[38]=/g" /DietPi/dietpi/.installed - sed -i "s/^MINIDLNA=/aSOFTWARE_INSTALL_STATE[39]=/g" /DietPi/dietpi/.installed - sed -i "s/^AMPACHE=/aSOFTWARE_INSTALL_STATE[40]=/g" /DietPi/dietpi/.installed - sed -i "s/^EMBYSERVER=/aSOFTWARE_INSTALL_STATE[41]=/g" /DietPi/dietpi/.installed - sed -i "s/^PLEXMEDIASERVER=/aSOFTWARE_INSTALL_STATE[42]=/g" /DietPi/dietpi/.installed - sed -i "s/^MUMBLESERVER=/aSOFTWARE_INSTALL_STATE[43]=/g" /DietPi/dietpi/.installed - sed -i "s/^TRANSMISSION=/aSOFTWARE_INSTALL_STATE[44]=/g" /DietPi/dietpi/.installed - sed -i "s/^DELUGE=/aSOFTWARE_INSTALL_STATE[45]=/g" /DietPi/dietpi/.installed - sed -i "s/^QBITTORRENT=/aSOFTWARE_INSTALL_STATE[46]=/g" /DietPi/dietpi/.installed - sed -i "s/^OWNCLOUD=/aSOFTWARE_INSTALL_STATE[47]=/g" /DietPi/dietpi/.installed - sed -i "s/^PYDIO=/aSOFTWARE_INSTALL_STATE[48]=/g" /DietPi/dietpi/.installed - sed -i "s/^GOGS=/aSOFTWARE_INSTALL_STATE[49]=/g" /DietPi/dietpi/.installed - sed -i "s/^SYNCTHING=/aSOFTWARE_INSTALL_STATE[50]=/g" /DietPi/dietpi/.installed - sed -i "s/^OPENTYRIAN=/aSOFTWARE_INSTALL_STATE[51]=/g" /DietPi/dietpi/.installed - sed -i "s/^CUBERITE=/aSOFTWARE_INSTALL_STATE[52]=/g" /DietPi/dietpi/.installed - sed -i "s/^MINEOS=/aSOFTWARE_INSTALL_STATE[53]=/g" /DietPi/dietpi/.installed - sed -i "s/^PHPBB=/aSOFTWARE_INSTALL_STATE[54]=/g" /DietPi/dietpi/.installed - sed -i "s/^WORDPRESS=/aSOFTWARE_INSTALL_STATE[55]=/g" /DietPi/dietpi/.installed - sed -i "s/^PHPIMAGEGALLERY=/aSOFTWARE_INSTALL_STATE[56]=/g" /DietPi/dietpi/.installed - sed -i "s/^BAIKAL=/aSOFTWARE_INSTALL_STATE[57]=/g" /DietPi/dietpi/.installed - sed -i "s/^OPENBAZAAR=/aSOFTWARE_INSTALL_STATE[58]=/g" /DietPi/dietpi/.installed - sed -i "s/^DIETPICAM=/aSOFTWARE_INSTALL_STATE[59]=/g" /DietPi/dietpi/.installed - sed -i "s/^WIFIHOTSPOT=/aSOFTWARE_INSTALL_STATE[60]=/g" /DietPi/dietpi/.installed - sed -i "s/^TORHOTSPOT=/aSOFTWARE_INSTALL_STATE[61]=/g" /DietPi/dietpi/.installed - sed -i "s/^DIETPICLOUDSHELL=/aSOFTWARE_INSTALL_STATE[62]=/g" /DietPi/dietpi/.installed - sed -i "s/^LINUXDASH=/aSOFTWARE_INSTALL_STATE[63]=/g" /DietPi/dietpi/.installed - sed -i "s/^PHPSYSINFO=/aSOFTWARE_INSTALL_STATE[64]=/g" /DietPi/dietpi/.installed - sed -i "s/^NETDATA=/aSOFTWARE_INSTALL_STATE[65]=/g" /DietPi/dietpi/.installed - sed -i "s/^RPIMONITOR=/aSOFTWARE_INSTALL_STATE[66]=/g" /DietPi/dietpi/.installed - sed -i "s/^NOIPDYNDNS=/aSOFTWARE_INSTALL_STATE[67]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEAVED=/aSOFTWARE_INSTALL_STATE[68]=/g" /DietPi/dietpi/.installed - sed -i "s/^RPIGPIO=/aSOFTWARE_INSTALL_STATE[69]=/g" /DietPi/dietpi/.installed - sed -i "s/^WIRINGPI=/aSOFTWARE_INSTALL_STATE[70]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBIOPI=/aSOFTWARE_INSTALL_STATE[71]=/g" /DietPi/dietpi/.installed - sed -i "s/^RPII2C=/aSOFTWARE_INSTALL_STATE[72]=/g" /DietPi/dietpi/.installed - sed -i "s/^FAIL2BAN=/aSOFTWARE_INSTALL_STATE[73]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_LAMP=/aSOFTWARE_INSTALL_STATE[74]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_LASP=/aSOFTWARE_INSTALL_STATE[75]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_LAAP=/aSOFTWARE_INSTALL_STATE[76]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_LEMP=/aSOFTWARE_INSTALL_STATE[77]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_LESP=/aSOFTWARE_INSTALL_STATE[78]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_LEAP=/aSOFTWARE_INSTALL_STATE[79]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_LLMP=/aSOFTWARE_INSTALL_STATE[80]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_LLSP=/aSOFTWARE_INSTALL_STATE[81]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_LLAP=/aSOFTWARE_INSTALL_STATE[82]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_APACHE=/aSOFTWARE_INSTALL_STATE[83]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_LIGHTTPD=/aSOFTWARE_INSTALL_STATE[84]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_NGINX=/aSOFTWARE_INSTALL_STATE[85]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_MYSQL=/aSOFTWARE_INSTALL_STATE[86]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_SQLITE=/aSOFTWARE_INSTALL_STATE[87]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_MARIADB=/aSOFTWARE_INSTALL_STATE[88]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_PHP=/aSOFTWARE_INSTALL_STATE[89]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_MYADMINPHP=/aSOFTWARE_INSTALL_STATE[90]=/g" /DietPi/dietpi/.installed - sed -i "s/^WEBSERVER_REDIS=/aSOFTWARE_INSTALL_STATE[91]=/g" /DietPi/dietpi/.installed - sed -i "s/^LETSENCRYPT=/aSOFTWARE_INSTALL_STATE[92]=/g" /DietPi/dietpi/.installed - sed -i "s/^PIHOLE=/aSOFTWARE_INSTALL_STATE[93]=/g" /DietPi/dietpi/.installed - sed -i "s/^FILESERVER_PROFTP=/aSOFTWARE_INSTALL_STATE[94]=/g" /DietPi/dietpi/.installed - sed -i "s/^FILESERVER_VSFTPD=/aSOFTWARE_INSTALL_STATE[95]=/g" /DietPi/dietpi/.installed - sed -i "s/^FILESERVER_SAMBA=/aSOFTWARE_INSTALL_STATE[96]=/g" /DietPi/dietpi/.installed - sed -i "s/^OPENVPNSERVER=/aSOFTWARE_INSTALL_STATE[97]=/g" /DietPi/dietpi/.installed - sed -i "s/^HAPROXY=/aSOFTWARE_INSTALL_STATE[98]=/g" /DietPi/dietpi/.installed - sed -i "s/^EMONHUB=/aSOFTWARE_INSTALL_STATE[99]=/g" /DietPi/dietpi/.installed - sed -i "s/^GRASSHOPPER=/aSOFTWARE_INSTALL_STATE[100]=/g" /DietPi/dietpi/.installed - sed -i "s/^LOGGING_LOGROTATE=/aSOFTWARE_INSTALL_STATE[101]=/g" /DietPi/dietpi/.installed - sed -i "s/^LOGGING_RSYSLOG=/aSOFTWARE_INSTALL_STATE[102]=/g" /DietPi/dietpi/.installed - sed -i "s/^LOGGING_RAMLOG=/aSOFTWARE_INSTALL_STATE[103]=/g" /DietPi/dietpi/.installed - sed -i "s/^SSHSERVER_DROPBEAR=/aSOFTWARE_INSTALL_STATE[104]=/g" /DietPi/dietpi/.installed - sed -i "s/^SSHSERVER_OPENSSH=/aSOFTWARE_INSTALL_STATE[105]=/g" /DietPi/dietpi/.installed - sed -i "s/^RASPCONTROL=/aSOFTWARE_INSTALL_STATE[106]=/g" /DietPi/dietpi/.installed - - fi - #------------------------------------------------------------------------------- - #VNC server, set screen :1 as default: https://github.com/Fourdee/DietPi/issues/454#issuecomment-237655998 - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'dietpi_vncserver_display=0') )); then - - sed -i '/^dietpi_vncserver_display=/c\dietpi_vncserver_display=1' /DietPi/dietpi.txt - - fi - #------------------------------------------------------------------------------- - #Remove bulky header packages on new images 40MB+, located in /usr/src, not required unless native kernel compile. - if [ ! -f /DietPi/dietpi/.installed ]; then - - apt-get purge -y --force-yes linux-headers* - - fi - #------------------------------------------------------------------------------- - #Remove dietpi-uninstall script (moved to dietpi-software) - rm /DietPi/dietpi/dietpi-uninstall - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 127 )); then - #------------------------------------------------------------------------------- - #Fix mysql key_buffer_size: - sed -i '/^key_buffer/c\key_buffer_size = 16M' /etc/mysql/my.cnf &> /dev/null - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 128 )); then - #------------------------------------------------------------------------------- - #Zero, set overclock back to default and disable: - if (( $(cat /DietPi/dietpi/.hw_model | tr '[:upper:]' '[:lower:]' | grep -ci -m1 'rpi 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 2/3 - Set correct sdram speed if not active. Used by dietpi-config for reading value. - if (( $HW_MODEL == 2 || $HW_MODEL == 3 )); then - - sed -i '/^#sdram_freq=/c\#sdram_freq=450' /DietPi/config.txt - - fi - #------------------------------------------------------------------------------- - #RPi new installs - if [ ! -f /DietPi/dietpi/.installed ] && (( $HW_MODEL < 10 )); then - - # - RPi-update backup left on image, remove - rm -R /boot.bak &> /dev/null - - # - Timezone left on American for v127 img, change back to London - echo -e "Europe/London" > /etc/timezone - dpkg-reconfigure -f noninteractive tzdata - - fi - - #------------------------------------------------------------------------------- - #Only start dietpi-services if system is at final install stage - if [ -f /DietPi/dietpi/.installed ]; then - - mv /etc/rc.local /etc/rc.local.bak - whiptail --title "/etc/rc.local updated" --msgbox "/etc/rc.local has been overwritten with an updated version. A backup of your previous rc.local can be found below:\n\n/etc/rc.local.bak" 11 70 - - fi - - cat << _EOF_ > /etc/rc.local -#!/bin/bash -if (( \$(cat /DietPi/dietpi/.install_stage) == 1 )); then - - /DietPi/dietpi/dietpi-services start - -fi -/DietPi/dietpi/dietpi-banner 0 -echo -e " Default Login:\n Username = root\n Password = dietpi\n" -exit 0 -_EOF_ - chmod +x /etc/rc.local - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 129 )); then - #------------------------------------------------------------------------------- - #apt-get pref ip version: https://github.com/Fourdee/DietPi/issues/472 - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^prefer_ipversion=') )); then - - echo -e "\nprefer_ipversion=auto\n" >> /DietPi/dietpi.txt - - fi - #------------------------------------------------------------------------------- - #Removal of dietpi-apt-get_update, revert back to standard apt-get update. - if [ -f /DietPi/dietpi/dietpi-apt-get_update ]; then #Doesnt exist on v129.5 AmiBerry image, so check exists. - - /DietPi/dietpi/dietpi-apt-get_update 1 #wait for existing job if running. - rm /DietPi/dietpi/dietpi-apt-get_update - - fi - #------------------------------------------------------------------------------- - #Scroll lock fix for RPi by Midwan: https://github.com/Fourdee/DietPi/issues/474#issuecomment-243215674 - if (( $HW_MODEL < 10 )); then - - cat << _EOF_ > /etc/udev/rules.d/50-leds.rules -ACTION=="add", SUBSYSTEM=="leds", ENV{DEVPATH}=="*/input*::scrolllock", ATTR{trigger}="kbd-scrollock" -_EOF_ - - fi - #------------------------------------------------------------------------------- - #Desktop xcompmgr roll out. Patch existing systems and reinstall xserver. - - # - remove LXDE xcomp line for c1/c2 on LXDE autostart conf - sed -i '/^xcompmgr/d' /etc/xdg/lxsession/LXDE/autostart &> /dev/null - - # - New function, will only reinstall if the program is currently installed. - /DietPi/dietpi/dietpi-software reinstall 6 - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 130 )); then - #------------------------------------------------------------------------------- - #C2 v130 image: apt-get update prior to this script has no effect. No apt-cache: https://github.com/Fourdee/DietPi/issues/508#issuecomment-246196842 - #NB: Regardless, run for all devices. - apt-get update - - #C2: apt-get upgrade 'uboot' package update without 'linux-image' at the same time = failed boot. - #NB: Apply to odroids as we also hold kernel packages for XU4. - if (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then - - - apt-mark unhold linux-* - DEBIAN_FRONTEND='noninteractive' apt-get dist-upgrade --force-yes -y - - fi - #------------------------------------------------------------------------------- - #Auto mount USB drive by default https://github.com/Fourdee/DietPi/issues/501 - # - All excluding VM images - if (( $HW_MODEL != 20 )); then - - cp /etc/fstab /etc/fstab.v130 - - # - Remove old FStab entries - sed -i '/\/dev\/sd[a-z]1[[:space:]]/d' /etc/fstab - sed -i '/\/mnt\/usb_[0-9][[:space:]]/d' /etc/fstab - - sed -i '/^#External Drives-/d' /etc/fstab - sed -i '/^# - Try and use only ext4 for USB drives/d' /etc/fstab - sed -i '/^# - Faster performance than NTFS, espically on RPi v1/d' /etc/fstab - sed -i '/^#NB: Please use dietpi-drive_manager/d' /etc/fstab - - # - Add new automount entries that supports all FS types - cat << _EOF_ >> /etc/fstab - -#External Drives--------------------------------------------------- -#NB: Please use dietpi-drive_manager to setup and control your external drives. -/dev/sda1 /mnt/usb_1 auto defaults,noatime,nofail,x-systemd.automount 0 0 -#/dev/sdb1 /mnt/usb_2 auto defaults,noatime,nofail,x-systemd.automount 0 0 -#/dev/sdc1 /mnt/usb_3 auto defaults,noatime,nofail,x-systemd.automount 0 0 -#/dev/sdd1 /mnt/usb_4 auto defaults,noatime,nofail,x-systemd.automount 0 0 -#/dev/sde1 /mnt/usb_5 auto defaults,noatime,nofail,x-systemd.automount 0 0 -_EOF_ - - systemctl daemon-reload - - fi - #------------------------------------------------------------------------------- - #add HFS+ FS support for all DietPi systems by default: https://github.com/Fourdee/DietPi/issues/271#issuecomment-245651818 - apt-get install -y hfsplus #hfsprogs is for format capabilities - #------------------------------------------------------------------------------- - #NFS: https://github.com/Fourdee/DietPi/issues/246 - mkdir -p /mnt/nfs_client - echo -e "NFS client can be installed and setup by DietPi-Config.\nSimply run: dietpi-config and select the Networking Options: NAS/Misc menu" > /mnt/nfs_client/readme.txt - - # - fstab template entry - if (( ! $(cat /etc/fstab | grep -ci -m1 '/mnt/nfs_client') )); then - - echo -e "\n#NFS Client Mount--------------------------------------------------\n#/mnt/nfs_client . Please use dietpi-config and the Networking Options: NAS menu to setup this mount" >> /etc/fstab - - fi - - # - dietpi.txt entries - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^nfsclient_ipaddress=') )); then - - echo -e "\nnfsclient_ipaddress=" >> /DietPi/dietpi.txt - - fi - #------------------------------------------------------------------------------- - #DietPi-Drive_Manager - # - remove old program - rm /DietPi/dietpi/dietpi-external_drive_setup - # - setup alias - if (( ! $(cat /etc/bash.bashrc | grep -ci -m1 'dietpi-drive_manager=') )); then - - sed -i "/#DietPi Additions/a alias dietpi-drive_manager='/DietPi/dietpi/dietpi-drive_manager'" /etc/bash.bashrc - - fi - #------------------------------------------------------------------------------- - #New rc.local : boottime - if [ -f /DietPi/dietpi/.installed ]; then - - mv /etc/rc.local /etc/rc.local.bak - whiptail --title "/etc/rc.local updated" --msgbox "/etc/rc.local has been overwritten with an updated version. A backup of your previous rc.local can be found below:\n\n/etc/rc.local.bak" 11 70 - - fi - - cat << _EOF_ > /etc/rc.local -#!/bin/bash -echo -e "\$(cat /proc/uptime | awk '{print \$1}') Seconds" > /var/log/boottime -if (( \$(cat /DietPi/dietpi/.install_stage) == 1 )); then - - /DietPi/dietpi/dietpi-services start - -fi -/DietPi/dietpi/dietpi-banner 0 -echo -e " Default Login:\n Username = root\n Password = dietpi\n" -exit 0 -_EOF_ - chmod +x /etc/rc.local - #------------------------------------------------------------------------------- - #AmiBerry v2 binary update - /DietPi/dietpi/dietpi-software reinstall 108 - #------------------------------------------------------------------------------- - #ifmetric: https://github.com/Fourdee/DietPi/issues/515 - apt-get purge ifmetric -y - sed -i '/^metric /d' /etc/network/interfaces - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 131 )); then - #------------------------------------------------------------------------------- - #Install p7zip by default on all DietPi systems - apt-get install -y p7zip-full - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 132 )); then - #------------------------------------------------------------------------------- - #Interactive CPU gov by default: - CPU_GOVERNOR_CURRENT=$(cat /DietPi/dietpi.txt | grep -m1 '^cpu_governor=' | sed 's/.*=//') - if [ "$CPU_GOVERNOR_CURRENT" = "ondemand" ]; then - - sed -i "/^cpu_governor=/c\cpu_governor=interactive" /DietPi/dietpi.txt - /DietPi/dietpi/dietpi-cpu_set - - fi - #------------------------------------------------------------------------------- - #dietpi.txt entries : https://github.com/Fourdee/DietPi/issues/533 - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^AUTO_Global_Password=') )); then - - echo -e "\nAUTO_Global_Password=dietpi\n" >> /DietPi/dietpi.txt - - fi - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^Apt_Raspbian_Mirror=') )); then - - echo -e "\nApt_Raspbian_Mirror=http://mirror.ox.ac.uk/sites/archive.raspbian.org/archive/raspbian\n" >> /DietPi/dietpi.txt - - fi - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^Apt_Debian_Mirror=') )); then - - echo -e "\nApt_Debian_Mirror=http://ftp.debian.org/debian\n" >> /DietPi/dietpi.txt - - fi - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^AUTO_Dedicated_Usb_Drive_Format_Filesystem=') )); then - - echo -e "\nAUTO_Dedicated_Usb_Drive_Format_Filesystem=0\n" >> /DietPi/dietpi.txt - - fi - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^dietpi_nextcloud_username=') )); then - - echo -e "\ndietpi_nextcloud_username=admin\n" >> /DietPi/dietpi.txt - - fi - #------------------------------------------------------------------------------- - #FriendlyARM images, remove custom services: - if (( $HW_MODEL == 61 || $HW_MODEL == 62 )); then - - rm /lib/systemd/system/lcd4linux.service - rm /lib/systemd/system/hwservice.service - rm /lib/systemd/system/hwservice_monitor.service - systemctl daemon-reload - - fi - #------------------------------------------------------------------------------- - #ethtool: - apt-get install -y ethtool - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 133 )); then - #------------------------------------------------------------------------------- - #NanoPi T2 bluetooth + patch by AWL29: http://dietpi.com/phpbb/viewtopic.php?f=12&t=622&start=40#p3280 - if (( $HW_MODEL == 61 )); then - - BT_USER_ENABLED=0 - if (( $(lsmod | grep -ci -m1 '^bluetooth') )); then - - BT_USER_ENABLED=1 - - fi - - wget http://dietpi.com/downloads/binaries/all/ap6212_bt_patch.7z -O package.7z - 7z x -y package.7z -o/ - - chmod +x /bin/brcm_patchram_plus - chmod +x /bin/bumpRTSCTS - chmod +x /etc/init.d/brcm_patchram_plus - chmod +x /lib/systemd/system/brcm_patchram_plus.service - - # - BT modules must be enabled before installation. Else, apt-get install will fail on bluetooth package init. - /DietPi/dietpi/func/dietpi-set_hardware bluetooth enable # will fail on bluetooth service start. Expected, as not installed yet. - /DietPi/dietpi/func/dietpi-notify 2 "If the above returns an error, it can safely be ignored as BT isnt installed yet." - - apt-get install bluetooth -y - - # - Disable BT modules, if the user had it disabled before hand: - if (( ! $BT_USER_ENABLED )); then - - /DietPi/dietpi/func/dietpi-notify 2 "BT was in a disabled state previously, setting back to disabled." - /DietPi/dietpi/func/dietpi-set_hardware bluetooth disable - - fi - - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 134 )); then - #------------------------------------------------------------------------------- - #DietPi services updated to SystemD: - - # - Stop and remove old service - #/DietPi/dietpi/dietpi-services stop # not required, ran from dietpi-update script before hand - systemctl stop dietpi-service - - systemctl disable dietpi-service - update-rc.d dietpi-service remove - rm /etc/init.d/dietpi-service - - # - Install new services - cat << _EOF_ > /etc/systemd/system/dietpi-ramdisk.service -[Unit] -Description=DietPi-RAMdisk - -[Service] -Type=forking -RemainAfterExit=yes -ExecStart=/bin/bash -c '/boot/dietpi/dietpi-ramdisk 0' -ExecStop=/bin/bash -c '/DietPi/dietpi/dietpi-ramdisk 1' - -[Install] -WantedBy=local-fs.target -_EOF_ - systemctl enable dietpi-ramdisk.service - systemctl daemon-reload - systemctl start dietpi-ramdisk.service - - # DietPi-Ramlog -cat << _EOF_ > /etc/systemd/system/dietpi-ramlog.service -[Unit] -Description=DietPi-RAMlog -Before=rsyslog.service syslog.service - -[Service] -Type=forking -RemainAfterExit=yes -ExecStart=/bin/bash -c '/boot/dietpi/dietpi-ramlog 0' -ExecStop=/bin/bash -c '/DietPi/dietpi/dietpi-ramlog 1' - -[Install] -WantedBy=local-fs.target -_EOF_ - systemctl enable dietpi-ramlog.service - systemctl daemon-reload - systemctl start dietpi-ramlog.service - - # Boot - cat << _EOF_ > /etc/systemd/system/dietpi-boot.service -[Unit] -Description=DietPi-Boot -After=network-online.target network.target networking.service dietpi-ramdisk.service dietpi-ramlog.service -Requires=dietpi-ramdisk.service - -[Service] -Type=oneshot -RemainAfterExit=yes -ExecStart=/bin/bash -c '/DietPi/dietpi/boot' -StandardOutput=tty - -[Install] -WantedBy=multi-user.target -_EOF_ - systemctl enable dietpi-boot.service - - cat << _EOF_ > /etc/systemd/system/rc-local.service -[Unit] -Description=/etc/rc.local Compatibility -After=dietpi-boot.service dietpi-ramdisk.service dietpi-ramlog.service -Requires=dietpi-boot.service dietpi-ramdisk.service - -[Service] -Type=idle -ExecStart=/etc/rc.local -StandardOutput=tty -RemainAfterExit=yes - -[Install] -WantedBy=multi-user.target -_EOF_ - systemctl enable rc-local.service - - if [ -f /DietPi/dietpi/.installed ]; then - - mv /etc/rc.local /etc/rc.local.bak - whiptail --title "/etc/rc.local updated" --msgbox "/etc/rc.local has been overwritten with an updated version. A backup of your previous rc.local can be found below:\n\n/etc/rc.local.bak" 11 70 - - fi - - cat << _EOF_ > /etc/rc.local -#!/bin/bash -#Precaution: Wait for DietPi Ramdisk to finish -while [ ! -f /DietPi/.ramdisk ] -do - - /DietPi/dietpi/func/dietpi-notify 2 "Waiting for DietPi-RAMDISK to finish mounting DietPi to RAM..." - sleep 1 - -done - -echo -e "\$(cat /proc/uptime | awk '{print \$1}') Seconds" > /var/log/boottime -if (( \$(cat /DietPi/dietpi/.install_stage) == 1 )); then - - /DietPi/dietpi/dietpi-services start - -fi -/DietPi/dietpi/dietpi-banner 0 -echo -e " Default Login:\n Username = root\n Password = dietpi\n" -exit 0 -_EOF_ - chmod +x /etc/rc.local - systemctl daemon-reload - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 135 )); then - #------------------------------------------------------------------------------- - #Soundcard fixes & changes, requires a reapply to overwrite and patch existing settings. - # JustBoom, pattern match as end of string may contain '-noeq' due to: https://github.com/Fourdee/DietPi/issues/585 - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^soundcard=justboom-dac') )); then - - /DietPi/dietpi/func/dietpi-set_hardware soundcard justboom-dac-eq - - elif (( $(cat /DietPi/dietpi.txt | grep -ci -m1 '^soundcard=justboom-digi') )); then - - /DietPi/dietpi/func/dietpi-set_hardware soundcard justboom-digi-eq - - # - Reapply active card - else - - /DietPi/dietpi/func/dietpi-set_hardware soundcard $(cat /DietPi/dietpi.txt | grep -m1 'soundcard=' | sed 's/.*=//') - - fi - - #Reinstall ALSA to enable bash alias for dietpi-justboom on all soundcards. - #Reinstall HiFi to update YMPD clients to latest version. - /DietPi/dietpi/dietpi-software reinstall 5 32 - - #------------------------------------------------------------------------------- - #Force use of existing installed configs if available, else install new. Also disables end user prompt from dpkg - cat << _EOF_ > /etc/apt/apt.conf.d/local -Dpkg::Options { - "--force-confdef"; - "--force-confold"; -} -_EOF_ - - #------------------------------------------------------------------------------- - #NoIP2 systemd service patch: https://github.com/Fourdee/DietPi/issues/589 - if [ -f /etc/init.d/noip2 ]; then - - update-rc.d noip2 remove - rm /etc/init.d/noip2 - cat << _EOF_ > /etc/systemd/system/noip2.service -[Unit] -Description=noip2 -After=network.target network-online.target rsyslog.service - -[Service] -Type=forking -RemainAfterExit=yes - -ExecStart=/usr/local/bin/noip2 -ExecStop=/usr/bin/killall -w noip2 - -[Install] -WantedBy=multi-user.target -_EOF_ - systemctl daemon-reload - - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 136 )); then - #------------------------------------------------------------------------------- - #Reinstalls - # - MySQL: Apply optimizations for reduced memory usage: https://github.com/Fourdee/DietPi/issues/605 - # - DietPi-Cloudshell: Reinstall to apply new service for tty1 use - # - vnc servers: Reinstall to allow use of new shared desktop mode - /DietPi/dietpi/dietpi-software reinstall 86 62 27 28 - - # - requires new save file - if [ -f /DietPi/dietpi/.dietpi-cloudshell ]; then - - whiptail --title "DietPi-Cloudshell Upgrade" --msgbox "DietPi-Cloudshell has been updated to the latest version. This version has significant changes to the settings/savefile system, which requires your current settings to be reset.\n\nYour previous settings have been cleared. Please run dietpi-cloudshell to reconfigure as needed." 12 70 - rm /DietPi/dietpi/.dietpi-cloudshell - - fi - - #Add roon to dietpi-process_tool: http://dietpi.com/phpbb/viewtopic.php?f=9&t=826#p3711 - - #------------------------------------------------------------------------------- - #Shared VNC server options: https://github.com/Fourdee/DietPi/issues/607 - if (( $(cat /DietPi/dietpi.txt | grep -ci -m1 'dietpi_vncserver_shared_desktop=') )); then - - echo -e "\ndietpi_vncserver_shared_desktop=0" >> /DietPi/dietpi.txt - - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 137 )); then - #------------------------------------------------------------------------------- - #Updated desktop icons: https://github.com/Fourdee/DietPi/issues/616 - - # - Desktop confs are now located online, so remove from DietPi-Ramdisk to save some memory. - rm -R /DietPi/dietpi/conf/desktop - - if [ -f /DietPi/dietpi/.installed ]; then - - #23 24 25 26 - if (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 '^aSOFTWARE_INSTALL_STATE\[23\]=2') || - $(cat /DietPi/dietpi/.installed | grep -ci -m1 '^aSOFTWARE_INSTALL_STATE\[24\]=2') || - $(cat /DietPi/dietpi/.installed | grep -ci -m1 '^aSOFTWARE_INSTALL_STATE\[25\]=2') || - $(cat /DietPi/dietpi/.installed | grep -ci -m1 '^aSOFTWARE_INSTALL_STATE\[26\]=2') )); then - - # - Remove old symlinks - rm /usr/share/applications/dietpi-* - rm "$HOME"/Desktop/dietpi-* - - # - reinstall new - mkdir -p /usr/share/applications - wget http://dietpi.com/downloads/conf/desktop/dietpi-software.desktop -O /usr/share/applications/dietpi-software.desktop - wget http://dietpi.com/downloads/conf/desktop/dietpi-update.desktop -O /usr/share/applications/dietpi-update.desktop - wget http://dietpi.com/downloads/conf/desktop/dietpi-config.desktop -O /usr/share/applications/dietpi-config.desktop - wget http://dietpi.com/downloads/conf/desktop/dietpi-uninstall.desktop -O /usr/share/applications/dietpi-uninstall.desktop - wget http://dietpi.com/downloads/conf/desktop/dietpi-backup.desktop -O /usr/share/applications/dietpi-backup.desktop - wget http://dietpi.com/downloads/conf/desktop/dietpi-sync.desktop -O /usr/share/applications/dietpi-sync.desktop - wget http://dietpi.com/downloads/conf/desktop/dietpi-bugreport.desktop -O /usr/share/applications/dietpi-bugreport.desktop - wget http://dietpi.com/downloads/conf/desktop/dietpi-process_tool.desktop -O /usr/share/applications/dietpi-process_tool.desktop - wget http://dietpi.com/downloads/conf/desktop/dietpi-cleaner.desktop -O /usr/share/applications/dietpi-cleaner.desktop - wget http://dietpi.com/downloads/conf/desktop/dietpi-cron.desktop -O /usr/share/applications/dietpi-cron.desktop - wget http://dietpi.com/downloads/conf/desktop/dietpi-launcher.desktop -O /usr/share/applications/dietpi-launcher.desktop - wget http://dietpi.com/downloads/conf/desktop/dietpi-justboom.desktop -O /usr/share/applications/dietpi-justboom.desktop - - #DietPi Desktop symlinks - ln -sf /usr/share/applications/dietpi-software.desktop "$HOME"/Desktop/dietpi-software.desktop - ln -sf /usr/share/applications/dietpi-config.desktop "$HOME"/Desktop/dietpi-config.desktop - ln -sf /usr/share/applications/dietpi-launcher.desktop "$HOME"/Desktop/dietpi-launcher.desktop - - #Download icons - mkdir -p /etc/dietpi/desktop_icons - wget http://dietpi.com/downloads/conf/desktop/dietpi-icon.png -O /etc/dietpi/desktop_icons/dietpi-icon.png - wget http://dietpi.com/downloads/conf/desktop/grey_16x16.png -O /etc/dietpi/desktop_icons/grey_16x16.png - wget http://dietpi.com/downloads/conf/desktop/kodi-icon.png -O /etc/dietpi/desktop_icons/kodi-icon.png - wget http://dietpi.com/downloads/conf/desktop/justboom.png -O /etc/dietpi/desktop_icons/justboom.png - - #Kodi - if (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 '^aSOFTWARE_INSTALL_STATE\[31\]=2') )); then - - rm /usr/share/applications/kodi.desktop - wget http://dietpi.com/downloads/conf/desktop/kodi.desktop -O /usr/share/applications/kodi.desktop - ln -sf /usr/share/applications/kodi.desktop "$HOME"/Desktop/kodi.desktop - - fi - - # - Set execute to prevent "untrusted" prompt in Mate, and possibily other desktops. - chmod +x /usr/share/applications/* - - fi - - fi - #------------------------------------------------------------------------------- - #Reinstalls: - # C2: FBTURBO provides much better desktop performance over Mali DDX: http://forum.odroid.com/viewtopic.php?f=138&t=19948&p=169808#p169808 - # Squeezelite 1.8 update to enable -C flag: https://github.com/Fourdee/DietPi/issues/620 - /DietPi/dietpi/dietpi-software reinstall 6 36 - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 138 )); then - #------------------------------------------------------------------------------- - #nanoPi M3 image cleanup (some things we missed), but lets apply to all devices on fresh install: - if [ ! -f /DietPi/dietpi/.installed ]; then - - userdel -f fa - apt-get purge -y modemmanager hostapd libgoa-* libfm-* - - # - May as well remove unneeded RPi packages while we are here: https://github.com/Fourdee/DietPi/issues/598 - apt-get purge -y libboost-iostreams1.49.0 libboost-iostreams1.50.0 libboost-iostreams1.53.0 libboost-iostreams1.54.0 gcc-4.6-base gcc-4.7-base gcc-4.8-base libsigc++-1.2-5c2 - - apt-get autoremove -y --purge - - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 139 )); then - #------------------------------------------------------------------------------- - echo 0 - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 140 )); then - #------------------------------------------------------------------------------- - #C2 libc6 u7 breaking most installations, replace with u6: https://github.com/Fourdee/DietPi/issues/653 - # https://github.com/Fourdee/DietPi/issues/663#issuecomment-269867184 - if (( $HW_MODEL == 12 )); then - - wget http://ftp.us.debian.org/debian/pool/main/g/glibc/libc6_2.19-18+deb8u6_arm64.deb -O package.deb - dpkg -i package.deb - rm package.deb - - # - Just incase u6 is outdated by the time this patch is run, lets also update and upgrade apt: - apt-get update - AGU - - fi - #------------------------------------------------------------------------------- - #Stretch, disable automatic updates and management of apt cache. Prevents unexpected lock on Apt cache and therefore failed apt installations. - # Very similar to a system DietPi had a while back that background threaded weekly apt-get updates, was removed as repo files change and without apt-get update prior to install, chance of package no longer existing (eg: package-1.2.3 changes to package-1.2.4), unless the apt list was also updated. - if (( $DISTRO == 4 )); then - - systemctl mask apt-daily.service - - fi - #------------------------------------------------------------------------------- - #Apt-transport install by default on all systems: - apt-get install -y apt-transport-https - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 141 )); then - #------------------------------------------------------------------------------- - #DietPi-Backup settings file has been recoded, must be generated again - if [ -f /DietPi/dietpi/.dietpi-backup_settings ]; then - - mv /DietPi/dietpi/.dietpi-backup_settings /DietPi/dietpi/.dietpi-backup_settings_v141 - - # - Inform user - whiptail --title "DietPi-Backup Changes:" --msgbox "Significant changes have been made to DietPi-Backup in v142. Due to this, existing backups, made with DietPi v141 or lower are no longer compatible.\nPlease see the url below for more information, and a method to restore a previous backup from DietPi v141 and lower:\n\nhttps://github.com/Fourdee/DietPi/issues/685#issuecomment-270145794" 15 75 - - fi - #------------------------------------------------------------------------------- - #Disable auto mounting of usb_1, if not in use: https://github.com/Fourdee/DietPi/issues/684 - if (( ! $(df -P | grep -ci -m1 '/mnt/usb_1') )); then - - sed -i '/\/mnt\/usb_1/c\#\/dev\/sda1 \/mnt\/usb_1 auto defaults,noatime,nofail,x-systemd.automount 0 0' /etc/fstab - systemctl daemon-reload - - fi - #------------------------------------------------------------------------------- - #RPi 3 Bluetooth packages missing: https://github.com/Fourdee/DietPi/issues/693 - if (( $HW_MODEL < 10 )); then - - apt-get install -y pi-bluetooth --reinstall - - # - Check if previously disabled, and reapply - if [ -f /etc/modprobe.d/disable_bt.conf ]; then - - /DietPi/dietpi/func/dietpi-set_hardware bluetooth disable - - fi - - fi - #------------------------------------------------------------------------------- - #Stretch RPi WiFi fix + firmware: https://github.com/Fourdee/DietPi/issues/475#issuecomment-270696515 - if (( $DISTRO == 4 && $HW_MODEL < 10 )); then - - AGDU - wget https://raw.githubusercontent.com/RPi-Distro/firmware-nonfree/master/brcm80211/brcm/brcmfmac43430-sdio.txt -O /lib/firmware/brcm/brcmfmac43430-sdio.txt - - fi - #------------------------------------------------------------------------------- - #Sparky SBC fixes: - # Additional blacklist to disable touch screen, and dmesg errors associated with it: https://github.com/Fourdee/DietPi/issues/699#issuecomment-271362441 - if (( $HW_MODEL == 70 )); then - - cat << _EOF_ > /etc/modprobe.d/disable_sparkysbc_touchscreen.conf -blacklist ctp_gsl3680 -_EOF_ - - fi - #------------------------------------------------------------------------------- - #Alsamixer fix, reapply current soundcard with updated asound.conf: https://github.com/Fourdee/DietPi/issues/705 - if [ -f /DietPi/dietpi/.installed ]; then - - /DietPi/dietpi/func/dietpi-set_hardware soundcard $(cat /DietPi/dietpi.txt | grep -m1 'soundcard=' | sed 's/.*=//') - - fi - #------------------------------------------------------------------------------- - #RPi, install common rpi specific binaries by default (eg: raspistill) - if (( $HW_MODEL < 10 )); then - - apt-get install -y --reinstall --force-yes libraspberrypi-bin - - fi - #------------------------------------------------------------------------------- - #Reinstalls: - # DietPi Cam: https://github.com/Fourdee/DietPi/issues/706 - # NetData 1.4 - # Move MySQL + MariaDB store to DietPi User data location: - /DietPi/dietpi/dietpi-software reinstall 59 65 86 88 - #------------------------------------------------------------------------------- - #switch from NTPD to systemd-timesyncd for drift mode (4): https://github.com/Fourdee/DietPi/issues/709 - if (( $(cat /DietPi/dietpi.txt | grep -m1 '^ntpd_update_mode=' | sed 's/.*=//') == 4 )); then - - timedatectl set-ntp true - - fi - #------------------------------------------------------------------------------- - #Inform our Allo Piano 2 users of updated sound card: - if [ -f /DietPi/dietpi/.installed ] && - (( $(cat /DietPi/dietpi.txt | grep 'soundcard=' | grep -ci -m1 'allo-piano') )); then - - whiptail --title "Allo Piano 2.1" --msgbox "The driver for the Allo Piano 2.1 DAC has been updated. \n\nIf you are using a Allo Piano DAC 2.1, please reselect this sound card from dietpi-config, to apply the updated driver." 12 70 - - fi - #------------------------------------------------------------------------------- - #Remove Meveric's CPU governor scripts, all Odroid images - if (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then - - systemctl disable cpu_governor &> /dev/null - rm /etc/init.d/cpu_governor &> /dev/null - rm /etc/systemd/system/cpu_governor.service &> /dev/null - systemctl daemon-reload - - fi - #------------------------------------------------------------------------------- - #Reduce DHCP request retry count and timeouts: https://github.com/Fourdee/DietPi/issues/711 - sed -i '/^#timeout /d' /etc/dhcp/dhclient.conf - sed -i '/^#retry /d' /etc/dhcp/dhclient.conf - sed -i '/^timeout /d' /etc/dhcp/dhclient.conf - sed -i '/^retry /d' /etc/dhcp/dhclient.conf - cat << _EOF_ >> /etc/dhcp/dhclient.conf -timeout 10; -retry 4; -_EOF_ - - #------------------------------------------------------------------------------- - #systemctl disable armhwinfo: Turns out this does more than just obtain info, also sets device specific "workarounds/fixes": https://github.com/igorpecovnik/lib/blob/73a4dd60a2b6ab9bd8008fb0ef06344e378a557f/scripts/armhwinfo - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 142 )); then - #------------------------------------------------------------------------------- - #OPi Zero (apply to all) | ARMbian, disable 1st run script: - systemctl disable firstrun &> /dev/null - rm /etc/init.d/firstrun &> /dev/null - #------------------------------------------------------------------------------- - #Pine A64, fb cursor: https://github.com/Fourdee/DietPi/issues/596#issuecomment-274328262 - if (( $HW_MODEL >= 40 && $HW_MODEL <= 42 )); then - - cat << _EOF_ >> "$HOME"/.bashrc -infocmp > terminfo.txt -sed -i -e 's/?0c/?112c/g' -e 's/?8c/?48;0;64c/g' terminfo.txt -tic terminfo.txt -tput cnorm -_EOF_ - - fi - #------------------------------------------------------------------------------- - #Reinstalls: - # Netdata 1.5.0: https://github.com/Fourdee/DietPi/issues/728 - /DietPi/dietpi/dietpi-software reinstall 65 - # - #------------------------------------------------------------------------------- - #DietPi-Ramdisk: - # - add debugging: https://github.com/Fourdee/DietPi/issues/719 - # - after local-fs.target - # DietPi-Ramdisk - cat << _EOF_ > /etc/systemd/system/dietpi-ramdisk.service -[Unit] -Description=DietPi-RAMdisk -After=local-fs.target - -[Service] -Type=forking -RemainAfterExit=yes -ExecStartPre=/bin/mkdir -p /etc/dietpi/logs -ExecStart=/bin/bash -c '/boot/dietpi/dietpi-ramdisk 0 &>> /etc/dietpi/logs/dietpi-ramdisk.log' -ExecStop=/bin/bash -c '/DietPi/dietpi/dietpi-ramdisk 1 &>> /etc/dietpi/logs/dietpi-ramdisk.log' - -[Install] -WantedBy=local-fs.target -_EOF_ - - # DietPi-Ramlog - cat << _EOF_ > /etc/systemd/system/dietpi-ramlog.service -[Unit] -Description=DietPi-RAMlog -Before=rsyslog.service syslog.service -After=local-fs.target - -[Service] -Type=forking -RemainAfterExit=yes -ExecStart=/bin/bash -c '/boot/dietpi/dietpi-ramlog 0' -ExecStop=/bin/bash -c '/DietPi/dietpi/dietpi-ramlog 1' - -[Install] -WantedBy=local-fs.target -_EOF_ - systemctl daemon-reload - - # - Restart RAMdisk now - systemctl restart dietpi-ramdisk.service - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 143 )); then - #------------------------------------------------------------------------------- - #Samba clients, remove _netdev: https://github.com/Fourdee/DietPi/issues/744 - if (( ! $(cat /etc/fstab | grep -ci -m1 '^#/mnt/samba') )); then - - /DietPi/dietpi/func/dietpi-set_smbclient 1 - - fi - #------------------------------------------------------------------------------- - #Sparky SBC kernel upgrade from Allo, improve USB DAC support: - if (( $HW_MODEL == 70 )); then - - /DietPi/dietpi/func/dietpi-set_hardware kernel sparky_sbc - - fi - #------------------------------------------------------------------------------- - #Reinstalls - # RoonBridge 1.3 update: https://github.com/Fourdee/DietPi/issues/749 - # AmiBerry 2.1: https://github.com/Fourdee/DietPi/issues/756 - /DietPi/dietpi/dietpi-software reinstall 108 121 - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 144 )); then - #------------------------------------------------------------------------------- - #Use our new EU mirror for mdrjr repo (Meveric's packages): - if (( $HW_MODEL >= 10 && $HW_MODEL < 20 )); then - - sed -i 's@http://oph.mdrjr.net/meveric@http://fuzon.co.uk/meveric@' /etc/apt/sources.list.d/* - - fi - #------------------------------------------------------------------------------- - #New installs, remove /mnt/usb_x entries in /etc/fstab and /mnt - if [ ! -f /DietPi/dietpi/.installed ]; then - - rm -R /mnt/usb_1 - sed -i "\@[[:space:]]/mnt/usb_[1-9][[:space:]]@d" /etc/fstab - - fi - #------------------------------------------------------------------------------- - #Disable ARMbian's log2ram: https://github.com/Fourdee/DietPi/issues/781 - systemctl disable log2ram.service - rm /usr/local/sbin/log2ram &> /dev/null - rm /etc/systemd/system/log2ram.service &> /dev/null - #------------------------------------------------------------------------------- - #Cleanup ARMbian's resize service (not automatically removed by ARMbian scripts...) - systemctl disable resize2fs &> /dev/null - rm /etc/systemd/system/resize2fs.service &> /dev/null - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 145 )); then - #------------------------------------------------------------------------------- - #/usr/bin/sudo: https://github.com/Fourdee/DietPi/issues/794 - chmod 4755 /usr/bin/sudo - #------------------------------------------------------------------------------- - #NTPD: Update DietPi Cron jobs: https://github.com/Fourdee/DietPi/issues/786 - cp /DietPi/dietpi/conf/cron.daily_dietpi /etc/cron.daily/dietpi - chmod +x /etc/cron.daily/dietpi - cp /DietPi/dietpi/conf/cron.hourly_dietpi /etc/cron.hourly/dietpi - chmod +x /etc/cron.hourly/dietpi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 146 )); then - #------------------------------------------------------------------------------- - #Shairport sync 3.0.2: https://github.com/Fourdee/DietPi/issues/819 - #MPD 19.21: https://github.com/Fourdee/DietPi/issues/821 - #NetData 1.6: https://github.com/Fourdee/DietPi/issues/832 - #Chromium: https://github.com/Fourdee/DietPi/issues/835 - /DietPi/dietpi/dietpi-software reinstall 37 65 113 128 - #------------------------------------------------------------------------------- - #New installs: pump default locale into sys env: https://github.com/Fourdee/DietPi/issues/825 - if [ ! -f /DietPi/dietpi/.installed ]; then - - cat << _EOF_ > /etc/environment -LC_ALL=en_GB.UTF-8 -LANG=en_GB.UTF-8 -_EOF_ - - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 147 )); then - #------------------------------------------------------------------------------- - #Apply WiFi country code to cfg80211 mod params, aswell as 'iw reg set' (currently): https://github.com/Fourdee/DietPi/issues/838 - echo -e "options cfg80211 ieee80211_regdom=$(cat /DietPi/dietpi.txt | grep -m1 '^wifi_country_code=' | sed 's/.*=//')" > /etc/modprobe.d/cfg80211.conf - #------------------------------------------------------------------------------- - #Delay boot until network is established: 0=disabled | 1=10 second wait max (default) | 2=infinite wait: https://github.com/Fourdee/DietPi/issues/842 - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^boot_wait_for_network=') )); then - - echo -e "\nboot_wait_for_network=1\n" >> /DietPi/dietpi.txt - - fi - #------------------------------------------------------------------------------- - #update cron jobs, removal of old df code for TRIM - cp /DietPi/dietpi/conf/cron.daily_dietpi /etc/cron.daily/dietpi - chmod +x /etc/cron.daily/dietpi - cp /DietPi/dietpi/conf/cron.hourly_dietpi /etc/cron.hourly/dietpi - chmod +x /etc/cron.hourly/dietpi - #------------------------------------------------------------------------------- - #ARMbian log2ram cron job cleanup: http://dietpi.com/phpbb/viewtopic.php?f=11&t=1580&p=6478#p6478 - rm /etc/cron.hourly/log2ram &> /dev/null - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 148 )); then - #------------------------------------------------------------------------------- - #Sudo UID bit (was missing from finalize script): https://github.com/Fourdee/DietPi/issues/794 - chmod 4755 /usr/bin/sudo - #------------------------------------------------------------------------------- - #Create DietPi user: https://github.com/Fourdee/DietPi/issues/796 - /DietPi/dietpi/func/dietpi-set_software useradd dietpi - #------------------------------------------------------------------------------- - #DietPi-Config + display rotation options: https://github.com/Fourdee/DietPi/issues/859 - if (( $HW_MODEL < 10 )); then - - if (( ! $(cat /DietPi/config.txt | grep -ci -m1 'display_rotate=') )); then - - echo -e "\ndisplay_rotate=0" >> /DietPi/config.txt - - fi - - if (( ! $(cat /DietPi/config.txt | grep -ci -m1 'lcd_rotate=') )); then - - echo -e "\nlcd_rotate=0" >> /DietPi/config.txt - - fi - - fi - #------------------------------------------------------------------------------- - #+ARMbian increase console verbose - sed -i '/verbosity=/c\verbosity=7' /boot/armbianEnv.txt &> /dev/null - #------------------------------------------------------------------------------- - #AmiBerry name change: https://github.com/Fourdee/DietPi/issues/850 - if [ -f /DietPi/dietpi/.installed ] && - (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 '^aSOFTWARE_INSTALL_STATE\[108\]=2') )); then - - killall -w uae4arm-rpi - - mv /etc/uae4arm-rpi /etc/amiberry - mv /mnt/dietpi_userdata/uae4arm-rpi /mnt/dietpi_userdata/amiberry - systemctl disable uae4arm-rpi.service - rm /etc/systemd/system/uae4arm-rpi.service - systemctl daemon-reload - - userdel -f amiberry - - fi - #------------------------------------------------------------------------------- - #Reinstalls (RPI) - # FFmpeg RPi (OpenMAX HW enc): https://github.com/Fourdee/DietPi/issues/869 - # AmiBerry (Name change): https://github.com/Fourdee/DietPi/issues/850 - if (( $HW_MODEL < 10 )); then - - /DietPi/dietpi/dietpi-software reinstall 7 108 - - fi - # (ALL) - # NAA Daemon: 3.5.1-35 - /DietPi/dietpi/dietpi-software reinstall 124 - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 149 )); then - #------------------------------------------------------------------------------- - #Remove ARMbian-config left on Neo image: - rm /etc/profile.d/check_first_login_reboot.sh &> /dev/null - #------------------------------------------------------------------------------- - #XU4 kernel 4.9 prep: https://github.com/Fourdee/DietPi/issues/899 - if (( $HW_MODEL == 11 && $(uname -r | grep -ci -m1 '^3.' ) )); then - - # - Replace /dev/mmcblk0p* in /etc/fstab + boot.ini with UUID as required by 4.9 kernel+uboot - # MMC0p1 - UUID_CURRENT=$(blkid /dev/mmcblk0p1 -s UUID -o value) - sed -i "s#^/dev/mmcblk0p1#UUID=$UUID_CURRENT#g" /etc/fstab - - # MMC0p2 - UUID_CURRENT=$(blkid /dev/mmcblk0p2 -s UUID -o value) - sed -i "s#^/dev/mmcblk0p2#UUID=$UUID_CURRENT#g" /etc/fstab - systemctl daemon-reload - - sed -i "s#root=/dev/mmcblk0p2#root=UUID=$UUID_CURRENT#g" /DietPi/boot.ini - - # - XU3/4 DTBs are now unique, but, we have no known way of knowing if XU3 or XU4 is current board via system cmds: - # Copy xu3 dtb to xu4 dtb so we can prep for this now when 4.9 arrives - cp /boot/exynos5422-odroidxu3.dtb /boot/exynos5422-odroidxu4.dtb - - # Assume XU4 - if (( ! $USER_INPUTS )); then - - sed -i "s#exynos5422-odroidxu3.dtb#exynos5422-odroidxu4.dtb#g" /DietPi/boot.ini - - # Request - else - - whiptail --title "XU4 4.9 Prep" --yesno "In preperation for the XU4 4.9 kernel, DTB's will be unique for XU3/4 boards.\n\nIs this board an Odroid XU4 (eg: NOT XU3)?" --backtitle "DietPi-Update" 12 70 - if (( $? == 0 )); then - - sed -i "s#exynos5422-odroidxu3.dtb#exynos5422-odroidxu4.dtb#g" /DietPi/boot.ini - - fi - - fi - - fi - #------------------------------------------------------------------------------- - #Minor tweaks to cron.hourly - cp /DietPi/dietpi/conf/cron.hourly_dietpi /etc/cron.hourly/dietpi - chmod +x /etc/cron.hourly/dietpi - #------------------------------------------------------------------------------- - #DietPi-Drive_Manager RO under '/': - cat << _EOF_ > /etc/systemd/system/dietpi-ramdisk.service -[Unit] -Description=DietPi-RAMdisk -After=local-fs.target - -[Service] -Type=forking -RemainAfterExit=yes -ExecStartPre=/bin/mkdir -p /etc/dietpi/logs -ExecStart=/bin/bash -c '/boot/dietpi/dietpi-ramdisk 0' -ExecStop=/bin/bash -c '/DietPi/dietpi/dietpi-ramdisk 1' - -[Install] -WantedBy=local-fs.target -_EOF_ - systemctl enable dietpi-ramdisk.service - systemctl daemon-reload - #------------------------------------------------------------------------------- - #NanoPi M3 update DietPi kernel: https://github.com/Fourdee/DietPi/issues/763 + https://github.com/Fourdee/DietPi/issues/920 - if (( $HW_MODEL == 62 )); then - - /DietPi/dietpi/func/dietpi-set_hardware kernel nanopim3 - - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 150 )); then - #------------------------------------------------------------------------------- - #Fix for VM fstab: https://github.com/Fourdee/DietPi/issues/960 - # Removal of quotations in UUID entry - if (( $HW_MODEL == 20 )); then - - sed -i 's#"044766be-96ca-491a-a93f-913b75a843bd"#044766be-96ca-491a-a93f-913b75a843bd#g' /etc/fstab - systemctl daemon-reload - - fi - #------------------------------------------------------------------------------- - #Reinstalls - # Shairport-sync: https://github.com/Fourdee/DietPi/issues/962 - /DietPi/dietpi/dietpi-software reinstall 37 - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 151 )); then - #------------------------------------------------------------------------------- - #Reinstalls - # WiringPi: https://github.com/Fourdee/DietPi/issues/1001 - /DietPi/dietpi/dietpi-software reinstall 70 - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 152 )); then - #------------------------------------------------------------------------------- - #Disable /tmp tmpfs if RAM <= 512MB: https://github.com/Fourdee/DietPi/issues/1027 - if (( $(free -m | grep -m1 'Mem:' | awk '{print $2}') <= 512 )); then - - sed -i -e "\@[[:space:]]/tmp[[:space:]]@s@^#*@#@" /etc/fstab - systemctl daemon-reload - mount -a - - fi - #------------------------------------------------------------------------------- - #Disable SystemD daily apt processing: https://github.com/Fourdee/DietPi/issues/1032#issuecomment-311942730 - systemctl mask apt-daily.service &> /dev/null - systemctl mask apt-daily-upgrade.timer &> /dev/null - #------------------------------------------------------------------------------- - #Odroid C2 Stretch, missing gnupg, install on all systems by default: https://github.com/Fourdee/DietPi/issues/1032 - apt-get install gnupg -y - #------------------------------------------------------------------------------- - #Firmware for Native PC: https://github.com/Fourdee/DietPi/issues/1007#issuecomment-312442384 - if (( $HW_MODEL == 21 )); then - - apt-get install firmware-linux-nonfree -y - cp /boot/dietpi/conf/htoprc /root/.config/htop/htoprc # Also missing our htop cfg - - fi - #------------------------------------------------------------------------------- - #Sparky kernel update: - # v151 | Updated kernel.dtb for USB Bridge support - # v153 | Updated driver for Piano DAC + (dual output modes) - if (( $HW_MODEL == 70 )); then - - wget https://raw.githubusercontent.com/sparky-sbc/sparky-test/master/usb-port1-enable/kernel.dtb -O /boot/kernel.dtb - wget https://raw.githubusercontent.com/sparky-sbc/sparky-test/master/piano-dac-plus-mono/snd-soc-allo-piano-dac-plus.ko -O /lib/modules/$(uname -r)/kernel/sound/soc/atc260x/snd-soc-allo-piano-dac-plus.ko - - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 153 )); then - #------------------------------------------------------------------------------- - #NTPD mirror: https://github.com/Fourdee/DietPi/issues/1049 - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^NTPD_Mirror=') )); then - - cat << _EOF_ >> /DietPi/dietpi.txt -#NTPD mirror, applied to /etc/ntp.conf -# For a full list, please see http://www.pool.ntp.org -# Please remove the initial interger and full stop from the value (removing 0.). eg: debian.pool.ntp.org -NTPD_Mirror=debian.pool.ntp.org -_EOF_ - - fi - #------------------------------------------------------------------------------- - # + RPi SDTV modes: https://github.com/Fourdee/DietPi/issues/1058 - if (( ! $(cat /DietPi/config.txt | grep -ci -m1 'sdtv_mode=') )); then - - cat << _EOF_ >> /DietPi/config.txt -#sdtv_mode=0 -_EOF_ - - fi - #------------------------------------------------------------------------------- - # Purge unnecessary pciutils package: https://github.com/Fourdee/DietPi/issues/1068 - apt purge -y pciutils - #------------------------------------------------------------------------------- - # RPi Stretch: Switch to new stretch repo on archive.raspberrypi.org: https://github.com/Fourdee/DietPi/issues/1077 - if (( $HW_MODEL < 10 && $DISTRO == 4 )); then # RPi + Stretch - echo "deb https://archive.raspberrypi.org/debian/ stretch main ui" > /etc/apt/sources.list.d/raspi.list - apt update - AGU - AGDU - fi - #------------------------------------------------------------------------------- - #Native PC, add i386 support by default - if (( $HW_MODEL == 21 )); then - - dpkg --add-architecture i386 - apt-get update - - fi - #------------------------------------------------------------------------------- - #Open Bazaar SystemD service: - if [ -f /DietPi/dietpi/.installed ] && - (( $(cat /DietPi/dietpi/.installed | grep -ci -m1 '^aSOFTWARE_INSTALL_STATE\[58\]=2') )); then - - cat << _EOF_ > /etc/systemd/system/openbazaar.service -[Unit] -Description=openbazaar - -[Service] -Type=simple -WorkingDirectory=/etc/openbazaar-server -ExecStart=$(which python) openbazaard.py start -a 0.0.0.0 - -[Install] -WantedBy=multi-user.target -_EOF_ - systemctl daemon-reload - /DietPi/dietpi/dietpi-services dietpi_controlled - - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 154 )); then - #------------------------------------------------------------------------------- - #Deb multimedia repo remove for ALL installs: https://github.com/Fourdee/DietPi/issues/1096#issuecomment-318076721 - rm /etc/apt/sources.list.d/deb-multimedia.list &> /dev/null - #------------------------------------------------------------------------------- - #FS forced resize option (dev use) - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^fs_force_resize=') )); then - - cat << _EOF_ >> /DietPi/dietpi.txt -#Forces a partition resize + expansion of rootfs on next boot. (0=disabled, 1=enabled) -fs_force_resize=0 -_EOF_ - - fi - #------------------------------------------------------------------------------- - #Fix error log on disabled IPv6: https://github.com/Fourdee/DietPi/issues/1119 - sed -i '/net.ipv6.conf.all.disable_ipv6 /c\' /etc/sysctl.conf - sed -i '/net.ipv6.conf.default.disable_ipv6 /c\' /etc/sysctl.conf - sed -i '/net.ipv6.conf.lo.disable_ipv6 /c\' /etc/sysctl.conf - #------------------------------------------------------------------------------- - #Prefer to use wlan/eth naming for networked devices (eg: stretch) - ln -s /dev/null /etc/systemd/network/99-default.link - #------------------------------------------------------------------------------- - #Force auto size/gen of swapfile: https://github.com/Fourdee/DietPi/issues/1126#issuecomment-326749203 - /DietPi/dietpi/func/dietpi-set_dphys-swapfile 1 - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 155 )); then - #------------------------------------------------------------------------------- - #Sparky kernel update to resolve slow playback under 16bit: https://community.roonlabs.com/t/allo-usbridge-board/27487/148 - if (( $HW_MODEL == 70 )); then - - /DietPi/dietpi/func/dietpi-set_hardware kernel sparky_sbc - - # - Update disabled modules - cat << _EOF_ > /etc/modprobe.d/disable_sparkysbc_touchscreen.conf -blacklist owl_camera -blacklist gsensor_stk8313 -blacklist ctp_ft5x06 -blacklist ctp_gsl3680 -blacklist gsensor_bma222 -blacklist gsensor_mir3da -_EOF_ - - cat << _EOF_ > /etc/modprobe.d/disable_sparkysbc_gpu.conf -blacklist pvrsrvkm -blacklist drm -blacklist videobuf2_vmalloc -blacklist bc_example -_EOF_ - - fi - #------------------------------------------------------------------------------- - #dietpi.txt entry for cpu_min_freq: https://github.com/Fourdee/DietPi/pull/1148 - if (( ! $(cat /DietPi/dietpi.txt | grep -ci -m1 '^cpu_min_frequency=') )); then - - cat << _EOF_ >> /DietPi/dietpi.txt -cpu_min_frequency=Disabled -_EOF_ - fi - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 156 )); then - #------------------------------------------------------------------------------- - #Set Ondemand as default CPU gov: https://github.com/Fourdee/DietPi/issues/1141 - sed -i "/cpu_governor=/c\cpu_governor=ondemand" /DietPi/dietpi.txt - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 157 )); then - #------------------------------------------------------------------------------- - #Allo GUI: - if (( $ALLO_GUI_IMAGE )); then - - #Regenerate unique Roon ID's: https://community.roonlabs.com/t/roon-core-will-not-recognize-two-dietpi-allo-gui-roon-bridges-simultaneously/32563/18?u=dan_knight - rm /mnt/dietpi_userdata/roon/RoonBridge/Settings/unique_id - rm /mnt/dietpi_userdata/roon/RAATServer/Settings/unique_id - - fi - #------------------------------------------------------------------------------- - #Reinstalls - # Squeezelite / Shairport-sync - /DietPi/dietpi/dietpi-software reinstall 36 37 - #------------------------------------------------------------------------------- - #WiFi module disable powersave addition: - echo -e "options wlan_8192eu rtw_power_mgnt=0" > /etc/modprobe.d/wlan_8192eu.conf - #------------------------------------------------------------------------------- - #Update of SSH kill on shutdown (due to dropbear/sshd not terminating during shutdown, before network is dropped) - cat << _EOF_ > /etc/systemd/system/kill-ssh-user-sessions-before-network.service -[Unit] -Description=Shutdown all ssh sessions before network -DefaultDependencies=no -Before=network.target shutdown.target - -[Service] -Type=oneshot -ExecStart=/bin/bash -c 'killall sshd &> /dev/null; killall dropbear &> /dev/null' - -[Install] -WantedBy=poweroff.target halt.target reboot.target -_EOF_ - systemctl daemon-reload - systemctl enable kill-ssh-user-sessions-before-network - #------------------------------------------------------------------------------- - #config.txt missing newline on older images, and uploaded/shared confs (<145) - echo -e "\n" >> /DietPi/config.txt - #------------------------------------------------------------------------------- - - elif (( $VERSION_CURRENT == 158 )); then - #------------------------------------------------------------------------------- - #Reinstalls - # Allo GUI (full) - # MPD - # Squeezelite - # YMPD - update-rc.d ympd remove &> /dev/null # switch to systemD - rm /etc/init.d/ympd &> /dev/null # switch to systemD - - # Enable ownCloud/Nextcloud maintenance mode before reinstall: - sudo -u www-data php /var/www/owncloud/occ maintenance:mode --on &> /dev/null - sudo -u www-data php /var/www/nextcloud/occ maintenance:mode --on &> /dev/null - - /DietPi/dietpi/dietpi-software reinstall 159 128 114 47 36 32 - #------------------------------------------------------------------------------- - #RPi update DietPi kernel: - if (( $HW_MODEL < 10 )); then - - # - remove old flags - rm /etc/dietpi/.dietpi_rpi &> /dev/null - rm /etc/dietpi/.384khz_rpi &> /dev/null - - /DietPi/dietpi/func/dietpi-set_hardware kernel dietpi_rpi - - # Sabre module update - if (( $(cat /DietPi/config.txt | grep -ci -m1 'dtoverlay=i-sabre-k2m') )); then - - whiptail --title "i-sabre-k2m" --msgbox "Due to a kernel update, this driver must be reinstalled, however, this can only be completed after the system is rebooted.\n\nOnce the system reboots:\n - use DietPi-Config to select soundcard 'none'\n - then reselect 'i-sabre-k2m'\n - Reboot system" 14 70 - - fi - - fi - #------------------------------------------------------------------------------- - #x86_64, blacklist by nouveau default, prefer Nvidia driver installer - # Disable nouveau: https://github.com/Fourdee/DietPi/issues/1244 // http://dietpi.com/phpbb/viewtopic.php?f=11&t=2462&p=9688#p9688 - if (( $HW_ARCH == 10 )); then - - cat << _EOF_ > /etc/modprobe.d/blacklist-nouveau.conf -blacklist nouveau -blacklist lbm-nouveau -options nouveau modeset=0 -alias nouveau off -alias lbm-nouveau off -_EOF_ - - echo -e "options nouveau modeset=0" > /etc/modprobe.d/nouveau-kms.conf - - update-initramfs -u - - fi - #------------------------------------------------------------------------------- - #WiFi, switch to wpa_supplicant.conf: https://github.com/Fourdee/DietPi/issues/1262 - # Netplug no longer compatible - apt-get purge netplug -y - - # + dietpi.txt entries - if (( ! $(grep -ci -m1 'Wifi_KEYMGR=' /DietPi/dietpi.txt) )); then - - cat << _EOF_ >> /DietPi/dietpi.txt -Wifi_KEYMGR=WPA-PSK -_EOF_ - - fi - - # Patch - if (( $(grep -ci -m1 'wpa-psk' /etc/network/interfaces) )); then - - # get current - WIFI_SSID=$(grep -m1 '^wpa-ssid' /etc/network/interfaces | sed 's/wpa-ssid[[:space:]]//') - WIFI_KEY=$(grep -m1 '^wpa-psk' /etc/network/interfaces | sed 's/wpa-psk[[:space:]]//') - WIFI_COUNTRY_CODE=$( grep -m1 '^wifi_country_code=' /DietPi/dietpi.txt | sed 's/.*=//') - - # update globals - sed -i "/^Wifi_SSID=/c\Wifi_SSID=$WIFI_SSID" /DietPi/dietpi.txt - sed -i "/^Wifi_KEY=/c\Wifi_KEY=$WIFI_KEY" /DietPi/dietpi.txt - - # remove entries, replaced by wpa_supp - sed -i '/wireless-essid[[:space:]]/d' /etc/network/interfaces - sed -i '/wireless-key[[:space:]]/d' /etc/network/interfaces - sed -i '/wireless-mode[[:space:]]/d' /etc/network/interfaces - sed -i '/wpa-ssid[[:space:]]/d' /etc/network/interfaces - sed -i '/wpa-psk[[:space:]]/d' /etc/network/interfaces - - # + wpa supp config link (exclude hotspot) - if [ ! -f /usr/sbin/hostapd ]; then - - sed -i "/wireless-power/a\wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf" /etc/network/interfaces - - fi - - systemctl daemon-reload - - /DietPi/dietpi/func/dietpi-set_hardware wificreds set - - fi - #------------------------------------------------------------------------------- - #PHP: Fix 'upload_tmp_dir': https://github.com/Fourdee/DietPi/issues/1259 - if [ -f /lib/systemd/system/apache2.service ]; then - - PHP_SERVICE='/lib/systemd/system/apache2.service' - - else - - PHP_SERVICE='/lib/systemd/system/php*-fpm.service' - - fi - if grep -q '^\s*PrivateTmp=true' $PHP_SERVICE &> /dev/null; then - - if (( $DISTRO >= 4 )); then - - DIETPI_PHP_INI="/etc/php/7.0/mods-available/dietpi.ini" - PHP_BIN="php" - - else - - DIETPI_PHP_INI="/etc/php5/mods-available/dietpi.ini" - PHP_BIN="php5" - - fi - grep -q 'upload_tmp_dir' $DIETPI_PHP_INI && - sed -i '/upload_tmp_dir/c\upload_tmp_dir = /var/tmp' $DIETPI_PHP_INI || - echo 'upload_tmp_dir = /var/tmp' >> $DIETPI_PHP_INI - ${PHP_BIN}enmod dietpi - - fi - #------------------------------------------------------------------------------- - #Sparky SBC kernel patches - if (( $HW_MODEL == 70 )); then - - wget https://raw.githubusercontent.com/sparky-sbc/sparky-test/master/dragon_fly_check/uImage -O /boot/uImage - wget https://raw.githubusercontent.com/sparky-sbc/sparky-test/master/dragon_fly_check/3.10.38.bz2 -O package.tar - tar xvf package.tar -C /lib/modules/ - rm package.tar - - cat << _EOF_ > /DietPi/uEnv.txt -uenvcmd=setenv os_type linux; -bootargs=earlyprintk clk_ignore_unused selinux=0 scandelay console=tty0 loglevel=1 real_rootflag=rw root=/dev/mmcblk0p2 rootwait init=/lib/systemd/systemd aotg.urb_fix=1 aotg.aotg1_speed=0 -_EOF_ - - fi - #------------------------------------------------------------------------------- - #XU4 FFMPEG fix. Prefer debian.org over Meveric for backports: https://github.com/Fourdee/DietPi/issues/1273 - if (( $HW_MODEL == 11 && $DISTRO == 3 )); then - - cat << _EOF_ > /etc/apt/preferences.d/backports -Package: * -Pin: release a=jessie-backports -Pin: origin "fuzon.co.uk" -Pin-Priority: 99 -_EOF_ - - fi - #------------------------------------------------------------------------------- - #Define a default LD_LIBRARY_PATH for all systems: https://github.com/Fourdee/DietPi/issues/475#issuecomment-350380744 - if (( ! $(grep -ci -m1 '^export LD_LIBRARY_PATH=' /etc/bash.bashrc) )); then - - cat << _EOF_ >> /etc/bash.bashrc -export LD_LIBRARY_PATH=/lib:/usr/lib:/usr/local/lib:/opt/vc/lib -_EOF_ - - fi - #------------------------------------------------------------------------------- fi #------------------------------------------------------------------------------- - #NB: If running apt-get upgrade, use non-interactive function instead: https://github.com/Fourdee/DietPi/issues/689 - # AGU = apt-get upgrade - # AGDU = apt-get dist-upgrade #NB: all if statements must contain at least one command. Prevents bash having a hissy fit :) #------------------------------------------------------------------------------- diff --git a/dietpi/server_version b/dietpi/server_version index ae84183be4..c76772f8fe 100644 --- a/dietpi/server_version +++ b/dietpi/server_version @@ -1,2 +1,2 @@ -159 -5 +160 +6 diff --git a/dietpi/server_version-6 b/dietpi/server_version-6 new file mode 100644 index 0000000000..cdfade7aba --- /dev/null +++ b/dietpi/server_version-6 @@ -0,0 +1,2 @@ +6 +0