Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

v68 #22

Merged
merged 25 commits into from
Jun 14, 2015
Prev Previous commit
Next Next commit
v68
Fourdee committed Jun 12, 2015
commit 3a180dc8546446584d75ec162de0e9609d29a6d4
3 changes: 2 additions & 1 deletion CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
v68
(xx/06/15)
Release Notes:
DietPi-BugReport | Can now generate offline reports to /boot/bugreport.zip
DietPi-BugReport | Can now generate an offline bugreport.zip if no network is detected.


-----------------------------------------------------------------------------------------------------------
v67
14 changes: 6 additions & 8 deletions dietpi.txt
Original file line number Diff line number Diff line change
@@ -33,22 +33,26 @@ AUTO_DietpiSoftware_SkipQuestions=0
AUTO_DietpiSoftware_SkipUsbDrive=0
# 0 = none , -1 = dropbear , -2 = opensshserver
AUTO_DietpiSoftware_SSHServerIndex=-1
# 0 = none , -1 = proftp , -2 = samba
AUTO_DietpiSoftware_FileServerIndex=0
# 0 = none , -1 = ramlog 24h clear , -2 = ramlog 1h backup clear , -3 = logrotate noclear
AUTO_DietpiSoftware_LoggingIndex=-1

#----------------------------------------------------------------
# D I E T - P I
# Global Settings Specific to DietPi
#----------------------------------------------------------------
# - Ideally, use dietpi-config to modify these values.
# RPi Hdmi output (if 0, sets tvservice -o and framebuffer 16x16 on boot, headless)
# RPi Hdmi output (if 0, sets tvservice -o and framebuffer 16x 16y 8z on boot, headless)
rpi_hdmi_output=1

#Cpu Governor | ondemand | powersave | performance | conservative
cpu_governor=ondemand
cpu_usage_throttle_up=60

#ONDEMAND Settings
#Min value 10000 microseconds (1ms)
cpu_ondemand_sampling_rate=100000

#sampling rate * down factor = microseconds (20 = 2000ms when sampling rate is 100000)
cpu_ondemand_sampling_down_factor=20

@@ -63,12 +67,6 @@ curlftpfs_clientaddress=192.168.0.100
curlftpfs_clientusername=root
curlftpfs_clientpassword=raspberry

#Logclear Mode
# -1 = Do not clear | logrotate
# 0 = (Default) Clear. | ramlog
# 1 = Add current log file data to /"$HOME"/logbackup/. Then clear. | ramlog
logclear_mode_index=0

#Git Branch, DO NOT MODIFY
gitbranch=master

12 changes: 9 additions & 3 deletions dietpi/conf/cron.daily_dietpi
Original file line number Diff line number Diff line change
@@ -10,16 +10,22 @@
#
#////////////////////////////////////

LOGCLEAR_MODE=$(cat /boot/dietpi.txt | grep 'logclear_mode_index=' | sed 's/logclear_mode_index=//g')
LOGGING_MODE=-1
if [ -f /boot/dietpi/.installed ]; then
LOGGING_MODE=$(cat /boot/dietpi/.installed | grep 'INDEX_LOGGING_CURRENT ' | awk '{print $2}')
fi

#----------------------------------------------------------------
# Main Loop
#----------------------------------------------------------------
#Mode=0 | Clear all Log files - recursive
if (( $LOGCLEAR_MODE == 0 )); then
# Logging

#Mode -1 | Clear all Log files - recursive
if (( $LOGGING_MODE == -1 )); then
/boot/dietpi/logclear
fi

#----------------------------------------------------------------
#check for dietpi updates
/boot/dietpi/dietpi-update 2 &> /dev/null

11 changes: 8 additions & 3 deletions dietpi/conf/cron.hourly_dietpi
Original file line number Diff line number Diff line change
@@ -10,13 +10,18 @@
#
#////////////////////////////////////

