mirror of https://github.com/armbian/build.git
Bsp services RFC (#1015)
* Basic armbian services RFC - tested building and upgrade - armbian-optimize-hardware and armbian-setup-hardware have still the same content * fix permissions * Forther renaming and small fixes * Odroid C2 NEXT tiny config adjustement to remove errros from bootup and moving u-boot to 2018.05 * More cleanings * permissions fix * More cleanup ... * permi * Remove few Ubuntu related things, fix permissions * Further mini improvements * Fix logrotate compression and permission issues * Bugfix * Wrong services setup at package install. fixing * RAM logging: workaround for older kernel/btrfs driver versions * Renaming services, proper config for zram, few bugfixes. * Various fixes * Various fixes * No $TMPFILE needed here * Various fixes * Lower this so boards with low memory can use it too * Various fixes * Adjust logfile to armbian-hardware-monitor.log * Remove swap file creation * Fix permissions in all logrotate configs if needed. * Prevent loading parallel printer port drivers which we don't need here.
This commit is contained in:
parent
ea4723a445
commit
fc07886a1d
|
|
@ -1589,8 +1589,8 @@ CONFIG_OF_IRQ=y
|
|||
CONFIG_OF_NET=y
|
||||
CONFIG_OF_MDIO=y
|
||||
CONFIG_OF_RESERVED_MEM=y
|
||||
# CONFIG_OF_OVERLAY is not set
|
||||
# CONFIG_PARPORT is not set
|
||||
CONFIG_OF_OVERLAY=m
|
||||
CONFIG_PARPORT=m
|
||||
CONFIG_BLK_DEV=y
|
||||
CONFIG_BLK_DEV_NULL_BLK=m
|
||||
CONFIG_ZRAM=m
|
||||
|
|
|
|||
|
|
@ -166,7 +166,7 @@ case $RELEASE in
|
|||
;;
|
||||
|
||||
xenial)
|
||||
PACKAGE_LIST_RELEASE="man-db wget nano zram-config"
|
||||
PACKAGE_LIST_RELEASE="man-db wget nano"
|
||||
PACKAGE_LIST_DESKTOP+=" paman libgcr-3-common gcj-jre-headless paprefs numix-icon-theme"
|
||||
PACKAGE_LIST_DESKTOP_RECOMMENDS+=" chromium-browser language-selector-gnome system-config-printer-common system-config-printer-gnome"
|
||||
;;
|
||||
|
|
@ -178,7 +178,7 @@ case $RELEASE in
|
|||
;;
|
||||
|
||||
bionic)
|
||||
PACKAGE_LIST_RELEASE="man-db zram-config less kbd net-tools netcat-openbsd gnupg2 dirmngr nano wget"
|
||||
PACKAGE_LIST_RELEASE="man-db less kbd net-tools netcat-openbsd gnupg2 dirmngr nano wget"
|
||||
PACKAGE_LIST_DESKTOP+=" xserver-xorg-input-all paprefs dbus-x11"
|
||||
PACKAGE_LIST_DESKTOP_RECOMMENDS+=" chromium-browser system-config-printer-common system-config-printer language-selector-gnome"
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -51,6 +51,13 @@ install_common()
|
|||
# remove Ubuntu's legal text
|
||||
[[ -f $SDCARD/etc/legal ]] && rm $SDCARD/etc/legal
|
||||
|
||||
# Prevent loading paralel printer port drivers which we don't need here.Suppress boot error if kernel modules are absent
|
||||
if [[ -f $SDCARD/etc/modules-load.d/cups-filters.conf ]]; then
|
||||
sed "s/^lp/#lp/" -i $SDCARD/etc/modules-load.d/cups-filters.conf
|
||||
sed "s/^ppdev/#ppdev/" -i $SDCARD/etc/modules-load.d/cups-filters.conf
|
||||
sed "s/^parport_pc/#parport_pc/" -i $SDCARD/etc/modules-load.d/cups-filters.conf
|
||||
fi
|
||||
|
||||
# console fix due to Debian bug
|
||||
sed -e 's/CHARMAP=".*"/CHARMAP="'$CONSOLE_CHAR'"/g' -i $SDCARD/etc/default/console-setup
|
||||
|
||||
|
|
@ -150,7 +157,7 @@ install_common()
|
|||
[[ $(type -t family_tweaks) == function ]] && family_tweaks
|
||||
|
||||
# enable additional services
|
||||
chroot $SDCARD /bin/bash -c "systemctl --no-reload enable firstrun.service resize2fs.service armhwinfo.service log2ram.service firstrun-config.service >/dev/null 2>&1"
|
||||
chroot $SDCARD /bin/bash -c "systemctl --no-reload enable armbian-firstrun.service armbian-firstrun-config.service armbian-zram-config.service armbian-hardware-optimize.service armbian-ramlog.service armbian-resize-filesystem.service armbian-hardware-monitor.service >/dev/null 2>&1"
|
||||
|
||||
# copy "first run automated config, optional user configured"
|
||||
cp $SRC/packages/bsp/armbian_first_run.txt.template $SDCARD/boot/armbian_first_run.txt.template
|
||||
|
|
@ -219,6 +226,13 @@ install_distribution_specific()
|
|||
display_alert "Applying distribution specific tweaks for" "$RELEASE" "info"
|
||||
case $RELEASE in
|
||||
jessie)
|
||||
if [[ -z $NM_IGNORE_DEVICES ]]; then
|
||||
echo "# Network Manager under Jessie doesn't work properly. Workaround" >> $SDCARD/etc/network/interfaces.d/eth0.conf
|
||||
echo "auto eth0" >> $SDCARD/etc/network/interfaces.d/eth0.conf
|
||||
echo "iface eth0 inet dhcp" >> $SDCARD/etc/network/interfaces.d/eth0.conf
|
||||
echo "[keyfile]" >> $SDCARD/etc/NetworkManager/NetworkManager.conf
|
||||
echo "unmanaged-devices=interface-name:eth0" >> $SDCARD/etc/NetworkManager/NetworkManager.conf
|
||||
fi
|
||||
;;
|
||||
|
||||
xenial)
|
||||
|
|
|
|||
|
|
@ -52,6 +52,43 @@ create_board_package()
|
|||
rm /etc/network/interfaces
|
||||
mv /etc/network/interfaces.tmp /etc/network/interfaces
|
||||
fi
|
||||
# disable deprecated services
|
||||
systemctl disable armhwinfo.service log2ram.service >/dev/null 2>&1
|
||||
#
|
||||
[ -f "/etc/profile.d/activate_psd_user.sh" ] && rm /etc/profile.d/activate_psd_user.sh
|
||||
[ -f "/etc/profile.d/check_first_login.sh" ] && rm /etc/profile.d/check_first_login.sh
|
||||
[ -f "/etc/profile.d/check_first_login_reboot.sh" ] && rm /etc/profile.d/check_first_login_reboot.sh
|
||||
[ -f "/etc/profile.d/ssh-title.sh" ] && rm /etc/profile.d/ssh-title.sh
|
||||
#
|
||||
[ -f "/etc/update-motd.d/10-header" ] && rm /etc/update-motd.d/10-header
|
||||
[ -f "/etc/update-motd.d/30-sysinfo" ] && rm /etc/update-motd.d/30-sysinfo
|
||||
[ -f "/etc/update-motd.d/35-tips" ] && rm /etc/update-motd.d/35-tips
|
||||
[ -f "/etc/update-motd.d/40-updates" ] && rm /etc/update-motd.d/40-updates
|
||||
[ -f "/etc/update-motd.d/98-autoreboot-warn" ] && rm /etc/update-motd.d/98-autoreboot-warn
|
||||
[ -f "/etc/update-motd.d/99-point-to-faq" ] && rm /etc/update-motd.d/99-point-to-faq
|
||||
# Remove Ubuntu junk
|
||||
[ -f "/etc/update-motd.d/50-motd-news" ] && rm /etc/update-motd.d/50-motd-news
|
||||
[ -f "/etc/update-motd.d/80-esm" ] && rm /etc/update-motd.d/80-esm
|
||||
[ -f "/etc/update-motd.d/80-livepatch" ] && rm /etc/update-motd.d/80-livepatch
|
||||
# Remove distro unattended-upgrades config
|
||||
[ -f "/etc/apt/apt.conf.d/50unattended-upgrades" ] && rm /etc/apt/apt.conf.d/50unattended-upgrades
|
||||
#
|
||||
[ -f "/etc/apt/apt.conf.d/02compress-indexes" ] && rm /etc/apt/apt.conf.d/02compress-indexes
|
||||
[ -f "/etc/apt/apt.conf.d/02periodic" ] && rm /etc/apt/apt.conf.d/02periodic
|
||||
[ -f "/etc/apt/apt.conf.d/no-languages" ] && rm /etc/apt/apt.conf.d/no-languages
|
||||
[ -f "/etc/cron.daily/log2ram" ] && rm /etc/cron.daily/log2ram
|
||||
[ -f "/etc/default/log2ram.dpkg-dist" ] && rm /etc/default/log2ram.dpkg-dist
|
||||
[ -f "/etc/init.d/armhwinfo" ] && rm /etc/init.d/armhwinfo
|
||||
[ -f "/etc/init.d/firstrun" ] && rm /etc/init.d/firstrun
|
||||
[ -f "/etc/init.d/resize2fs" ] && rm /etc/init.d/resize2fs
|
||||
[ -f "/lib/systemd/system/firstrun-config.service" ] && rm /lib/systemd/system/firstrun-config.service
|
||||
[ -f "/lib/systemd/system/firstrun.service" ] && rm /lib/systemd/system/firstrun.service
|
||||
[ -f "/lib/systemd/system/log2ram.service" ] && rm /lib/systemd/system/log2ram.service
|
||||
[ -f "/lib/systemd/system/resize2fs.service" ] && rm /lib/systemd/system/resize2fs.service
|
||||
[ -f "/usr/lib/armbian/apt-updates" ] && rm /usr/lib/armbian/apt-updates
|
||||
[ -f "/usr/lib/armbian/firstrun-config.sh" ] && rm /usr/lib/armbian/firstrun-config.sh
|
||||
[ -f "/usr/sbin/log2ram" ] && rm /usr/sbin/log2ram
|
||||
[ -f "/usr/share/log2ram/LICENSE" ] && rm -r /usr/share/log2ram
|
||||
# make a backup since we are unconditionally overwriting this on update
|
||||
[ -f "/etc/default/cpufrequtils" ] && cp /etc/default/cpufrequtils /etc/default/cpufrequtils.dpkg-old
|
||||
dpkg-divert --package linux-${RELEASE}-root-${DEB_BRANCH}${BOARD} --add --rename \
|
||||
|
|
@ -67,7 +104,7 @@ create_board_package()
|
|||
if [ remove = "\$1" ] || [ abort-install = "\$1" ]; then
|
||||
dpkg-divert --package linux-${RELEASE}-root-${DEB_BRANCH}${BOARD} --remove --rename \
|
||||
--divert /etc/mpv/mpv-dist.conf /etc/mpv/mpv.conf
|
||||
systemctl disable log2ram.service armhwinfo.service >/dev/null 2>&1
|
||||
systemctl disable armbian-hardware-monitor.service armbian-hardware-optimize.service armbian-zram-config.service armbian-ramlog.service >/dev/null 2>&1
|
||||
fi
|
||||
exit 0
|
||||
EOF
|
||||
|
|
@ -83,14 +120,16 @@ create_board_package()
|
|||
if [ -f "/boot/bin/$BOARD.bin" ] && [ ! -f "/boot/script.bin" ]; then ln -sf bin/$BOARD.bin /boot/script.bin >/dev/null 2>&1 || cp /boot/bin/$BOARD.bin /boot/script.bin; fi
|
||||
rm -f /usr/local/bin/h3disp /usr/local/bin/h3consumption
|
||||
if [ ! -f "/etc/default/armbian-motd" ]; then
|
||||
cp /etc/default/armbian-motd.dpkg-dist /etc/default/armbian-motd
|
||||
mv /etc/default/armbian-motd.dpkg-dist /etc/default/armbian-motd
|
||||
fi
|
||||
if [ ! -f "/etc/default/log2ram" ]; then
|
||||
cp /etc/default/log2ram.dpkg-dist /etc/default/log2ram
|
||||
if [ ! -f "/etc/default/armbian-ramlog" ]; then
|
||||
mv /etc/default/armbian-ramlog.dpkg-dist /etc/default/armbian-ramlog
|
||||
fi
|
||||
if [ -f "/etc/systemd/system/log2ram.service" ]; then
|
||||
mv /etc/systemd/system/log2ram.service /etc/systemd/system/log2ram-service.dpkg-old
|
||||
if [ ! -f "/etc/default/armbian-zram-config" ]; then
|
||||
mv /etc/default/armbian-zram-config.dpkg-dist /etc/default/armbian-zram-config
|
||||
fi
|
||||
|
||||
systemctl --no-reload enable armbian-hardware-monitor.service armbian-hardware-optimize.service armbian-zram-config.service armbian-ramlog.service >/dev/null 2>&1
|
||||
exit 0
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
// Enable the update/upgrade script (0=disable)
|
||||
APT::Periodic::Enable "1";
|
||||
APT::Periodic::Enable "0";
|
||||
|
||||
// Do "apt-get update" automatically every n-days (0=disable)
|
||||
APT::Periodic::Update-Package-Lists "7";
|
||||
APT::Periodic::Update-Package-Lists "21";
|
||||
|
||||
// Do "apt-get upgrade --download-only" every n-days (0=disable)
|
||||
APT::Periodic::Download-Upgradeable-Packages "0";
|
||||
|
|
@ -11,7 +11,7 @@ APT::Periodic::Download-Upgradeable-Packages "0";
|
|||
// every n-days (0=disabled)
|
||||
// Requires the package "unattended-upgrades" and will write
|
||||
// a log in /var/log/unattended-upgrades
|
||||
APT::Periodic::Unattended-Upgrade "1";
|
||||
APT::Periodic::Unattended-Upgrade "7";
|
||||
|
||||
// Do "apt-get autoclean" every n-days (0=disable)
|
||||
APT::Periodic::AutocleanInterval "21";
|
||||
APT::Periodic::AutocleanInterval "120";
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
Acquire::GzipIndexes "true";
|
||||
Acquire::CompressionTypes::Order:: "gz";
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
// Enable the update/upgrade script (0=disable)
|
||||
APT::Periodic::Enable "1";
|
||||
|
||||
// Do "apt-get update" automatically every n-days (0=disable)
|
||||
APT::Periodic::Update-Package-Lists "7";
|
||||
|
||||
// Do "apt-get upgrade --download-only" every n-days (0=disable)
|
||||
APT::Periodic::Download-Upgradeable-Packages "0";
|
||||
|
||||
// Run the "unattended-upgrade" security upgrade script
|
||||
// every n-days (0=disabled)
|
||||
// Requires the package "unattended-upgrades" and will write
|
||||
// a log in /var/log/unattended-upgrades
|
||||
APT::Periodic::Unattended-Upgrade "1";
|
||||
|
||||
// Do "apt-get autoclean" every n-days (0=disable)
|
||||
APT::Periodic::AutocleanInterval "21";
|
||||
|
|
@ -0,0 +1 @@
|
|||
*/15 * * * root /usr/lib/armbian/armbian-truncate-logs
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
@reboot root /usr/lib/armbian/apt-updates
|
||||
@daily root /usr/lib/armbian/apt-updates
|
||||
@reboot root /usr/lib/armbian/armbian-apt-updates
|
||||
@daily root /usr/lib/armbian/armbian-apt-updates
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
#! /bin/sh
|
||||
/usr/sbin/armbian/armbian-ram-logging write >/dev/null 2>&1
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
#! /bin/sh
|
||||
|
||||
/usr/sbin/log2ram write >/dev/null 2>&1
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
# configuration values for the armbian-ram-logging service
|
||||
#
|
||||
# enable the armbian-ram-logging service?
|
||||
ENABLED=true
|
||||
#
|
||||
# size of the tmpfs mount -- please keep in mind to adjust /etc/default/armbian-zram-config too when increasing
|
||||
SIZE=50M
|
||||
#
|
||||
# use rsync instead of cp -r
|
||||
# requires rsync installed, may provide better performance
|
||||
# due to copying only new and changed files
|
||||
USE_RSYNC=true
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
# configuration values for the armbian-zram-config service
|
||||
#
|
||||
# enable the armbian-zram-config service?
|
||||
ENABLED=true
|
||||
#
|
||||
# size of the partition for ramlog in megabytes
|
||||
SIZE=40
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
# configuration values for the log2ram service
|
||||
#
|
||||
# enable the log2ram service?
|
||||
ENABLED=true
|
||||
#
|
||||
# size of the tmpfs mount
|
||||
SIZE=50M
|
||||
#
|
||||
# use rsync instead of cp -r
|
||||
# requires rsync installed, may provide better performance
|
||||
# due to copying only new and changed files
|
||||
USE_RSYNC=true
|
||||
#
|
||||
|
|
@ -1,4 +1,12 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# acticate profile sync daemon
|
||||
|
||||
if [ -f "${HOME}/.activate_psd" ]; then
|
||||
rm -f ${HOME}/.activate_psd
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# only do this for interactive shells
|
||||
if [ "$-" != "${-#*i}" ]; then
|
||||
printf "\n"
|
||||
if [ -f "/var/run/.reboot_required" ]; then
|
||||
printf "[\e[0;91m Kernel was updated, please reboot\x1B[0m ]\n\n"
|
||||
fi
|
||||
fi
|
||||
|
|
@ -1,4 +1,10 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
. /etc/armbian-release
|
||||
|
||||
|
|
@ -100,8 +106,6 @@ if [ -f /root/.not_logged_in_yet ] && [ -n "$BASH_VERSION" ] && [ "$-" != "${-#*
|
|||
fi
|
||||
# check whether desktop environment has to be considered
|
||||
if [ "$DESKTOPDETECT" = nodm ] && [ -n "$RealName" ] ; then
|
||||
# enable splash
|
||||
# [[ -f /etc/systemd/system/desktop-splash.service ]] && systemctl --no-reload enable desktop-splash.service >/dev/null 2>&1 && service desktop-splash restart
|
||||
sed -i "s/NODM_USER=\(.*\)/NODM_USER=${RealUserName}/" /etc/default/nodm
|
||||
sed -i "s/NODM_ENABLED=\(.*\)/NODM_ENABLED=true/g" /etc/default/nodm
|
||||
if [[ -f /var/run/resize2fs-reboot ]]; then
|
||||
|
|
@ -135,4 +139,4 @@ if [ -f /root/.not_logged_in_yet ] && [ -n "$BASH_VERSION" ] && [ "$-" != "${-#*
|
|||
printf "\e[0;91mPlease reboot the system now \x1B[0m \n\n"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
if [ -n "$PS1" ] && ( [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] ); then
|
||||
tput tsl > /dev/null
|
||||
if [ "$?" -eq 0 ]; then
|
||||
echo `tput tsl` `whoami`@`hostname` `tput fsl`
|
||||
fi
|
||||
fi
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# only do this for interactive shells
|
||||
if [ "$-" != "${-#*i}" ]; then
|
||||
printf "\n"
|
||||
if [ -f "/var/run/.reboot_required" ]; then
|
||||
printf "[\e[0;91m Kernel was updated, please reboot\x1B[0m ]\n\n"
|
||||
fi
|
||||
fi
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
if [ -n "$PS1" ] && ( [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ] ); then
|
||||
tput tsl > /dev/null
|
||||
if [ "$?" -eq 0 ]; then
|
||||
echo `tput tsl` `whoami`@`hostname` `tput fsl`
|
||||
fi
|
||||
fi
|
||||
|
|
@ -1,6 +1,12 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# DO NOT EDIT THIS FILE
|
||||
# DO NOT EDIT THIS FILE but add config options to /etc/default/armbian-motd
|
||||
# any changes will be lost on board support package update
|
||||
|
||||
THIS_SCRIPT="header"
|
||||
|
|
@ -1,7 +1,14 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# 30-sysinfo - generate the system information
|
||||
# Copyright (c) 2015-2017 Igor Pecovnik
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
#
|
||||
|
||||
# DO NOT EDIT THIS FILE but add config options to /etc/default/armbian-motd
|
||||
# generate system information
|
||||
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
|
|
@ -10,7 +17,6 @@ MOTD_DISABLE=""
|
|||
STORAGE=/dev/sda1
|
||||
SHOW_IP_PATTERN="^[ewr].*|^br.*|^lt.*|^umts.*"
|
||||
|
||||
# This file is overwritten on upgrade. Do overrides here:
|
||||
[[ -f /etc/default/armbian-motd ]] && . /etc/default/armbian-motd
|
||||
|
||||
for f in $MOTD_DISABLE; do
|
||||
|
|
@ -178,5 +184,4 @@ display "Usage of /" "$root_usage" "90" "1" "%" " of $root_total"
|
|||
display "storage/" "$storage_usage" "90" "1" "%" " of $storage_total"
|
||||
display "Battery" "$battery_percent" "20" "1" "%" "$status_battery_text"
|
||||
echo ""
|
||||
echo ""
|
||||
|
||||
echo ""
|
||||
|
|
@ -1,6 +1,12 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# DO NOT EDIT THIS FILE
|
||||
# DO NOT EDIT THIS FILE but add config options to /etc/default/armbian-motd
|
||||
# any changes will be lost on board support package update
|
||||
|
||||
THIS_SCRIPT="tips"
|
||||
|
|
@ -1,6 +1,12 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# DO NOT EDIT THIS FILE
|
||||
# DO NOT EDIT THIS FILE but add config options to /etc/default/armbian-motd
|
||||
# any changes will be lost on board support package update
|
||||
|
||||
THIS_SCRIPT="updates"
|
||||
|
|
@ -1,6 +1,12 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# DO NOT EDIT THIS FILE
|
||||
# DO NOT EDIT THIS FILE but add config options to /etc/default/armbian-motd
|
||||
# any changes will be lost on board support package update
|
||||
|
||||
THIS_SCRIPT="armbian-config"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# DO NOT EDIT THIS FILE
|
||||
# any changes will be lost on board support package update
|
||||
|
|
@ -1,6 +1,12 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# DO NOT EDIT THIS FILE
|
||||
# DO NOT EDIT THIS FILE but add config options to /etc/default/armbian-motd
|
||||
# any changes will be lost on board support package update
|
||||
|
||||
THIS_SCRIPT="point-to-faq"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
# Armbian firstrun config service
|
||||
# Armbian firstrun configuration service
|
||||
# This service will run in parallel with other services
|
||||
|
||||
[Unit]
|
||||
|
|
@ -11,7 +11,7 @@ ConditionPathExists=/root/.not_logged_in_yet
|
|||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/bin/bash /usr/lib/armbian/firstrun-config.sh
|
||||
ExecStart=/usr/lib/armbian/armbian-firstrun-config
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -10,7 +10,7 @@ Before=getty.target system-getty.slice
|
|||
[Service]
|
||||
Type=simple
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/bin/bash /etc/init.d/firstrun start
|
||||
ExecStart=/usr/lib/armbian/armbian-firstrun start
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# Armbian hardware monitor service
|
||||
# Detects and sets various features on boot
|
||||
# This service may block the boot process for up to 2 minutes
|
||||
|
||||
[Unit]
|
||||
Description=Armbian hardware monitoring
|
||||
Before=basic.target
|
||||
After=sysinit.target local-fs.target
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/lib/armbian/armbian-hardware-monitor start
|
||||
ExecStop=/usr/lib/armbian/armbian-hardware-monitor stop
|
||||
RemainAfterExit=yes
|
||||
TimeoutStartSec=2min
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
# Armbian hardware optimization service
|
||||
# Apply optimisations
|
||||
# This service may block the boot process for up to 2 minutes
|
||||
|
||||
[Unit]
|
||||
Description=Armbian hardware optimization
|
||||
Before=basic.target
|
||||
After=sysinit.target local-fs.target armbian-hardware-monitor.target
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/lib/armbian/armbian-hardware-optimization start
|
||||
ExecStop=/usr/lib/armbian/armbian-hardware-optimization stop
|
||||
RemainAfterExit=yes
|
||||
TimeoutStartSec=2min
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
|
|
@ -1,17 +1,19 @@
|
|||
# Armbian ramlog service
|
||||
|
||||
[Unit]
|
||||
Description=Armbian enhanced Log2Ram
|
||||
Description=Armbian memory supported logging
|
||||
DefaultDependencies=no
|
||||
Before=rsyslog.service syslog.target systemd-journald.service sysinit.target shutdown.target
|
||||
After=local-fs.target
|
||||
After=armbian-zram-config.service
|
||||
Conflicts=shutdown.target
|
||||
RequiresMountsFor=/var/log /var/log.hdd
|
||||
IgnoreOnIsolate=yes
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/sbin/log2ram start
|
||||
ExecStop=/usr/sbin/log2ram stop
|
||||
ExecReload=/usr/sbin/log2ram write
|
||||
ExecStart=/usr/lib/armbian/armbian-ramlog start
|
||||
ExecStop=/usr/lib/armbian/armbian-ramlog stop
|
||||
ExecReload=/usr/lib/armbian/armbian-ramlog write
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
# Armbian resize2fs service
|
||||
# Armbian resize filesystem service
|
||||
# Resizes partition and filesystem on first/second boot
|
||||
# This service may block the boot process for up to 5 minutes
|
||||
# This service may block the boot process for up to 3 minutes
|
||||
|
||||
[Unit]
|
||||
Description=Armbian filesystem resize service
|
||||
Description=Armbian filesystem resize
|
||||
Before=basic.target
|
||||
After=sysinit.target local-fs.target
|
||||
DefaultDependencies=no
|
||||
|
|
@ -11,8 +11,8 @@ DefaultDependencies=no
|
|||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/bin/bash /etc/init.d/resize2fs start
|
||||
TimeoutStartSec=5min
|
||||
ExecStart=/usr/lib/armbian/armbian-resize-filesystem start
|
||||
TimeoutStartSec=3min
|
||||
|
||||
[Install]
|
||||
WantedBy=basic.target
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
# Armbian ZRAM configuration service
|
||||
# Create 5 compressed block devices
|
||||
|
||||
[Unit]
|
||||
Description=Armbian ZRAM config
|
||||
DefaultDependencies=no
|
||||
Before=rsyslog.service syslog.target systemd-journald.service sysinit.target shutdown.target armbian-ramlog.target
|
||||
After=local-fs.target
|
||||
Conflicts=shutdown.target
|
||||
RequiresMountsFor=/var/log /var/log.hdd
|
||||
IgnoreOnIsolate=yes
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/lib/armbian/armbian-zram-config start
|
||||
ExecStop=/usr/lib/armbian/armbian-zram-config stop
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=sysinit.target
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
#
|
||||
# - toggle boot verbosity (works)
|
||||
# - monitoring mode: continually print monitoring info (WiP)
|
||||
# - uploading /var/log/armhwinfo.log to online pastebin service
|
||||
# - uploading /var/log/armbian-hardware-monitor.log to online pastebin service
|
||||
#
|
||||
# Without arguments called it should present a simple user
|
||||
# interface that guides through:
|
||||
|
|
@ -146,7 +146,7 @@ ParseOptions() {
|
|||
exit 0
|
||||
;;
|
||||
u)
|
||||
# Upload /var/log/armhwinfo.log with additional support info
|
||||
# Upload /var/log/armbian-hardware-monitor.log with additional support info
|
||||
fping ix.io 2>/dev/null | grep -q alive || \
|
||||
(echo -e "\nNetwork/firewall problem detected. Not able to upload debug info.\nPlease fix this or use \"-U\" instead and upload ${BOLD}whole output${NC} manually\n" >&2 ; exit 1)
|
||||
which curl >/dev/null 2>&1 || apt-get -f -qq -y install curl
|
||||
|
|
@ -258,7 +258,7 @@ DisplayUsage() {
|
|||
echo -e " armbianmonitor ${BOLD}-N${NC} provides simple CLI network monitoring - fixed-line output"
|
||||
echo -e " armbianmonitor ${BOLD}-p${NC} tries to install cpuminer for performance measurements"
|
||||
echo -e " armbianmonitor ${BOLD}-r${NC} tries to install RPi-Monitor"
|
||||
echo -e " armbianmonitor ${BOLD}-u${NC} tries to upload armhwinfo.log for support purposes"
|
||||
echo -e " armbianmonitor ${BOLD}-u${NC} tries to upload armbian-hardware-monitor.log for support purposes"
|
||||
echo -e " armbianmonitor ${BOLD}-v${NC} tries to verify installed package integrity\n"
|
||||
echo -e "############################################################################\n"
|
||||
} # DisplayUsage
|
||||
|
|
@ -808,7 +808,7 @@ gwYNGjRo0KBBw1eEfwH4UoBHAKAAAA==" | base64 --decode | tar xzf -
|
|||
} # PatchRPiMonitor_for_sun8i
|
||||
|
||||
CollectSupportInfo() {
|
||||
[[ -s /var/log/armhwinfo.log ]] && cat /var/log/armhwinfo.log || zcat /var/log/armhwinfo.log.1.gz
|
||||
[[ -s /var/log/armbian-hardware-monitor.log ]] && cat /var/log/armbian-hardware-monitor.log || zcat /var/log/armbian-hardware-monitor.log.1.gz
|
||||
[[ -f /boot/armbianEnv.txt ]] && LOGLEVEL=$(awk -F'=' '/^verbosity/ {print $2}' /boot/armbianEnv.txt) || LOGLEVEL=1
|
||||
if [ ${LOGLEVEL} -gt 4 ]; then
|
||||
VERBOSE='-v'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# Functions:
|
||||
#
|
||||
# show_motd_warning
|
||||
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
my_name="${0##*/}"
|
||||
Log=/var/log/armbian-services.log
|
||||
|
||||
show_motd_warning() {
|
||||
cat > /etc/update-motd.d/90-warning <<EOT
|
||||
#!/bin/bash
|
||||
echo -e "\e[0;91mAttention:\x1B[0m $1\n"
|
||||
rm "\$0"
|
||||
EOT
|
||||
chmod +x /etc/update-motd.d/90-warning
|
||||
} # show_motd_warning
|
||||
|
|
@ -1,24 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: firstrun
|
||||
# Required-Start: $all
|
||||
# Required-Stop:
|
||||
# Should-Start: armhwinfo
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Armbian first run tasks
|
||||
# Description: Something needs to be done when is
|
||||
# starting at first time.
|
||||
### END INIT INFO
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
. /etc/armbian-release
|
||||
. /etc/os-release
|
||||
. /lib/init/vars.sh
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
Log=/var/log/armhwinfo.log
|
||||
. /usr/lib/armbian/armbian-common
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
|
|
@ -26,20 +18,13 @@ case "$1" in
|
|||
# Run a q&d benchmark to be able to identify cards way too slow easily
|
||||
echo -e "\n### quick iozone test:$(cd /root; iozone -e -I -a -s 1M -r 4k -i 0 -i 1 -i 2 | grep '^ 1024' | sed 's/ 1024 //')" >> $Log
|
||||
|
||||
# workaround for AP6212a under mainline kernel
|
||||
#if [ -n "$(lsmod | grep brcmfmac)" ] && [ -z "$(dmesg | grep brcmf | grep Firm)" ]; then
|
||||
# cp /lib/firmware/brcm/brcmfmac43430-sdio.bin /lib/firmware/brcm/brcmfmac43430-sdio.bin.bak
|
||||
# cp /lib/firmware/ap6212/fw_bcm43438a1.bin /lib/firmware/brcm/brcmfmac43430-sdio.bin
|
||||
# rmmod brcmfmac
|
||||
# modprobe brcmfmac
|
||||
#fi
|
||||
# Bluetooth tweaks
|
||||
|
||||
# BT tweaks
|
||||
case ${BOARD} in
|
||||
cubietruck)
|
||||
systemctl enable brcm40183-patch && service brcm40183-patch start
|
||||
;;
|
||||
bananapim2zero|bananapim2plus|nanopiair|nanopim1plus|orangepizeroplus2*|orangepiwin|nanopineoplus2|nanopik2)
|
||||
bananapim2zero|bananapim2plus|nanopiair|nanopim1plus|orangepizeroplus2*|orangepiwin|nanopineoplus2|nanopik2)
|
||||
update-rc.d ap6212-bluetooth defaults
|
||||
;;
|
||||
cubox-i)
|
||||
|
|
@ -61,29 +46,6 @@ case "$1" in
|
|||
read entropy_after </proc/sys/kernel/random/entropy_avail
|
||||
echo -e "\n### [firstrun] Recreated SSH keys (entropy: ${entropy_before} ${entropy_after})" >>${Log}
|
||||
|
||||
# set up swap preferring zram if available over swapfile
|
||||
dpkg -l | grep -q 'zram-config'
|
||||
case $? in
|
||||
0)
|
||||
echo -e "\n### [firstrun] Skipped swapfile creation since zram is available" >>${Log}
|
||||
;;
|
||||
*)
|
||||
FREESIZE=$(( $(findmnt --target / -n -o AVAIL -b) / 1048576 )) # MiB
|
||||
SWAPFILE=/var/swap
|
||||
if [[ ! -f $SWAPFILE && $FREESIZE -gt 132 ]]; then
|
||||
fallocate -l 128M $SWAPFILE || dd if=/dev/zero of=$SWAPFILE bs=1M count=128 status=noxfer
|
||||
chown root:root $SWAPFILE
|
||||
chmod 0600 $SWAPFILE
|
||||
mkswap $SWAPFILE
|
||||
swapon $SWAPFILE
|
||||
grep -q swap /etc/fstab || echo "$SWAPFILE none swap sw 0 0" >> /etc/fstab
|
||||
echo -e "\n### [firstrun] Created 128MB emergency swap as $SWAPFILE" >>${Log}
|
||||
fi
|
||||
# set vm.swappiness to 0 (even with a btrfs rootfs)
|
||||
grep -q 'vm.swappiness' /etc/sysctl.conf || echo "vm.swappiness=0" >> /etc/sysctl.conf
|
||||
;;
|
||||
esac
|
||||
|
||||
# get rid of purple background color in newt apps whiptail, partimage, debconf ... Reverting to Debian look.
|
||||
sed -e 's/magenta/blue/g' -i /etc/newt/palette
|
||||
|
||||
|
|
@ -146,7 +108,7 @@ case "$1" in
|
|||
[[ -f /boot/armbianEnv.txt ]] && sed -i "s/^ethaddr=.*/ethaddr=$MACADDR/" /boot/armbianEnv.txt
|
||||
esac
|
||||
|
||||
systemctl disable firstrun
|
||||
systemctl disable armbian-firstrun
|
||||
exit 0
|
||||
;;
|
||||
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
# TODO: convert this to use nmcli, improve network interfaces names handling (wl*, en*)
|
||||
# or drop support for this and remove all related files
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# Function calculates number of bit in a netmask
|
||||
#
|
||||
|
|
@ -134,5 +137,4 @@ do_firstrun_automated_user_configuration()
|
|||
|
||||
do_firstrun_automated_user_configuration
|
||||
|
||||
exit 0
|
||||
|
||||
exit 0
|
||||
|
|
@ -0,0 +1,187 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# Functions:
|
||||
#
|
||||
# collect_information
|
||||
# prepare_temp_monitoring
|
||||
# log_hardware_info
|
||||
# get_flash_information
|
||||
# check_sd_card_speed
|
||||
|
||||
|
||||
# Read in basic OS image information
|
||||
. /etc/armbian-release
|
||||
# and script configuration
|
||||
. /usr/lib/armbian/armbian-common
|
||||
|
||||
collect_information() {
|
||||
ifconfig | grep -q eth0 || (ifconfig eth0 up ; sleep 2)
|
||||
TMPFILE=$(mktemp /tmp/${0##*/}.XXXXXX)
|
||||
trap "sleep 1 ; rm \"${TMPFILE}\" ; exit 0" 0 1 2 3 15
|
||||
CPU_ARCH=$(lscpu | awk '/Architecture/ {print $2}')
|
||||
DISTRO_ARCH=$(dpkg --print-architecture)
|
||||
KERNELID=$(uname -r)
|
||||
dmesg >"${TMPFILE}"
|
||||
} # collect_information
|
||||
|
||||
prepare_temp_monitoring() {
|
||||
# still an ugly hack but better do it just once at startup instead of every login
|
||||
[ -d /etc/armbianmonitor/datasources ] || mkdir -p -m775 /etc/armbianmonitor/datasources
|
||||
|
||||
# PMIC check
|
||||
if [[ -f /sys/power/axp_pmu/pmu/temp ]]; then
|
||||
ln -fs /sys/power/axp_pmu/pmu/temp /etc/armbianmonitor/datasources/pmictemp
|
||||
elif [[ -f /sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034//temp1_input ]]; then
|
||||
ln -fs /sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input \
|
||||
/etc/armbianmonitor/datasources/pmictemp
|
||||
elif [[ -f /sys/devices/b0170000.i2c/i2c-0/0-0065/atc2603c-hwmon.0/ic_temperature ]]; then
|
||||
ln -fs /sys/devices/b0170000.i2c/i2c-0/0-0065/atc2603c-hwmon.0/ic_temperature \
|
||||
/etc/armbianmonitor/datasources/pmictemp
|
||||
elif [[ -f /sys/class/axppower/ic_temp ]]; then
|
||||
ln -fs /sys/class/axppower/ic_temp /etc/armbianmonitor/datasources/pmictemp
|
||||
fi
|
||||
|
||||
# SoC temp: check sun7i legacy exception first, then standard path(s)
|
||||
if [[ -d "/sys/devices/platform/a20-tp-hwmon" ]]; then
|
||||
# sun7i legacy
|
||||
ln -fs /sys/devices/platform/a20-tp-hwmon/temp1_input /etc/armbianmonitor/datasources/soctemp
|
||||
elif [[ -f /sys/class/hwmon/hwmon0/temp1_input ]]; then
|
||||
# usual convention with modern kernels
|
||||
ln -fs /sys/class/hwmon/hwmon0/temp1_input /etc/armbianmonitor/datasources/soctemp
|
||||
else
|
||||
# all other boards/kernels use the same sysfs node except of Actions Semi S500:
|
||||
[[ ${BOARDFAMILY} == s500 ]] && THERMAL_ZONE="thermal_zone1" || THERMAL_ZONE="thermal_zone0"
|
||||
ln -fs /sys/devices/virtual/thermal/${THERMAL_ZONE}/temp /etc/armbianmonitor/datasources/soctemp
|
||||
fi
|
||||
# remove the soctemp node on platforms where kernel support is not yet ready for thermal readouts
|
||||
cat /etc/armbianmonitor/datasources/soctemp >/dev/null 2>&1 || rm /etc/armbianmonitor/datasources/soctemp
|
||||
} # prepare_temp_monitoring
|
||||
|
||||
log_hardware_info() {
|
||||
Log=/var/log/armbian-hardware-monitor.log
|
||||
[ -f "/etc/logrotate.d/${0##*/}" ] || \
|
||||
echo -e "${Log} {\n rotate 12\n weekly\n compress\n missingok\n notifempty\n}" \
|
||||
> "/etc/logrotate.d/${0##*/}" ; chmod 644 "/etc/logrotate.d/${0##*/}"
|
||||
if [ -f ${Log} ]; then
|
||||
echo -e "\n\n\n$(date) | ${BOARD_NAME} | ${VERSION} | ${DISTRO_ARCH} | ${CPU_ARCH} | ${KERNELID}" >>${Log}
|
||||
else
|
||||
echo "$(date) | ${BOARD_NAME} | ${VERSION} | ${DISTRO_ARCH} | ${CPU_ARCH} | ${KERNELID}" >>${Log}
|
||||
chmod 644 ${Log}
|
||||
fi
|
||||
echo -e "\n### dmesg:\n" >>${Log}
|
||||
cat "${TMPFILE}" >>${Log}
|
||||
echo -e "\n### armbian-release:\n" >>${Log}
|
||||
cat /etc/armbian-release >>${Log}
|
||||
echo -e "\n### boot environment:\n" >>${Log}
|
||||
cat /boot/armbianEnv.txt >>${Log} 2>/dev/null || grep -v "^#" /boot/boot.ini | sed '/^\s*$/d' >>${Log}
|
||||
echo -e "\n### lsusb:\n" >>${Log}
|
||||
lsusb 2>/dev/null >>${Log}
|
||||
echo -e "\n### lscpu:\n" >>${Log}
|
||||
lscpu >>${Log}
|
||||
echo -e "\n### cpuinfo:\n" >>${Log}
|
||||
cat /proc/cpuinfo >>${Log}
|
||||
echo -e "\n### meminfo:\n" >>${Log}
|
||||
cat /proc/meminfo >>${Log}
|
||||
if [ -x /sbin/ip ]; then
|
||||
echo -e "\n### ip addr:\n" >>${Log}
|
||||
/sbin/ip r s >>${Log} ; /sbin/ip a >>${Log}
|
||||
echo " " >>${Log}
|
||||
else
|
||||
echo -e "\n### ifconfig:\n" >>${Log}
|
||||
ifconfig >>${Log}
|
||||
fi
|
||||
echo -e "### partitions:\n" >>${Log}
|
||||
egrep -v " ram| zram" /proc/partitions >>${Log}
|
||||
echo -e "\n### df:\n" >>${Log}
|
||||
df -h | egrep '^udev|^tmpfs|^/dev/|log2ram|folder2ram' >>${Log}
|
||||
which zpool >/dev/null 2>&1 && echo -e "\n### zpools:\n\n$(zpool list)\n\n### zfs datasets:\n\n$(zfs list)" >>${Log}
|
||||
echo -e "\n### lsblk:\n" >>${Log}
|
||||
lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,UUID | grep -v "^zram" >>${Log}
|
||||
echo -e "\n### mtab:\n" >>${Log}
|
||||
egrep '^/dev/|\ zfs\ ' /etc/mtab | egrep -v "log2ram|folder2ram" | sort >>${Log}
|
||||
[[ -e /boot/script.bin ]] && echo -e "\n### /boot/script.bin --> $(readlink /boot/script.bin)" >>${Log}
|
||||
get_flash_information >>${Log}
|
||||
(echo -e "\n### Boot system health:\n" >>${Log} ; armbianmonitor -s | egrep "^Time|^[0-9]" >>${Log}) &
|
||||
} # log_hardware_info
|
||||
|
||||
get_flash_information() {
|
||||
# http://www.bunniestudios.com/blog/?page_id=1022
|
||||
find /sys -name oemid | while read Device ; do
|
||||
DeviceNode="${Device%/*}"
|
||||
DeviceName="${DeviceNode##*/}"
|
||||
echo -e "\n### ${DeviceName} info:\n"
|
||||
find "${DeviceNode}" -maxdepth 1 -type f | while read ; do
|
||||
NodeName="${REPLY##*/}"
|
||||
echo -e "$(printf "%20s" ${NodeName}): $(cat "${DeviceNode}/${NodeName}" | tr '\n' " ")"
|
||||
done
|
||||
done
|
||||
} # get_flash_information
|
||||
|
||||
check_sd_card_speed() {
|
||||
# function that checks on 3rd boot whether firstrun script made a quick benchmark
|
||||
# and displays a motd warning when _random_ I/O is below some tresholds.
|
||||
if [ -f /var/log/armbian-hardware-monitor.log ]; then
|
||||
RebootCount=$(grep -c '^### df:' /var/log/armbian-hardware-monitor.log)
|
||||
if [ ${RebootCount} -eq 2 ]; then
|
||||
# check whether iozone data has been collected
|
||||
IozoneResults="$(awk -F" " '/^### quick iozone test/ {print $10"\t"$11}' </var/log/armbian-hardware-monitor.log)"
|
||||
if [ "X${IozoneResults}" != "X" ]; then
|
||||
set ${IozoneResults}
|
||||
Readspeed=$1
|
||||
Writespeed=$2
|
||||
if [ ${Readspeed} -lt 500 -o ${Writespeed} -lt 250 ]; then
|
||||
show_motd_warning "Your SD card seems to be very slow. Please check performance using armbianmonitor -c"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
} # check_sd_card_speed
|
||||
|
||||
case $1 in
|
||||
*start*)
|
||||
# check sd card speed once on 3rd boot too warn for too slow media
|
||||
check_sd_card_speed &
|
||||
|
||||
# prepare correct temperature readouts
|
||||
prepare_temp_monitoring &
|
||||
|
||||
# get hardware information and rely on contents of /etc/armbian-release
|
||||
collect_information
|
||||
|
||||
# display message, log hardware id to file, write log
|
||||
# echo -e "[\e[0;32m ok \x1B[0m] Starting ARM hardware info: ${BOARD_NAME} (${VERSION})"
|
||||
echo $BOARD_NAME >/var/run/machine.id # we should leave this, maybe users depend on it
|
||||
if [ $? -ne 0 ]; then
|
||||
# most probably readonly fs. We'll try to warn the user.
|
||||
show_motd_warning "It seems the rootfs is readonly at the moment. Please check your SD card for errors"
|
||||
fi
|
||||
|
||||
# check whether auto detection override exists and if true use this for machine.id
|
||||
[ -f /root/.machine.id ] && cat /root/.machine.id >/var/run/machine.id
|
||||
log_hardware_info
|
||||
|
||||
;;
|
||||
*stop*)
|
||||
case ${BOARDFAMILY} in
|
||||
sun?i)
|
||||
# redefine green led to blink until shutdown, try to switch OTG port to host
|
||||
(echo heartbeat >/sys/class/leds/*green*/trigger) 2>/dev/null
|
||||
echo 0 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
# some kernel modules are known to crash the kernel on shutdown (an example
|
||||
# is the mass storage gadget module at least on sun7i). We try to unload as
|
||||
# much modules as possible to minimize such situations:
|
||||
/sbin/modprobe -r $(cut -f1 -d' ' </proc/modules)
|
||||
# shutdown logging
|
||||
echo -e "\n### shutdown:\n\n$(iostat -p zram0)\n\n$(vmstat -w)\n\n$(free -h)\n\n$(dmesg | tail -n 100)" >>/var/log/armbian-hardware-monitor.log
|
||||
logger -i -t ${my_name} "Sane shutdown"
|
||||
sync
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,30 +1,25 @@
|
|||
#!/bin/bash
|
||||
### BEGIN INIT INFO
|
||||
# Provides: armhwinfo
|
||||
# Required-Start:
|
||||
# Required-Stop: glibc
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Armbian gathering hardware information
|
||||
### END INIT INFO
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# Functions:
|
||||
#
|
||||
# set_io_scheduler
|
||||
# prepare_board
|
||||
# add_usb_storage_quirks
|
||||
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
my_name="${0##*/}"
|
||||
|
||||
# Read in basic OS image information
|
||||
. /etc/armbian-release
|
||||
|
||||
collect_information() {
|
||||
ifconfig | grep -q eth0 || (ifconfig eth0 up ; sleep 2)
|
||||
TMPFILE=$(mktemp /tmp/${0##*/}.XXXXXX)
|
||||
trap "sleep 1 ; rm \"${TMPFILE}\" ; exit 0" 0 1 2 3 15
|
||||
CPU_ARCH=$(lscpu | awk '/Architecture/ {print $2}')
|
||||
DISTRO_ARCH=$(dpkg --print-architecture)
|
||||
KERNELID=$(uname -r)
|
||||
dmesg >"${TMPFILE}"
|
||||
} # collect_information
|
||||
# and script configuration
|
||||
. /usr/lib/armbian/armbian-common
|
||||
|
||||
set_io_scheduler() {
|
||||
|
||||
for i in $( lsblk -idn -o NAME | grep -v zram ); do
|
||||
read ROTATE </sys/block/$i/queue/rotational
|
||||
case ${ROTATE} in
|
||||
|
|
@ -38,42 +33,14 @@ set_io_scheduler() {
|
|||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
} # set_io_scheduler
|
||||
|
||||
prepare_temp_monitoring() {
|
||||
# still an ugly hack but better do it just once at startup instead of every login
|
||||
[ -d /etc/armbianmonitor/datasources ] || mkdir -p -m775 /etc/armbianmonitor/datasources
|
||||
|
||||
# PMIC check
|
||||
if [[ -f /sys/power/axp_pmu/pmu/temp ]]; then
|
||||
ln -fs /sys/power/axp_pmu/pmu/temp /etc/armbianmonitor/datasources/pmictemp
|
||||
elif [[ -f /sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034//temp1_input ]]; then
|
||||
ln -fs /sys/devices/platform/sunxi-i2c.0/i2c-0/0-0034/temp1_input \
|
||||
/etc/armbianmonitor/datasources/pmictemp
|
||||
elif [[ -f /sys/devices/b0170000.i2c/i2c-0/0-0065/atc2603c-hwmon.0/ic_temperature ]]; then
|
||||
ln -fs /sys/devices/b0170000.i2c/i2c-0/0-0065/atc2603c-hwmon.0/ic_temperature \
|
||||
/etc/armbianmonitor/datasources/pmictemp
|
||||
elif [[ -f /sys/class/axppower/ic_temp ]]; then
|
||||
ln -fs /sys/class/axppower/ic_temp /etc/armbianmonitor/datasources/pmictemp
|
||||
fi
|
||||
|
||||
# SoC temp: check sun7i legacy exception first, then standard path(s)
|
||||
if [[ -d "/sys/devices/platform/a20-tp-hwmon" ]]; then
|
||||
# sun7i legacy
|
||||
ln -fs /sys/devices/platform/a20-tp-hwmon/temp1_input /etc/armbianmonitor/datasources/soctemp
|
||||
elif [[ -f /sys/class/hwmon/hwmon0/temp1_input ]]; then
|
||||
# usual convention with modern kernels
|
||||
ln -fs /sys/class/hwmon/hwmon0/temp1_input /etc/armbianmonitor/datasources/soctemp
|
||||
else
|
||||
# all other boards/kernels use the same sysfs node except of Actions Semi S500:
|
||||
[[ ${BOARDFAMILY} == s500 ]] && THERMAL_ZONE="thermal_zone1" || THERMAL_ZONE="thermal_zone0"
|
||||
ln -fs /sys/devices/virtual/thermal/${THERMAL_ZONE}/temp /etc/armbianmonitor/datasources/soctemp
|
||||
fi
|
||||
# remove the soctemp node on platforms where kernel support is not yet ready for thermal readouts
|
||||
cat /etc/armbianmonitor/datasources/soctemp >/dev/null 2>&1 || rm /etc/armbianmonitor/datasources/soctemp
|
||||
} # prepare_temp_monitoring
|
||||
|
||||
prepare_board() {
|
||||
|
||||
# prevent logrotate from compressing rotated logs when /var/log lives on compressed fs
|
||||
CheckDevice=$(for i in /var/log /var / ; do findmnt -n -o SOURCE $i && break ; done)
|
||||
[ -n "${CheckDevice}" ] && grep "^${CheckDevice}" /etc/mtab | grep -q compress && \
|
||||
|
|
@ -82,6 +49,13 @@ prepare_board() {
|
|||
-e "s/^\s\+delaycompress/\t# delaycompress/" "${ConfigFile}"
|
||||
done
|
||||
|
||||
# remove compression from general config
|
||||
sed -i 's/^compress/#compress/' /etc/logrotate.conf
|
||||
|
||||
# fix permissions in all logrotate configs
|
||||
find /etc/logrotate.d/. -type f | xargs grep -H -c 'su root' | grep 0$ | cut -d':' -f1 | \
|
||||
xargs -L1 sed -i '/{/ i su root syslog' 2> /dev/null
|
||||
|
||||
# tweak ondemand cpufreq governor settings to increase cpufreq with IO load
|
||||
grep -q ondemand /etc/default/cpufrequtils
|
||||
if [ $? -eq 0 ]; then
|
||||
|
|
@ -262,100 +236,14 @@ prepare_board() {
|
|||
esac
|
||||
} # prepare_board
|
||||
|
||||
log_hardware_info() {
|
||||
Log=/var/log/armhwinfo.log
|
||||
[ -f "/etc/logrotate.d/${0##*/}" ] || \
|
||||
echo -e "${Log} {\n rotate 12\n weekly\n compress\n missingok\n notifempty\n}" \
|
||||
> "/etc/logrotate.d/${0##*/}" ; chmod 644 "/etc/logrotate.d/${0##*/}"
|
||||
if [ -f ${Log} ]; then
|
||||
echo -e "\n\n\n$(date) | ${BOARD_NAME} | ${VERSION} | ${DISTRO_ARCH} | ${CPU_ARCH} | ${KERNELID}" >>${Log}
|
||||
else
|
||||
echo "$(date) | ${BOARD_NAME} | ${VERSION} | ${DISTRO_ARCH} | ${CPU_ARCH} | ${KERNELID}" >>${Log}
|
||||
chmod 644 ${Log}
|
||||
fi
|
||||
echo -e "\n### dmesg:\n" >>${Log}
|
||||
cat "${TMPFILE}" >>${Log}
|
||||
echo -e "\n### armbian-release:\n" >>${Log}
|
||||
cat /etc/armbian-release >>${Log}
|
||||
echo -e "\n### boot environment:\n" >>${Log}
|
||||
cat /boot/armbianEnv.txt >>${Log} 2>/dev/null || grep -v "^#" /boot/boot.ini | sed '/^\s*$/d' >>${Log}
|
||||
echo -e "\n### lsusb:\n" >>${Log}
|
||||
lsusb 2>/dev/null >>${Log}
|
||||
echo -e "\n### lscpu:\n" >>${Log}
|
||||
lscpu >>${Log}
|
||||
echo -e "\n### cpuinfo:\n" >>${Log}
|
||||
cat /proc/cpuinfo >>${Log}
|
||||
echo -e "\n### meminfo:\n" >>${Log}
|
||||
cat /proc/meminfo >>${Log}
|
||||
if [ -x /sbin/ip ]; then
|
||||
echo -e "\n### ip addr:\n" >>${Log}
|
||||
/sbin/ip r s >>${Log} ; /sbin/ip a >>${Log}
|
||||
echo " " >>${Log}
|
||||
else
|
||||
echo -e "\n### ifconfig:\n" >>${Log}
|
||||
ifconfig >>${Log}
|
||||
fi
|
||||
echo -e "### partitions:\n" >>${Log}
|
||||
egrep -v " ram| zram" /proc/partitions >>${Log}
|
||||
echo -e "\n### df:\n" >>${Log}
|
||||
df -h | egrep '^udev|^tmpfs|^/dev/|log2ram|folder2ram' >>${Log}
|
||||
which zpool >/dev/null 2>&1 && echo -e "\n### zpools:\n\n$(zpool list)\n\n### zfs datasets:\n\n$(zfs list)" >>${Log}
|
||||
echo -e "\n### lsblk:\n" >>${Log}
|
||||
lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,UUID | grep -v "^zram" >>${Log}
|
||||
echo -e "\n### mtab:\n" >>${Log}
|
||||
egrep '^/dev/|\ zfs\ ' /etc/mtab | egrep -v "log2ram|folder2ram" | sort >>${Log}
|
||||
[[ -e /boot/script.bin ]] && echo -e "\n### /boot/script.bin --> $(readlink /boot/script.bin)" >>${Log}
|
||||
get_flash_information >>${Log}
|
||||
(echo -e "\n### Boot system health:\n" >>${Log} ; armbianmonitor -s | egrep "^Time|^[0-9]" >>${Log}) &
|
||||
} # log_hardware_info
|
||||
|
||||
get_flash_information() {
|
||||
# http://www.bunniestudios.com/blog/?page_id=1022
|
||||
find /sys -name oemid | while read Device ; do
|
||||
DeviceNode="${Device%/*}"
|
||||
DeviceName="${DeviceNode##*/}"
|
||||
echo -e "\n### ${DeviceName} info:\n"
|
||||
find "${DeviceNode}" -maxdepth 1 -type f | while read ; do
|
||||
NodeName="${REPLY##*/}"
|
||||
echo -e "$(printf "%20s" ${NodeName}): $(cat "${DeviceNode}/${NodeName}" | tr '\n' " ")"
|
||||
done
|
||||
done
|
||||
} # get_flash_information
|
||||
|
||||
show_motd_warning() {
|
||||
cat > /etc/update-motd.d/90-warning <<EOT
|
||||
#!/bin/bash
|
||||
echo -e "\e[0;91mAttention:\x1B[0m $1\n"
|
||||
rm "\$0"
|
||||
EOT
|
||||
chmod +x /etc/update-motd.d/90-warning
|
||||
} # show_motd_warning
|
||||
|
||||
check_sd_card_speed() {
|
||||
# function that checks on 3rd boot whether firstrun script made a quick benchmark
|
||||
# and displays a motd warning when _random_ I/O is below some tresholds.
|
||||
if [ -f /var/log/armhwinfo.log ]; then
|
||||
RebootCount=$(grep -c '^### df:' /var/log/armhwinfo.log)
|
||||
if [ ${RebootCount} -eq 2 ]; then
|
||||
# check whether iozone data has been collected
|
||||
IozoneResults="$(awk -F" " '/^### quick iozone test/ {print $10"\t"$11}' </var/log/armhwinfo.log)"
|
||||
if [ "X${IozoneResults}" != "X" ]; then
|
||||
set ${IozoneResults}
|
||||
Readspeed=$1
|
||||
Writespeed=$2
|
||||
if [ ${Readspeed} -lt 800 -o ${Writespeed} -lt 400 ]; then
|
||||
show_motd_warning "Your SD card seems to be very slow. Please check performance using armbianmonitor -c"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
} # check_sd_card_speed
|
||||
|
||||
add_usb_storage_quirks() {
|
||||
|
||||
# check for /boot/armbianEnv.txt existence
|
||||
[ -f /boot/armbianEnv.txt ] || return
|
||||
|
||||
# preserve old contents if existent
|
||||
TMPFILE=$(mktemp /tmp/${0##*/}.XXXXXX)
|
||||
trap "sleep 1 ; rm \"${TMPFILE}\" ; exit 0" 0 1 2 3 15
|
||||
awk -F"=" '/^usbstoragequirks/ {print $2}' </boot/armbianEnv.txt | tr -d -c '[:graph:]' >${TMPFILE}
|
||||
|
||||
# UAS blacklist Norelsys NS1068X and NS1066X since broken. Can be removed once
|
||||
|
|
@ -378,87 +266,18 @@ add_usb_storage_quirks() {
|
|||
if [ -f /sys/module/usb_storage/parameters/quirks ]; then
|
||||
echo ${USBQUIRKS} >/sys/module/usb_storage/parameters/quirks
|
||||
fi
|
||||
|
||||
} # add_usb_storage_quirks
|
||||
|
||||
activate_zram() {
|
||||
# Do not interfere with already present config-zram package
|
||||
dpkg -l | grep -q 'zram-config' && return
|
||||
|
||||
# Load zram module with n instances (one per CPU core, 4 are the maximum)
|
||||
cpu_cores=$(grep -c '^processor' /proc/cpuinfo | sed 's/^0$/1/')
|
||||
[[ ${cpu_cores} -gt 4 ]] && zram_devices=4 || zram_devices=${cpu_cores}
|
||||
module_args="$(modinfo zram | awk -F" " '/num_devices/ {print $2}' | cut -f1 -d:)"
|
||||
[[ -n ${module_args} ]] && modprobe zram ${module_args}=$(( ${zram_devices} + 1 )) || return
|
||||
|
||||
# Use half of the real memory by default --> 1/${ram_divisor}
|
||||
ram_divisor=2
|
||||
mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem")
|
||||
memory_total=$(awk '{printf("%d",$2*1024)}' <<<${mem_info})
|
||||
mem_per_zram_device=$(( ${memory_total} / ${zram_devices} / ${ram_divisor} ))
|
||||
|
||||
for (( i=1; i<=zram_devices; i++ )); do
|
||||
[[ -f /sys/block/zram${i}/comp_algorithm ]] && echo lz4 >/sys/block/zram${i}/comp_algorithm 2>/dev/null
|
||||
echo -n ${mem_per_zram_device} > /sys/block/zram${i}/disksize
|
||||
mkswap /dev/zram${i}
|
||||
swapon -p 5 /dev/zram${i}
|
||||
done
|
||||
echo -e "\n### Activated ${zram_devices} zram swap devices with ${mem_per_zram_device} MB each\n" >>${Log}
|
||||
|
||||
# Dedicate 300 MB (uncompressed) /dev/zram0 device for log2ram and choose most efficient
|
||||
# compression scheme available -- https://patchwork.kernel.org/patch/9918897/
|
||||
for algo in lz4 quicklz zlib brotli zstd ; do
|
||||
echo ${algo} >/sys/block/zram0/comp_algorithm 2>/dev/null
|
||||
done
|
||||
echo -n 314572800 > /sys/block/zram0/disksize
|
||||
mkfs.btrfs -s 1024 -L log2ram /dev/zram0
|
||||
read algo </sys/block/zram0/comp_algorithm
|
||||
echo -e "### Activated log2ram partition with ${algo} compression\n" >>${Log}
|
||||
} # activate_zram
|
||||
|
||||
case $1 in
|
||||
*start*)
|
||||
# set optimal disk scheduler settings
|
||||
set_io_scheduler &
|
||||
|
||||
# check sd card speed once on 3rd boot too warn for too slow media
|
||||
check_sd_card_speed &
|
||||
|
||||
# get hardware information and rely on contents of /etc/armbian-release
|
||||
collect_information
|
||||
|
||||
# hardware preparation
|
||||
prepare_board &
|
||||
prepare_temp_monitoring &
|
||||
# activate_zram &
|
||||
|
||||
# display message, log hardware id to file, write log
|
||||
echo -e "[\e[0;32m ok \x1B[0m] Starting ARM hardware info: ${BOARD_NAME} (${VERSION})"
|
||||
echo $BOARD_NAME >/var/run/machine.id # we should leave this, maybe users depend on it
|
||||
if [ $? -ne 0 ]; then
|
||||
# most probably readonly fs. We'll try to warn the user.
|
||||
show_motd_warning "It seems the rootfs is readonly at the moment. Please check your SD card for errors"
|
||||
fi
|
||||
|
||||
# check whether auto detection override exists and if true use this for machine.id
|
||||
[ -f /root/.machine.id ] && cat /root/.machine.id >/var/run/machine.id
|
||||
log_hardware_info
|
||||
add_usb_storage_quirks
|
||||
;;
|
||||
*stop*)
|
||||
case ${BOARDFAMILY} in
|
||||
sun?i)
|
||||
# redefine green led to blink until shutdown, try to switch OTG port to host
|
||||
(echo heartbeat >/sys/class/leds/*green*/trigger) 2>/dev/null
|
||||
echo 0 > /sys/bus/platform/devices/sunxi_usb_udc/otg_role 2>/dev/null
|
||||
;;
|
||||
esac
|
||||
# some kernel modules are known to crash the kernel on shutdown (an example
|
||||
# is the mass storage gadget module at least on sun7i). We try to unload as
|
||||
# much modules as possible to minimize such situations:
|
||||
/sbin/modprobe -r $(cut -f1 -d' ' </proc/modules)
|
||||
# shutdown logging
|
||||
echo -e "\n### shutdown:\n\n$(iostat -p zram0)\n\n$(vmstat -w)\n\n$(free -h)\n\n$(dmesg | tail -n 100)" >>/var/log/armhwinfo.log
|
||||
logger -i -t ${my_name} "Sane shutdown"
|
||||
sync
|
||||
# add usb quirks
|
||||
add_usb_storage_quirks &
|
||||
;;
|
||||
esac
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
SIZE=40M
|
||||
USE_RSYNC=false
|
||||
ENABLED=false
|
||||
|
||||
[ -f /etc/default/armbian-ramlog ] && . /etc/default/armbian-ramlog
|
||||
|
||||
[ "$ENABLED" != true ] && exit 0
|
||||
|
||||
# don't touch anything below here.
|
||||
|
||||
HDD_LOG=/var/log.hdd/
|
||||
RAM_LOG=/var/log/
|
||||
LOG2RAM_LOG="${HDD_LOG}armbian-ramlog.log"
|
||||
LOG_OUTPUT="tee -a $LOG2RAM_LOG"
|
||||
|
||||
isSafe () {
|
||||
[ -d $HDD_LOG ] || echo "ERROR: $HDD_LOG doesn't exist! Can't sync."
|
||||
[ -d $HDD_LOG ] || exit 1
|
||||
}
|
||||
|
||||
syncToDisk () {
|
||||
isSafe
|
||||
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
rsync -aXWv --exclude armbian-ramlog.log --links $RAM_LOG $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
else
|
||||
cp -rfup $RAM_LOG -T $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
fi
|
||||
}
|
||||
|
||||
syncFromDisk () {
|
||||
isSafe
|
||||
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
rsync -aXWv --delete --exclude armbian-ramlog.log --exclude *.gz --exclude='*.[0-9]' --links $HDD_LOG $RAM_LOG 2>&1 | $LOG_OUTPUT
|
||||
else
|
||||
#find $RAM_LOG* -maxdepth 1 -type f -not \( -name '*.[0-9]' -or -name '*.xz*' -or -name '*.gz' \) | awk -v var="$RAM_LOG" '{print var $1}' | xargs cp -t $RAM_LOG
|
||||
find $HDD_LOG* -maxdepth 1 -type f -not \( -name '*.[0-9]' -or -name '*.xz*' -or -name '*.gz' \) | xargs cp -ut $RAM_LOG
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ -d $HDD_LOG ] || mkdir $HDD_LOG
|
||||
mount --bind $RAM_LOG $HDD_LOG
|
||||
mount --make-private $HDD_LOG
|
||||
rm -f $LOG2RAM_LOG
|
||||
# zram type
|
||||
if [ "$(blkid -s TYPE /dev/zram0 | awk ' { print $2 } ' | grep btrfs)" ]; then
|
||||
mount /dev/zram0 $RAM_LOG | $LOG_OUTPUT
|
||||
# workaround for older kernel/btrfs driver versions
|
||||
if [ $? -eq 1 ]; then mkfs.btrfs -f -O ^extref -s 1024 -L armbian-ramlog /dev/zram0; mount /dev/zram0 $RAM_LOG | $LOG_OUTPUT; fi
|
||||
else
|
||||
|
||||
mount -t tmpfs -o nosuid,noexec,nodev,mode=0755,size=$SIZE armbian-ramlog $RAM_LOG | $LOG_OUTPUT
|
||||
fi
|
||||
syncFromDisk
|
||||
;;
|
||||
|
||||
stop)
|
||||
syncToDisk
|
||||
umount -l $RAM_LOG
|
||||
umount -l $HDD_LOG
|
||||
;;
|
||||
|
||||
write)
|
||||
syncToDisk
|
||||
;;
|
||||
*)
|
||||
echo "Usage: log2ram {start|stop|write}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,22 +1,15 @@
|
|||
#!/bin/bash
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: resize2fs
|
||||
# Required-Start: $local_fs
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Resize the root filesystem
|
||||
# Description: Resize the root filesystem to fill the whole storage
|
||||
### END INIT INFO
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
. /etc/armbian-release
|
||||
. /lib/init/vars.sh
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
Log=/var/log/armhwinfo.log
|
||||
. /usr/lib/armbian/armbian-common
|
||||
|
||||
do_expand_partition()
|
||||
{
|
||||
|
|
@ -142,7 +135,7 @@ case "$1" in
|
|||
start)
|
||||
# skip resizing if rootfs is neither ext4 not btrfs or if explicitly disabled
|
||||
if [[ -f /root/.no_rootfs_resize ]]; then
|
||||
systemctl disable resize2fs
|
||||
systemctl disable armbian-resize-filesystem
|
||||
exit 0
|
||||
fi
|
||||
|
||||
|
|
@ -163,12 +156,12 @@ case "$1" in
|
|||
[[ ! -f /var/run/resize2fs-reboot ]] && do_expand_ext4 ${rootpart}
|
||||
;;
|
||||
btrfs)
|
||||
do_expand_partition ${rootfstype} && systemctl disable resize2fs
|
||||
do_expand_partition ${rootfstype} && systemctl disable armbian-resize-filesystem
|
||||
;;
|
||||
esac
|
||||
|
||||
# disable itself
|
||||
[[ ! -f /var/run/resize2fs-reboot ]] && systemctl disable resize2fs
|
||||
[[ ! -f /var/run/resize2fs-reboot ]] && systemctl disable armbian-resize-filesystem
|
||||
exit 0
|
||||
;;
|
||||
|
||||
|
|
@ -176,4 +169,4 @@ case "$1" in
|
|||
echo "Usage: $0 start"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
esac
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
#
|
||||
# truncate, save and clean logs if they get over 75% of the /var/log size
|
||||
#
|
||||
|
||||
treshold=75 # %
|
||||
logusage=$(df /var/log/ --output=pcent | tail -1 |cut -d "%" -f 1)
|
||||
if [ $logusage -ge $treshold ]; then
|
||||
|
||||
logrotate --force /etc/logrotate.d/
|
||||
# write to SD
|
||||
/usr/sbin/armbian/armbian-ram-logging write >/dev/null 2>&1
|
||||
# truncate
|
||||
/usr/bin/find /var/log -name '*.log' -or -name '*.xz' -or -name 'lastlog' -or -name 'messages' -or -name 'debug' -or -name 'syslog' | xargs truncate --size 0
|
||||
/usr/bin/find /var/log -name 'btmp' -or -name 'wtmp' | xargs truncate --size 0
|
||||
# remove
|
||||
/usr/bin/find /var/log -name '*.[0-9]' -or -name '*.gz' | xargs rm
|
||||
|
||||
fi
|
||||
|
|
@ -0,0 +1,63 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
#
|
||||
# This file is licensed under the terms of the GNU General Public
|
||||
# License version 2. This program is licensed "as is" without any
|
||||
# warranty of any kind, whether express or implied.
|
||||
|
||||
# Functions:
|
||||
#
|
||||
# activate_zram
|
||||
|
||||
|
||||
# Read in basic OS image information
|
||||
. /etc/armbian-release
|
||||
# and script configuration
|
||||
. /usr/lib/armbian/armbian-common
|
||||
|
||||
[ -f /etc/default/armbian-zram-config ] && . /etc/default/armbian-zram-config
|
||||
|
||||
activate_zram() {
|
||||
|
||||
# Do not interfere with already present config-zram package
|
||||
dpkg -l | grep -q 'zram-config' && return
|
||||
[[ "$ENABLED" != "true" ]] && return
|
||||
|
||||
# Load zram module with n instances (one per CPU core, 4 are the maximum)
|
||||
cpu_cores=$(grep -c '^processor' /proc/cpuinfo | sed 's/^0$/1/')
|
||||
[[ ${cpu_cores} -gt 4 ]] && zram_devices=4 || zram_devices=${cpu_cores}
|
||||
module_args="$(modinfo zram | awk -F" " '/num_devices/ {print $2}' | cut -f1 -d:)"
|
||||
[[ -n ${module_args} ]] && modprobe zram ${module_args}=$(( ${zram_devices} + 1 )) || return
|
||||
|
||||
# Use half of the real memory by default --> 1/${ram_divisor}
|
||||
ram_divisor=2
|
||||
mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem")
|
||||
memory_total=$(awk '{printf("%d",$2*1024)}' <<<${mem_info})
|
||||
mem_per_zram_device=$(( ${memory_total} / ${zram_devices} / ${ram_divisor} ))
|
||||
|
||||
for (( i=1; i<=zram_devices; i++ )); do
|
||||
[[ -f /sys/block/zram${i}/comp_algorithm ]] && echo lz4 >/sys/block/zram${i}/comp_algorithm 2>/dev/null
|
||||
echo -n ${mem_per_zram_device} > /sys/block/zram${i}/disksize
|
||||
mkswap /dev/zram${i}
|
||||
swapon -p 5 /dev/zram${i}
|
||||
done
|
||||
echo -e "\n### Activated ${zram_devices} zram swap devices with ${mem_per_zram_device} MB each\n" >>${Log}
|
||||
|
||||
# Dedicate SIZE MB (uncompressed) /dev/zram0 device for log2ram and choose most efficient
|
||||
# compression scheme available -- https://patchwork.kernel.org/patch/9918897/
|
||||
for algo in lz4 quicklz zlib brotli zstd ; do
|
||||
echo ${algo} >/sys/block/zram0/comp_algorithm 2>/dev/null
|
||||
done
|
||||
echo -n $(($SIZE*1024*1024)) > /sys/block/zram0/disksize
|
||||
mkfs.btrfs -s 1024 -L log2ram /dev/zram0
|
||||
read algo </sys/block/zram0/comp_algorithm
|
||||
echo -e "### Activated Armbian ramlog partition with ${algo} compression\n" >>${Log}
|
||||
} # activate_zram
|
||||
|
||||
case $1 in
|
||||
*start*)
|
||||
# activate zram
|
||||
activate_zram
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Source: https://github.com/azlux/log2ram
|
||||
# License: MIT
|
||||
# License file: /usr/share/log2ram/LICENSE
|
||||
|
||||
SIZE=40M
|
||||
USE_RSYNC=false
|
||||
ENABLED=false
|
||||
|
||||
[ -f /etc/default/log2ram ] && . /etc/default/log2ram
|
||||
|
||||
[ "$ENABLED" != true ] && exit 0
|
||||
|
||||
# don't touch anything below here.
|
||||
|
||||
HDD_LOG=/var/log.hdd/
|
||||
RAM_LOG=/var/log/
|
||||
LOG2RAM_LOG="${HDD_LOG}log2ram.log"
|
||||
LOG_OUTPUT="tee -a $LOG2RAM_LOG"
|
||||
|
||||
isSafe () {
|
||||
[ -d $HDD_LOG ] || echo "ERROR: $HDD_LOG doesn't exist! Can't sync."
|
||||
[ -d $HDD_LOG ] || exit 1
|
||||
}
|
||||
|
||||
syncToDisk () {
|
||||
isSafe
|
||||
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
rsync -aXWv --delete --exclude log2ram.log --links $RAM_LOG $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
else
|
||||
cp -rfup $RAM_LOG -T $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
fi
|
||||
}
|
||||
|
||||
syncFromDisk () {
|
||||
isSafe
|
||||
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
rsync -aXWv --delete --exclude log2ram.log --links $HDD_LOG $RAM_LOG 2>&1 | $LOG_OUTPUT
|
||||
else
|
||||
cp -rfup $HDD_LOG -T $RAM_LOG 2>&1 | $LOG_OUTPUT
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
[ -d $HDD_LOG ] || mkdir $HDD_LOG
|
||||
rm -f $LOG2RAM_LOG
|
||||
mount --bind $RAM_LOG $HDD_LOG
|
||||
mount --make-private $HDD_LOG
|
||||
mount -t tmpfs -o nosuid,noexec,nodev,mode=0755,size=$SIZE log2ram $RAM_LOG
|
||||
syncFromDisk
|
||||
;;
|
||||
|
||||
stop)
|
||||
syncToDisk
|
||||
umount -l $RAM_LOG
|
||||
umount -l $HDD_LOG
|
||||
;;
|
||||
|
||||
write)
|
||||
syncToDisk
|
||||
;;
|
||||
*)
|
||||
echo "Usage: log2ram {start|stop|write}" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
Loading…
Reference in New Issue