Skip to content

Commit

Permalink
v7.1 (#4236)
Browse files Browse the repository at this point in the history
+ DietPi-Software | Add IPFS Node install option
+ DietPi-Software | Add some code comments and G_EXEC usage, where applicable
+ DietPi-Software | Do not call "dietpi-set_hardware headless 0" in every case but only if graphical software is installed
  • Loading branch information
ravenclaw900 authored Apr 11, 2021
1 parent d2df750 commit bdb5699
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 47 deletions.
3 changes: 2 additions & 1 deletion .meta/dietpi-survey_report
Original file line number Diff line number Diff line change
Expand Up @@ -493,9 +493,10 @@ shopt -s extglob
for i in "${!aSOFTWARE_NAME6_35[@]}"
do
aSOFTWARE_NAME7_0[$i]=${aSOFTWARE_NAME6_35[$i]}
# shellcheck disable=SC2034
aSOFTWARE_NAME7_1[$i]=${aSOFTWARE_NAME7_0[$i]}
done
# shellcheck disable=SC2034
aSOFTWARE_NAME7_1[186]='IPFS Node'

# $1 = File name
Process_File()
Expand Down
3 changes: 3 additions & 0 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Changes:
- DietPi-Software | WebIOPi: On fresh installs, the default listening port has been changed from 8000 to 8002 to avoid conflicts with IceCast. Additionally the install process has been slightly sped up by skipping unnecessary installer-internal APT calls.
- DietPi-Software | Koel: On fresh installs and reinstalls, the listening port has been changed from 8000 to 8003 to avoid conflicts with IceCast. Additionally the install process has been simplified and dependencies reduces, since after Koel v5.0.0 pre-compiled frontend binaries are available. This also allows a completely unattended install now. As little security hardening, the Koel MariaDB database password has been changed to a long random character string and the config files permission mode has been changed to 600 to permit read access to the Koel service user only. Finally as little performance enhancement, Koel now connects via UNIX socket to MariaDB instead of view TCP connection, which allows to disable TCP listening in MariaDB.

New Software:
- DietPi-Software | IPFS Node: The InterPlanetary File System peer-to-peer hypermedia protocol node is now available for install. Many thanks to @ravenclaw900 for implementing this software option: https://github.com/MichaIng/DietPi/issues/4232

Fixes:
- DietPi-Config/DietPi-PREP | Resolved an issue on Debian Bullseye, when toggling serial consoles, where /etc/securetty is attempted to be altered even that it is not used and does not exist anymore since Debian Bullseye. Many thanks to @NastyDesertFox for reporting this issue: https://github.com/MichaIng/DietPi/issues/4205
- DietPi-Config | Resolved an issue on Sparky SBC, where selecting the generic USB DAC sound card option failed, due to invalid amixer calls. Many thanks to @Balmoral86 for reporting this issue: https://github.com/MichaIng/DietPi/issues/4249
Expand Down
2 changes: 1 addition & 1 deletion dietpi/dietpi-launcher
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
'' '●─ Misc '
'DietPi-CPUinfo' ': Displays CPU temp, frequencies, type etc.'
'DietPi-LetsEncrypt' ': Frontend for Lets Encrypt, free SSL certs'
'DietPi-NordVPN' ': GUI to setup a NordVPN connection'
'DietPi-VPN' ': GUI to setup a VPN connection'
'DietPi-Survey' ': Join or leave our usage program, or view upload file'
'DietPi-BugReport' ': Found a bug? Let us know!'
'DietPi-MorseCode' ': Converts and outputs a text file to morsecode'
Expand Down
7 changes: 5 additions & 2 deletions dietpi/dietpi-services
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,6 @@ Available services:
'octoprint'

# - Social/Search
'yacy'
'openbazaar'

# - Hardware Projects
Expand Down Expand Up @@ -194,9 +193,13 @@ Available services:
# - Misc
'docker'
'mycroft'
'fahclient'
'cron'

# - Distributed Projects
'fahclient'
'ipfs'
'yacy'

)