LOGCLEAR_MODE=$(cat /boot/dietpi.txt | grep 'logclear_mode_index=' | sed 's/logclear_mode_index=//g')
LOGGING_MODE=-1
if [ -f /boot/dietpi/.installed ]; then
LOGGING_MODE=$(cat /boot/dietpi/.installed | grep 'INDEX_LOGGING_CURRENT ' | awk '{print $2}')
fi

#----------------------------------------------------------------
# Main Loop
#----------------------------------------------------------------
#Mode=1 | Updates the log files in /$HOME/log_backup/* . Then overwrites and clears all logs in /var/log - recursive
if (( $LOGCLEAR_MODE == 1 )); then
# Logging

#Mode -2 | Updates the log files in /$HOME/log_backup/* . Then overwrites and clears all logs in /var/log - recursive
if (( $LOGGING_MODE == -2 )); then
/boot/dietpi/logclear
fi

9 changes: 6 additions & 3 deletions dietpi/dietpi-funtime
Original file line number Diff line number Diff line change
@@ -30,11 +30,14 @@
local MAX_COUNT=28
((MAX_COUNT--))

local count=$MAX_COUNT
local mode=1
#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 MAX_PASSES=3

declare -a marker=(
'# processing | D I E T P I #'
69 changes: 66 additions & 3 deletions dietpi/dietpi-software
Original file line number Diff line number Diff line change
@@ -68,6 +68,8 @@
AUTOINSTALL_SKIPUSBDRIVE=$(cat /boot/dietpi.txt | grep 'AUTO_DietpiSoftware_SkipUsbDrive=' | sed 's/AUTO_DietpiSoftware_SkipUsbDrive=//g')
AUTOINSTALL_SKIPQUESTIONS=$(cat /boot/dietpi.txt | grep 'AUTO_DietpiSoftware_SkipQuestions=' | sed 's/AUTO_DietpiSoftware_SkipQuestions=//g')
AUTOINSTALL_SSHINDEX=$(cat /boot/dietpi.txt | grep 'AUTO_DietpiSoftware_SSHServerIndex=' | sed 's/AUTO_DietpiSoftware_SSHServerIndex=//g')
AUTOINSTALL_FILESERVERINDEX=$(cat /boot/dietpi.txt | grep 'AUTO_DietpiSoftware_FileServerIndex=' | sed 's/AUTO_DietpiSoftware_FileServerIndex=//g')
AUTOINSTALL_LOGGINGINDEX=$(cat /boot/dietpi.txt | grep 'AUTO_DietpiSoftware_LoggingIndex=' | sed 's/AUTO_DietpiSoftware_LoggingIndex=//g')

Apply_Automated_Install(){

@@ -87,14 +89,14 @@
#DIETPI Core
if (( $AUTOINSTALL_INDEX == 1 )); then
echo -e " - DietPi-Core\n"
sleep 2
/tmp/dietpi/dietpi-funtime 0
#example of setting packages
#DESKTOP=1

#Grasshopper
elif (( $AUTOINSTALL_INDEX == 2 )); then
echo -e " - Grasshopper\n"
sleep 2
/tmp/dietpi/dietpi-funtime 0

#Required DietPi Software
GRASSHOPPER=1
@@ -110,6 +112,8 @@

#Further Automated options. (Applied regardless of AUTOINSTALL_INDEX)
INDEX_SSHSERVER_TARGET=$AUTOINSTALL_SSHINDEX
INDEX_FILESERVER_TARGET=$AUTOINSTALL_FILESERVERINDEX
INDEX_LOGGING_TARGET=$AUTOINSTALL_LOGGINGINDEX

}

@@ -169,6 +173,8 @@
CURLFTPFS=0
SSHSERVER_DROPBEAR=2
SSHSERVER_OPENSSH=0
LOGGING_LOGROTATE=0
LOGGING_RAMLOG=0

#SSH Server Choices system
INSTALL_SSHSERVER_CHOICESMADE=false
@@ -182,6 +188,11 @@
INDEX_FILESERVER_CURRENT=0
INDEX_FILESERVER_TARGET=0

#Logging Choices system
INSTALL_LOGGING_CHOICESMADE=false
# 0=none -1=ramlog 24h clear -2=ramlog 1hour backup, clear -3=logrotate
INDEX_LOGGING_CURRENT=-1
INDEX_LOGGING_TARGET=-1

Write_InstallFileList(){

@@ -238,6 +249,10 @@
echo -e "#DietPi Choice System: File Server" >> "$FILEPATH_INSTALLED_FILE"
echo -e "INDEX_FILESERVER_CURRENT $INDEX_FILESERVER_CURRENT" >> "$FILEPATH_INSTALLED_FILE"
echo -e "INDEX_FILESERVER_TARGET $INDEX_FILESERVER_TARGET" >> "$FILEPATH_INSTALLED_FILE"

echo -e "#DietPi Choice System: Logging" >> "$FILEPATH_INSTALLED_FILE"
echo -e "INDEX_LOGGING_CURRENT $INDEX_LOGGING_CURRENT" >> "$FILEPATH_INSTALLED_FILE"
echo -e "INDEX_LOGGING_TARGET $INDEX_LOGGING_TARGET" >> "$FILEPATH_INSTALLED_FILE"

}

@@ -293,6 +308,10 @@
#Fileserver Software Choices
INDEX_FILESERVER_CURRENT=$(cat "$FILEPATH_INSTALLED_FILE" | grep 'INDEX_FILESERVER_CURRENT ' | awk '{print $2}')
INDEX_FILESERVER_TARGET=$(cat "$FILEPATH_INSTALLED_FILE" | grep 'INDEX_FILESERVER_TARGET ' | awk '{print $2}')

#Logging Choices
INDEX_LOGGING_CURRENT=$(cat "$FILEPATH_INSTALLED_FILE" | grep 'INDEX_LOGGING_CURRENT ' | awk '{print $2}')
INDEX_LOGGING_TARGET=$(cat "$FILEPATH_INSTALLED_FILE" | grep 'INDEX_LOGGING_TARGET ' | awk '{print $2}')

#Take note of the extra space used at the end of each grep quote 'MYSOFTWARE '
#This ensures packages with similar names (eg: WEBSERVER_PHP and WEBSERVER_PHPMYADMIN) dont both get picked up.
@@ -1097,6 +1116,44 @@
fi

}

