Skip to content

Commit

Permalink
v160
Browse files Browse the repository at this point in the history
+ Switch to DietPi-Global imports in all scripts (excluding those within
the script itself): https://github.com/Fourdee/DietPi/issues/1311
  • Loading branch information
Fourdee committed Dec 17, 2017
1 parent 03af044 commit 874383b
Show file tree
Hide file tree
Showing 46 changed files with 253 additions and 543 deletions.
28 changes: 3 additions & 25 deletions dietpi/boot
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,15 @@
# - 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/func/dietpi-globals update_hw_details
#Import DietPi-Globals ---------------------------------------------------------------

#/////////////////////////////////////////////////////////////////////////////////////
#Globals
#/////////////////////////////////////////////////////////////////////////////////////
FP_LOGFILE='/var/log/dietpi-boot.log'

HW_MODEL=0
DISTRO=0
HW_CPUID=0

# -1 = first boot / 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
Expand Down Expand Up @@ -249,11 +232,6 @@
#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 &
#----------------------------------------------------------------
Expand Down
15 changes: 6 additions & 9 deletions dietpi/dietpi-autostart
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,18 @@
# - 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
CHECK_ROOT_USER
#Import DietPi-Globals ---------------------------------------------------------------

#/////////////////////////////////////////////////////////////////////////////////////
# MENUS
Expand Down Expand Up @@ -246,7 +244,6 @@ _EOF_

}


#/////////////////////////////////////////////////////////////////////////////////////
# Main Loop
#/////////////////////////////////////////////////////////////////////////////////////
Expand Down
30 changes: 7 additions & 23 deletions dietpi/dietpi-backup
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,18 @@
# - /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
CHECK_ROOT_USER
CHECK_ROOTFS_RW
#Import DietPi-Globals ---------------------------------------------------------------

#/////////////////////////////////////////////////////////////////////////////////////
# MENUS
#/////////////////////////////////////////////////////////////////////////////////////
Expand Down
11 changes: 4 additions & 7 deletions dietpi/dietpi-banner
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,19 @@
# - 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
#Import DietPi-Globals ---------------------------------------------------------------

#/////////////////////////////////////////////////////////////////////////////////////
#Globals
#/////////////////////////////////////////////////////////////////////////////////////
DIETPI_VERSION=$(cat /DietPi/dietpi/.version)
HW_MODEL_DESCRIPTION=$(sed -n 2p /DietPi/dietpi/.hw_model)
IMAGE_ADDITIONAL_CREDITS=$(sed -n 8p /DietPi/dietpi/.hw_model)

IP_ADDRESS=$(sed -n 4p /DietPi/dietpi/.network)
Expand Down
10 changes: 5 additions & 5 deletions dietpi/dietpi-bugreport
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
# - 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
CHECK_ROOT_USER
CHECK_ROOTFS_RW
#Import DietPi-Globals ---------------------------------------------------------------

# - byte
UPLOAD_FILESIZE_LIMIT=83886080
Expand Down
20 changes: 6 additions & 14 deletions dietpi/dietpi-cleaner
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,18 @@
# /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
CHECK_ROOT_USER
CHECK_ROOTFS_RW
#Import DietPi-Globals ---------------------------------------------------------------

#/////////////////////////////////////////////////////////////////////////////////////
# Globals
#/////////////////////////////////////////////////////////////////////////////////////
Expand Down
22 changes: 5 additions & 17 deletions dietpi/dietpi-cloudshell
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,16 @@
# 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
CHECK_ROOT_USER
#Import DietPi-Globals ---------------------------------------------------------------

#Version
DIETPI_CLOUDSHELL_VERSION=9
Expand Down Expand Up @@ -386,7 +374,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 / $HW_CPU_CORES" | bc -l )

# TOP (accurate)
# Fails to output in low screen res (https://github.com/Fourdee/DietPi/issues/203#issuecomment-189711968)
Expand Down
61 changes: 14 additions & 47 deletions dietpi/dietpi-config
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,35 @@
# - 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)
#/////////////////////////////////////////////////////////////////////////////////////
# -1 = first boot / 0 = run dietpi-software at login / 1 = completed
DIETPI_INSTALL_STAGE=$(cat /DietPi/dietpi/.install_stage)
#Import DietPi-Globals ---------------------------------------------------------------
. /DietPi/dietpi/func/dietpi-globals
CHECK_ROOT_USER
CHECK_ROOTFS_RW
#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

Expand Down Expand Up @@ -96,17 +74,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'
Expand Down
14 changes: 5 additions & 9 deletions dietpi/dietpi-cpu_set
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
# - 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
CHECK_ROOT_USER
#Import DietPi-Globals ---------------------------------------------------------------

#Exit path for VM
if (( $HW_MODEL == 20 )); then
Expand All @@ -30,7 +27,6 @@

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/.*=//')
Expand Down Expand Up @@ -184,7 +180,7 @@
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 $HW_CPU_CORES

/DietPi/dietpi/func/dietpi-notify 0 "CPU gov applied: $CPU_GOVERNOR\n"

Expand Down
Loading

0 comments on commit 874383b

Please sign in to comment.