# Additional services: https://github.com/MichaIng/DietPi/issues/1869#issuecomment-401017251
Expand Down
182 changes: 139 additions & 43 deletions dietpi/dietpi-software
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ _EOF_
'●─ Advanced Networking ' #16
'●─ Home Automation ' #17
'●─ Printing ' #18
'●─ Computational Science ' #19
'●─ Distributed Projects ' #19

)

Expand Down Expand Up @@ -1228,15 +1228,6 @@ _EOF_
aSOFTWARE_REQUIRES_BUILDESSENTIAL[$software_id]=1
aSOFTWARE_REQUIRES_GIT[$software_id]=1
aSOFTWARE_REQUIRES_USERINPUT[$software_id]=1
#------------------
software_id=133

aSOFTWARE_NAME[$software_id]='YaCy'
aSOFTWARE_DESC[$software_id]='decentralised open source search engine'
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_CATEGORY_INDEX[$software_id]=6
aSOFTWARE_ONLINEDOC_URL[$software_id]='https://dietpi.com/docs/software/social/#yacy'
aSOFTWARE_REQUIRES_JAVA_JRE_JDK[$software_id]=1

# Camera & Surveillance
#--------------------------------------------------------------------------------
Expand Down Expand Up @@ -1810,16 +1801,6 @@ _EOF_
aSOFTWARE_CATEGORY_INDEX[$software_id]=16
aSOFTWARE_ONLINEDOC_URL[$software_id]='https://dietpi.com/docs/software/advanced_networking/#haproxy'
aSOFTWARE_REQUIRES_BUILDESSENTIAL[$software_id]=1
#------------------
software_id=184

aSOFTWARE_NAME[$software_id]='Tor Relay'
aSOFTWARE_DESC[$software_id]='add a node to the Tor network'
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_CATEGORY_INDEX[$software_id]=16
aSOFTWARE_ONLINEDOC_URL[$software_id]='https://dietpi.com/docs/software/advanced_networking/#tor-relay'
aSOFTWARE_RECOMMENDS_AUTOMATED_UPGRADES[$software_id]=1
aSOFTWARE_REQUIRES_USERINPUT[$software_id]=1

# Home Automation
#--------------------------------------------------------------------------------
Expand Down Expand Up @@ -1875,18 +1856,45 @@ _EOF_
aSOFTWARE_ONLINEDOC_URL[$software_id]='https://dietpi.com/docs/software/printing/#octoprint'
(( $G_HW_ARCH < 3 && $G_DISTRO > 4 )) || aSOFTWARE_REQUIRES_BUILDESSENTIAL[$software_id]=1

# Computational Science
# Distributed Projects
#--------------------------------------------------------------------------------
software_id=2

aSOFTWARE_NAME[$software_id]='Folding@Home'
aSOFTWARE_DESC[$software_id]='distributed disease research project'
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_CATEGORY_INDEX[$software_id]=19
aSOFTWARE_ONLINEDOC_URL[$software_id]='https://dietpi.com/docs/software/computational_science/#foldinghome'
aSOFTWARE_ONLINEDOC_URL[$software_id]='https://dietpi.com/docs/software/distributed_projects/#foldinghome'
# - ARMv6 - ARMv7
aSOFTWARE_AVAIL_G_HW_ARCH[$software_id,1]=0
aSOFTWARE_AVAIL_G_HW_ARCH[$software_id,2]=0
#------------------
software_id=133

aSOFTWARE_NAME[$software_id]='YaCy'
aSOFTWARE_DESC[$software_id]='decentralised open source search engine'
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_CATEGORY_INDEX[$software_id]=19
aSOFTWARE_ONLINEDOC_URL[$software_id]='https://dietpi.com/docs/software/distributed_projects/#yacy'
aSOFTWARE_REQUIRES_JAVA_JRE_JDK[$software_id]=1
#------------------
software_id=184

aSOFTWARE_NAME[$software_id]='Tor Relay'
aSOFTWARE_DESC[$software_id]='add a node to the Tor network'
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_CATEGORY_INDEX[$software_id]=19
aSOFTWARE_ONLINEDOC_URL[$software_id]='https://dietpi.com/docs/software/distributed_projects/#tor-relay'
aSOFTWARE_RECOMMENDS_AUTOMATED_UPGRADES[$software_id]=1
aSOFTWARE_REQUIRES_USERINPUT[$software_id]=1
#------------------
software_id=186