Apply_Logging_Choices(){

#Work out which Logging system needs installing from Indexs (if any)
#Work out which Logging system needs removing (if any), and, create a temp script file
if (( $INDEX_LOGGING_TARGET != $INDEX_LOGGING_CURRENT )); then

#None
if (( $INDEX_LOGGING_TARGET == 0 )); then
echo -e "LOGGING_LOGROTATE" >> "$UNINSTALL_FILE"
echo -e "LOGGING_RAMLOG" >> "$UNINSTALL_FILE"

#Ramlog - clear every 24H
elif (( $INDEX_LOGGING_TARGET == -1 )); then

LOGGING_RAMLOG=1
echo -e "LOGGING_LOGROTATE" >> "$UNINSTALL_FILE"

#Ramlog - backup every 1H to /$HOME/logfile_storage, then clear.
elif (( $INDEX_LOGGING_TARGET == -2 )); then

LOGGING_RAMLOG=1
echo -e "LOGGING_LOGROTATE" >> "$UNINSTALL_FILE"

#Logrotate - logs to disk
elif (( $INDEX_LOGGING_TARGET == -3 )); then

LOGGING_LOGROTATE=1
echo -e "LOGGING_RAMLOG" >> "$UNINSTALL_FILE"

fi

#Update Current Logging index
INDEX_LOGGING_CURRENT=$INDEX_LOGGING_TARGET

fi

}

