-
-
Notifications
You must be signed in to change notification settings - Fork 501
/
dietpi
executable file
·61 lines (58 loc) · 2.55 KB
/
dietpi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
{
#////////////////////////////////////
# DietPi Cron.Daily script
#
#////////////////////////////////////
#
# Info:
# - Location: /etc/cron.daily/dietpi
#
#////////////////////////////////////
# Assure that whiptail dialogues are skipped, even when the script is called manually, since STDOUT is redirected
export G_INTERACTIVE=0
#----------------------------------------------------------------
# Main Loop
#----------------------------------------------------------------
# Sync system time if mode 2 (daily) is detected
grep -q '^[[:blank:]]*CONFIG_NTP_MODE=2' /boot/dietpi.txt && /boot/dietpi/func/run_ntpd 1
#----------------------------------------------------------------
# Check for DietPi and/or APT updates
APT_UPDATE_MODE=$(sed -n '/^[[:blank:]]*CONFIG_CHECK_APT_UPDATES=/{s/^[^=]*=//p;q}' /boot/dietpi.txt)
if grep -q '^[[:blank:]]*CONFIG_CHECK_DIETPI_UPDATES=1' /boot/dietpi.txt
then
/boot/dietpi/dietpi-update 2
[[ $APT_UPDATE_MODE == 2 && -f '/run/dietpi/.update_available' ]] && { . /boot/dietpi/func/dietpi-globals; G_AGUP -f; }
elif [[ $APT_UPDATE_MODE != 0 ]]
then
. /boot/dietpi/func/dietpi-globals
G_AGUP -f
fi
# Apply APT upgrades if chosen and available
[[ $APT_UPDATE_MODE == 2 && -f '/run/dietpi/.apt_updates' ]] && apt-get -qq upgrade &> /var/tmp/dietpi/logs/dietpi-upgrade_apt.log
#----------------------------------------------------------------
# Sync DietPi-RAMlog to disk: https://github.com/MichaIng/DietPi/issues/4884
systemctl -q is-enabled dietpi-ramlog 2> /dev/null && /boot/dietpi/func/dietpi-ramlog 1
#----------------------------------------------------------------
# Refresh DietPi MOTD
if [[ ! -f '/boot/dietpi/.dietpi-banner' ]] || grep -q '^[[:blank:]]*aENABLED\[12\]=1' /boot/dietpi/.dietpi-banner
then
[[ -f '/run/dietpi/.dietpi_motd' ]] && rm /run/dietpi/.dietpi_motd
curl -sSfL 'https://dietpi.com/motd' -o /run/dietpi/.dietpi_motd
fi
#----------------------------------------------------------------
# DietPi-Backup daily
if [[ -f '/boot/dietpi/.dietpi-backup_settings' ]] && grep -q '^[[:blank:]]*DAILY_BACKUP=1' /boot/dietpi/.dietpi-backup_settings
then
/boot/dietpi/dietpi-backup 1
fi
#----------------------------------------------------------------
# DietPi-Sync daily
if [[ -f '/boot/dietpi/.dietpi-sync_settings' ]] && grep -q '^[[:blank:]]*SYNC_CRONDAILY=1' /boot/dietpi/.dietpi-sync_settings
then
/boot/dietpi/dietpi-sync 1
fi
#----------------------------------------------------------------
exit
#----------------------------------------------------------------
} > /dev/null