aSOFTWARE_NAME[$software_id]='IPFS Node'
aSOFTWARE_DESC[$software_id]='contribute to a decentralized internet'
aSOFTWARE_TYPE[$software_id]=0
aSOFTWARE_CATEGORY_INDEX[$software_id]=19
aSOFTWARE_ONLINEDOC_URL[$software_id]='https://dietpi.com/docs/software/distributed_projects/#ipfs-node'

#--------------------------------------------------------------------------------
# Additional linux software items
Expand Down Expand Up @@ -3607,6 +3615,36 @@ _EOF_

fi

software_id=186 # IPFS Node
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then

Banner_Installing

# ARMv6/7
local arch='arm'

# ARMv8
if (( $G_HW_ARCH == 3 )); then

arch='arm64'

# x86_64
elif (( $G_HW_ARCH == 10 )); then

arch='amd64'

fi

# Download latest version
local version=$(curl -sSfL 'https://dist.ipfs.io/go-ipfs/versions' | tail -n 1)
[[ $version ]] || { version='v0.8.0'; G_DIETPI-NOTIFY 1 "Automatic latest ${aSOFTWARE_NAME[$software_id]} version detection failed. Version \"$version\" will be installed as fallback, but a newer version might be available. Please report this at: https://github.com/MichaIng/DietPi/issues"; }
Download_Install "https://dist.ipfs.io/go-ipfs/$version/go-ipfs_${version}_linux-$arch.tar.gz"

# Install
G_EXEC_OUTPUT=1 G_EXEC go-ipfs/install.sh

fi

software_id=2 # Folding@Home
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then

Expand Down Expand Up @@ -9872,6 +9910,55 @@ _EOF_

fi

software_id=186 # IPFS Node
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then

Banner_Configuration

# Data and config directory
[[ -d '/mnt/dietpi_userdata/ipfs' ]] || G_EXEC mkdir -p /mnt/dietpi_userdata/ipfs

# User
Create_User -d /mnt/dietpi_userdata/ipfs ipfs

# Service
cat << '_EOF_' > /etc/systemd/system/ipfs.service
[Unit]
Description=IPFS (DietPi)
Documentation=https://docs.ipfs.io/reference/go/api/
Wants=network-online.target
After=network-online.target dietpi-boot.service

[Service]
User=ipfs
Environment=IPFS_PATH=/mnt/dietpi_userdata/ipfs
ExecStart=/usr/local/bin/ipfs daemon

[Install]
WantedBy=multi-user.target
_EOF_
# Config: Preserve existing on reinstall
if [[ ! -f '/mnt/dietpi_userdata/ipfs/config' ]]; then

IPFS_PATH='/mnt/dietpi_userdata/ipfs' G_EXEC_OUTPUT=1 G_EXEC ipfs init
IPFS_PATH='/mnt/dietpi_userdata/ipfs' G_EXEC ipfs config --json Addresses.Gateway '"/ip4/0.0.0.0/tcp/8087"'
IPFS_PATH='/mnt/dietpi_userdata/ipfs' G_EXEC ipfs config --json Addresses.API '"/ip4/0.0.0.0/tcp/5003"'
IPFS_PATH='/mnt/dietpi_userdata/ipfs' G_EXEC ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'

fi

# Permissions
G_EXEC chown -R ipfs:ipfs /mnt/dietpi_userdata/ipfs

# CLI alias
echo "alias ipfs='sudo -u ipfs IPFS_PATH=/mnt/dietpi_userdata/ipfs ipfs'" > /etc/bashrc.d/dietpi-ipfs.sh

# Raise packet receive buffer: https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size
G_EXEC eval "echo 'net.core.rmem_max=2500000' > /etc/sysctl.d/dietpi-ipfs.conf"
G_EXEC sysctl -w net.core.rmem_max=2500000

fi

software_id=77 # Grafana
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == 1 )); then

Expand All @@ -9886,16 +9973,16 @@ _EOF_

elif [[ -d '/var/lib/grafana' ]]; then