Install_Apply_Configs(){

@@ -1946,7 +2003,12 @@
Menu_StartInstall(){

#No Software selected / No changes Made / nothing to install
if [ "$INSTALL_DIETPI_CHOICESMADE" = false ] && [ "$INSTALL_LINUX_CHOICESMADE" = false ] && [ "$INSTALL_SSHSERVER_CHOICESMADE" = false ] && [ "$INSTALL_FILESERVER_CHOICESMADE" = false ]; then
if [ "$INSTALL_DIETPI_CHOICESMADE" = false ] &&
[ "$INSTALL_LINUX_CHOICESMADE" = false ] &&
[ "$INSTALL_SSHSERVER_CHOICESMADE" = false ] &&
[ "$INSTALL_FILESERVER_CHOICESMADE" = false ] &&
[ "$INSTALL_LOGGING_CHOICESMADE" = false ]; then

#1st run install
if (( $DIETPI_INSTALL_STAGE == 0 )); then
WHIP_TITLE='No Software Selected!'
@@ -2973,6 +3035,7 @@
#Apply DietPi choice systems
Apply_FileServer_Choices
Apply_SSHServer_Choices
Apply_Logging_Choices

#Install Linux Software
Install_Linux_Software
9 changes: 6 additions & 3 deletions dietpi/finalise
Original file line number Diff line number Diff line change
@@ -138,6 +138,12 @@
sed -i "/AUTO_DietpiSoftware_SkipUsbDrive=/c\AUTO_DietpiSoftware_SkipUsbDrive=0" /boot/dietpi.txt
#Dropbear SSH -1
sed -i "/AUTO_DietpiSoftware_SSHServerIndex=/c\AUTO_DietpiSoftware_SSHServerIndex=-1" /boot/dietpi.txt
# 0 = none
sed -i "/AUTO_DietpiSoftware_FileServerIndex=/c\AUTO_DietpiSoftware_FileServerIndex=0" /boot/dietpi.txt
#-1 = ramlog 24h clear
sed -i "/AUTO_DietpiSoftware_LoggingIndex=/c\AUTO_DietpiSoftware_LoggingIndex=-1" /boot/dietpi.txt
#Remove logging mode -2 backups
rm -R /"$HOME"/logfile_storage

# Development Settings
sed -i "/gitbranch=/c\gitbranch=master" /boot/dietpi.txt
@@ -156,9 +162,6 @@
sed -i "/cpu_ondemand_sampling_down_factor=/c\cpu_ondemand_sampling_down_factor=20" /boot/dietpi.txt
/boot/dietpi/dietpi-cpu_set

#Logclear mode
sed -i "/logclear_mode_index=/c\logclear_mode_index=0" /boot/dietpi.txt

#////////////////////////////////////
# Remove/Reset DietPi generated files
rm /boot/dietpi/.*
36 changes: 17 additions & 19 deletions dietpi/logclear
Original file line number Diff line number Diff line change
@@ -8,24 +8,25 @@
#
#////////////////////////////////////
#
# Info:
# - LOGCLEAR_MODE = -1 | Disabled.
# - LOGCLEAR_MODE = 0 | Overwrites and clears all logs in /var/log - recursive
# - LOGCLEAR_MODE = 1 | Updates the log file in /$HOME/log_backup/* . Then overwrites and clears all logs in /var/log - recursive
#////////////////////////////////////

TEMP_LOGLIST_FILEPATH="/tmp/logclear_temp"

LOGCLEAR_MODE=$(cat /boot/dietpi.txt | grep 'logclear_mode_index=' | sed 's/logclear_mode_index=//g')
LOGGING_MODE=-1
if [ -f /boot/dietpi/.installed ]; then
LOGGING_MODE=$(cat /boot/dietpi/.installed | grep 'INDEX_LOGGING_CURRENT ' | awk '{print $2}')
fi

#////////////////////////////////////
# Run
#////////////////////////////////////

#----------------------------------------------------------------
# NB: LOGCLEAR_MODE 0/1 in seperate forloops. Although they could all be in the same forloop, it would generate a "if (( $LOGCLEAR_MODE == ? ))" call for each log file.
#MODE 0 | Clear all logs in /var/log by overwriting them.
if (( $LOGCLEAR_MODE == 0 )); then
#MODE 0 = None , do nothing.

#----------------------------------------------------------------
#MODE -1 | Clear all logs in /var/log by overwriting them.
if (( $LOGGING_MODE == -1 )); then

#Find existing logs and read their filepath into an array
find /var/log -type f > "$TEMP_LOGLIST_FILEPATH"
@@ -46,8 +47,8 @@
unset ARRAY_LOG_FILEPATH

#----------------------------------------------------------------
#MODE 1 = Add current log files data to /"$HOME"/logbackup/*. Then clear.
elif (( $LOGCLEAR_MODE == 1 )); then
#MODE -2 = Add current log files data to /"$HOME"/logbackup/*. Then clear.
elif (( $LOGGING_MODE == -2 )); then

#Find existing logs and read their filepath into an array
find /var/log -type f > "$TEMP_LOGLIST_FILEPATH"
@@ -62,21 +63,16 @@
filename=$(echo -e ${ARRAY_LOG_FILEPATH[$i]} | sed 's/\/var\/log\///g')

#Generate filepaths
if [ ! -f "$HOME/logs_backup/$filename" ]; then
if [ ! -f "$HOME/logfile_storage/$filename" ]; then

#This is a little "hack" to automatically generate the required subdirectories.
# EG: /this/is/my/logfile.txt | will create the folders /this/is/my
#
# How it works:
# We create the target filepath as a folder
# Then we delete the folder.
# By doing this, we generate all the required subdirectories that the file needs.
mkdir -p "$HOME/logs_backup/$filename"
rm -R "$HOME/logs_backup/$filename"
mkdir -p "$HOME/logfile_storage/$filename"
rm -R "$HOME/logfile_storage/$filename"
fi

#Write current logfile contents to existing.
cat "${ARRAY_LOG_FILEPATH[$i]}" >> "$HOME"/logs_backup/"$filename"
cat "${ARRAY_LOG_FILEPATH[$i]}" >> "$HOME"/logfile_storage/"$filename"
fi

#Clear log files by overwriting them.
@@ -90,6 +86,8 @@
#delete[] array
unset ARRAY_LOG_FILEPATH
fi
#----------------------------------------------------------------
#MODE -3 = Logrotate, do nothing

#----------------------------------------------------------------
exit
15 changes: 12 additions & 3 deletions dietpi/patch_file
Original file line number Diff line number Diff line change
@@ -564,9 +564,18 @@
elif (( $VERSION_CURRENT == 67 )); then
echo -e "67 > 68 patch"
#-------------------------------------------------------------------------------
#dietpi.txt - Logclear mode.
echo -e "#Logclear mode" >> /boot/dietpi.txt
echo -e "logclear_mode_index=0" >> /boot/dietpi.txt
#dietpi.txt Automation additions
echo -e "AUTO_DietpiSoftware_FileServerIndex=0" >> /boot/dietpi.txt
echo -e "AUTO_DietpiSoftware_LoggingIndex=-1" >> /boot/dietpi.txt
#-------------------------------------------------------------------------------
#New .installed
if [ -f /boot/dietpi/.installed ]; then
echo -e "LOGGING_RAMLOG 2" >> /boot/dietpi/.installed
echo -e "LOGGING_LOGROTATE 0" >> /boot/dietpi/.installed
echo -e "#DietPi Choice System: Logging" >> /boot/dietpi/.installed
echo -e "INDEX_LOGGING_CURRENT -1" >> /boot/dietpi/.installed
echo -e "INDEX_LOGGING_TARGET -1" >> /boot/dietpi/.installed
fi
#-------------------------------------------------------------------------------
#Update DietPi crons
cp /boot/dietpi/conf/cron.daily_dietpi /etc/cron.daily/dietpi