mv /var/lib/grafana /mnt/dietpi_userdata/
G_EXEC mv /var/lib/grafana /mnt/dietpi_userdata/

else

mkdir -p /mnt/dietpi_userdata/grafana
chown -R grafana:grafana /mnt/dietpi_userdata/grafana
G_EXEC mkdir -p /mnt/dietpi_userdata/grafana
G_EXEC chown -R grafana:grafana /mnt/dietpi_userdata/grafana

fi
rm -Rf /var/lib/grafana
ln -s /mnt/dietpi_userdata/grafana /var/lib/grafana
G_EXEC rm -Rf /var/lib/grafana
G_EXEC ln -s /mnt/dietpi_userdata/grafana /var/lib/grafana

# Config: Apply our defaults only if nothing was set before
# - Set password, wrap into trippled double quotes in case of ; or # being contained, according to docs: http://docs.grafana.org/installation/configuration/#password
Expand Down Expand Up @@ -13203,9 +13290,6 @@ _EOF_

Install_Apply_GPU_Settings(){

# Disable headless mode based on installed software
local gpu_enabled=1

# RPi: Define minimal memory split based on installed software
local gpu_memory=0

Expand Down Expand Up @@ -13239,23 +13323,21 @@ _EOF_

fi

# RPi: Apply memory split
if (( $G_HW_MODEL < 10 && $gpu_memory > 0 )); then
# Disable headless/enable GPU when graphics software was installed
(( $gpu_memory )) || return

# Never override a higher existing value
local current_gpu_mem=$(sed -n '/^[[:blank:]]*gpu_mem_1024=/{s/^[^=]*=//p;q}' /boot/config.txt)
G_WHIP_DEFAULT_ITEM='Ok'
if (( $current_gpu_mem < $gpu_memory )) && G_WHIP_YESNO "[ INFO ] DietPi has detected an increased GPU memory is required for your installed software:
- Current: $current_gpu_mem MiB\n - Recommended: $gpu_memory MiB\n\nWould you like DietPi to apply the recommended GPU memory split?\n\nIf unsure, select 'Ok'."; then
/boot/dietpi/func/dietpi-set_hardware headless 0

/boot/dietpi/func/dietpi-set_hardware gpumemsplit $gpu_memory
# RPi: Apply memory split
(( $G_HW_MODEL < 10 )) || return

fi
# Never override a higher existing value
local current_gpu_mem=$(sed -n '/^[[:blank:]]*gpu_mem_1024=/{s/^[^=]*=//p;q}' /boot/config.txt)
[[ $current_gpu_mem ]] || current_gpu_mem=64
(( $current_gpu_mem < $gpu_memory )) && G_WHIP_DEFAULT_ITEM='Ok' G_WHIP_YESNO "[ INFO ] DietPi has detected an increased GPU memory is required for your installed software:
- Current: $current_gpu_mem MiB\n - Recommended: $gpu_memory MiB\n\nWould you like DietPi to apply the recommended GPU memory split?\n\nIf unsure, select 'Ok'." || return

fi

# Disable headless/enable GPU
(( $gpu_enabled )) && /boot/dietpi/func/dietpi-set_hardware headless 0
/boot/dietpi/func/dietpi-set_hardware gpumemsplit $gpu_memory

}

Expand Down Expand Up @@ -14584,6 +14666,20 @@ _EOF_

fi

software_id=186 # IPFS Node
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then

Banner_Uninstalling
if [[ -f '/etc/systemd/system/ipfs.service' ]]
then
systemctl disable --now ipfs
rm -v /etc/systemd/system/ipfs.service
fi
[[ -d '/etc/systemd/system/ipfs.service.d' ]] && rm -R /etc/systemd/system/ipfs.service.d
rm -Rf /usr/local/bin/ipfs /etc/bashrc.d/dietpi-ipfs.sh /etc/sysctl.d/dietpi-ipfs.conf /mnt/dietpi_userdata/ipfs

fi

software_id=98 # HAProxy
if (( ${aSOFTWARE_INSTALL_STATE[$software_id]} == -1 )); then

Expand Down

0 comments on commit bdb5699

Please sign in to comment.