mirror of
https://github.com/DrHo1y/orangepi-build.git
synced 2026-11-18 08:02:46 +07:00
Bump to next branch
Host: Ubuntu 21.04
This commit is contained in:
@@ -1,23 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# With offloading enabled, Samba becomes completely useless - transfers to a Windows PC freezes randomly
|
||||
# Disabling offloading should solve this - all RK3399
|
||||
|
||||
IFACE=$1
|
||||
EVENT=$2
|
||||
|
||||
if [[ "$EVENT" != "up" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if linux-version compare $(uname -r | cut -d '.' -f1,2) gt 4.4; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
ETHTOOL=/sbin/ethtool
|
||||
|
||||
[ -f $ETHTOOL ] || exit 2
|
||||
[ -d /sys/devices/platform/fe300000.ethernet/net/$IFACE ] || exit 3
|
||||
|
||||
$ETHTOOL -K $IFACE rx off tx off
|
||||
exit 0
|
||||
@@ -1,2 +1,3 @@
|
||||
Acquire::GzipIndexes "true";
|
||||
Acquire::CompressionTypes::Order:: "gz";
|
||||
APT::Compressor::gzip::Cost "10";
|
||||
|
||||
@@ -19,4 +19,5 @@ APT::Periodic::AutocleanInterval "120";
|
||||
// Define basic patterns
|
||||
Unattended-Upgrade::Origins-Pattern {
|
||||
"origin=${distro_id},codename=${distro_codename}";
|
||||
"origin=OrangePi";
|
||||
};
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
#!/bin/sh
|
||||
# Only run on systems where logrotate is a cron job
|
||||
systemctl is-active --quiet logrotate.timer && exit 0
|
||||
/usr/lib/orangepi/orangepi-ramlog write >/dev/null 2>&1
|
||||
|
||||
@@ -1,6 +1,20 @@
|
||||
# add space-separated list of MOTD script names (without number) to exclude them from MOTD
|
||||
# Example:
|
||||
# MOTD_DISABLE="header tips updates"
|
||||
# ONE_WIRE="yes" show 1-wire temperature sensor if attached
|
||||
# PRIMARY_DIRECTION="rx" show daily traffic stats, options: "rx", "tx", "both", "off", vnstat needs to be installed
|
||||
|
||||
MOTD_DISABLE=""
|
||||
ONE_WIRE="" # yes = show 1-wire temperature sensor if attached
|
||||
ONE_WIRE=""
|
||||
HIDE_IP_PATTERN="^dummy0|^lo"
|
||||
PRIMARY_INTERFACE="$(ls -1 /sys/class/net/ | grep -v lo | egrep "enp|eth" | head -1)"
|
||||
PRIMARY_DIRECTION="rx"
|
||||
STORAGE=/dev/sda1
|
||||
|
||||
# Temperature offset in Celcius degrees
|
||||
CPU_TEMP_OFFSET=0
|
||||
|
||||
# Define where red color is used
|
||||
CPU_TEMP_LIMIT=60
|
||||
HDD_TEMP_LIMIT=60
|
||||
AMB_TEMP_LIMIT=40
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# configuration values for the orangepi-ram-logging service
|
||||
#
|
||||
# enable the orangepi-ram-logging service?
|
||||
ENABLED=true
|
||||
ENABLED=false
|
||||
#
|
||||
# size of the tmpfs mount -- please keep in mind to adjust /etc/default/orangepi-zram-config too when increasing
|
||||
SIZE=50M
|
||||
@@ -10,3 +10,15 @@ SIZE=50M
|
||||
# requires rsync installed, may provide better performance
|
||||
# due to copying only new and changed files
|
||||
USE_RSYNC=true
|
||||
|
||||
# If USE_RSYNC is true, additional options may be specified for the rsync
|
||||
# commands used to synchronize logs to disk from RAM (XTRA_RSYNC_TO) or from
|
||||
# disk to RAM (XTRA_RSYNC_FROM). These are bash arrays to make specifying
|
||||
# multiple arguments easy even in the presence of whitespace.
|
||||
XTRA_RSYNC_TO=(
|
||||
## If you use log rotation programs that datestamp their logs (e.g., runit's
|
||||
## svlogd or daemontools' multilog), deleting log files while synchronizing is
|
||||
## likely a good idea.
|
||||
# --delete
|
||||
)
|
||||
XTRA_RSYNC_FROM=()
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
# configuration values for the orangepi-zram-config service
|
||||
#
|
||||
# enable the orangepi-zram-config service?
|
||||
ENABLED=true
|
||||
ENABLED=false
|
||||
|
||||
# Zram swap enabled by default, unless set to disabled
|
||||
# SWAP=false
|
||||
|
||||
# percentage of zram used as swap compared to physically available DRAM.
|
||||
# Huge overcommitment (300) is possible and sometimes desirable. See
|
||||
@@ -28,6 +31,9 @@ ENABLED=true
|
||||
# Which algorithm to choose for zram based /tmp
|
||||
# TMP_ALGORITHM=zstd
|
||||
|
||||
# Size for zram based /tmp, total memory / 2 by default
|
||||
# TMP_SIZE=500M
|
||||
|
||||
# If defined a separate partition will be used as zram backing device. Be CAREFUL
|
||||
# which partition you assign and read starting from CONFIG_ZRAM_WRITEBACK in
|
||||
# https://www.kernel.org/doc/Documentation/blockdev/zram.txt
|
||||
|
||||
11
external/packages/bsp/common/etc/initramfs-tools/hooks/bootsplash.sh
vendored
Executable file
11
external/packages/bsp/common/etc/initramfs-tools/hooks/bootsplash.sh
vendored
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
# Copy splash file to initrd
|
||||
#
|
||||
mkdir -p "${DESTDIR}"/lib/firmware
|
||||
splashfile=/lib/firmware/bootsplash.orangepi
|
||||
|
||||
if [ -f "${splashfile}" ]; then
|
||||
cp "${splashfile}" "${DESTDIR}"/lib/firmware
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@@ -7,5 +7,4 @@ tempname="/boot/uInitrd-$1"
|
||||
mkimage -A $INITRD_ARCH -O linux -T ramdisk -C gzip -n uInitrd -d $2 $tempname > /dev/null
|
||||
|
||||
ln -sf $(basename $tempname) /boot/uInitrd > /dev/null 2>&1 || mv $tempname /boot/uInitrd
|
||||
|
||||
exit 0
|
||||
|
||||
1
external/packages/bsp/common/etc/modprobe.d/8189fs.conf
vendored
Executable file
1
external/packages/bsp/common/etc/modprobe.d/8189fs.conf
vendored
Executable file
@@ -0,0 +1 @@
|
||||
options 8189fs rtw_power_mgnt=0 rtw_enusbss=0
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
@@ -8,8 +8,17 @@
|
||||
|
||||
# only do this for interactive shells
|
||||
if [ "$-" != "${-#*i}" ]; then
|
||||
printf "\n"
|
||||
OutstandingPackages="$(egrep -v "linux-base|linux-image" /var/run/reboot-required.pkgs 2>/dev/null)"
|
||||
if [ -f "/var/run/.reboot_required" ]; then
|
||||
printf "[\e[0;91m Kernel was updated, please reboot\x1B[0m ]\n\n"
|
||||
printf "\n[\e[0;91m Kernel was updated, please reboot\x1B[0m ]\n\n"
|
||||
elif [ "X${OutstandingPackages}" != "X" ]; then
|
||||
# No kernel update involved, just regular packages like e.g. dbus require a reboot
|
||||
Packages="$(egrep -v "linux-base|linux-image" /var/run/reboot-required.pkgs | sort | uniq | tr '\n' ',' | sed -e 's/,/, /g' -e 's/,\ $//')"
|
||||
OlderThanOneDay=$(find /var/run/reboot-required -mtime +1)
|
||||
if [ "X${OlderThanOneDay}" = "X" ]; then
|
||||
printf "\n[\e[0;92m some packages require a reboot (${Packages})\x1B[0m ]\n\n"
|
||||
else
|
||||
printf "\n[\e[0;91m some packages require a reboot since more than 1 day (${Packages})\x1B[0m ]\n\n"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
|
||||
@@ -20,10 +20,10 @@ update_process_names=0
|
||||
account_guest_in_cpu_meter=0
|
||||
color_scheme=0
|
||||
delay=15
|
||||
left_meters=AllCPUs Memory Swap CpuTemp
|
||||
left_meter_modes=1 1 1 2
|
||||
right_meters=OrangePiversion Hostname Tasks LoadAverage Uptime CpuFreq Eth0 Eth0stat
|
||||
right_meter_modes=2 2 2 2 2 2 2 2
|
||||
left_meters=AllCPUs Memory Swap CpuFreq CpuTemp
|
||||
left_meter_modes=1 1 1 2 2
|
||||
right_meters=OSversion Hostname Tasks LoadAverage Uptime
|
||||
right_meter_modes=2 2 2 2 2
|
||||
# SBC hardware and Kernel specific path.
|
||||
# Editable manually.
|
||||
BoardName=
|
||||
|
||||
42
external/packages/bsp/common/etc/udev/rules.d/50-usb-realtek-net.rules
vendored
Executable file
42
external/packages/bsp/common/etc/udev/rules.d/50-usb-realtek-net.rules
vendored
Executable file
@@ -0,0 +1,42 @@
|
||||
# This is used to change the default configuration of Realtek USB ethernet adapters
|
||||
|
||||
ACTION!="add", GOTO="usb_realtek_net_end"
|
||||
SUBSYSTEM!="usb", GOTO="usb_realtek_net_end"
|
||||
ENV{DEVTYPE}!="usb_device", GOTO="usb_realtek_net_end"
|
||||
|
||||
# Modify this to change the default value
|
||||
ENV{REALTEK_NIC_MODE}="1"
|
||||
|
||||
# Realtek
|
||||
ATTR{idVendor}=="0bda", ATTR{idProduct}=="8156", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="0bda", ATTR{idProduct}=="8155", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="0bda", ATTR{idProduct}=="8153", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="0bda", ATTR{idProduct}=="8152", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
|
||||
# Samsung
|
||||
ATTR{idVendor}=="04e8", ATTR{idProduct}=="a101", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
|
||||
# Lenovo
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="304f", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3052", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3054", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3057", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="3082", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="7205", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="720a", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="720b", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="720c", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="721e", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="a359", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
ATTR{idVendor}=="17ef", ATTR{idProduct}=="a387", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
|
||||
# TP-LINK
|
||||
ATTR{idVendor}=="2357", ATTR{idProduct}=="0601", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
|
||||
# Nvidia
|
||||
ATTR{idVendor}=="0955", ATTR{idProduct}=="09ff", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
|
||||
# LINKSYS
|
||||
ATTR{idVendor}=="13b1", ATTR{idProduct}=="0041", ATTR{bConfigurationValue}!="$env{REALTEK_NIC_MODE}", ATTR{bConfigurationValue}="$env{REALTEK_NIC_MODE}"
|
||||
|
||||
LABEL="usb_realtek_net_end"
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
@@ -23,4 +23,4 @@ done
|
||||
|
||||
KERNELID=$(uname -r)
|
||||
TERM=linux toilet -f standard -F metal $(echo $BOARD_NAME | sed 's/Orange Pi/OPi/')
|
||||
echo -e "Welcome to \e[0;91mOrange Pi \x1B[0m$(if [[ $ID == debian ]]; then echo ${PRETTY_NAME##*\(} | sed -e 's/^.*Linux //' | sed "s/\/.*//" | sed 's|)||'; else echo -n ${VERSION_CODENAME^};fi) with \e[0;91mLinux $KERNELID\x1B[0m\n"
|
||||
echo -e "Welcome to \e[0;91mOrange Pi ${VERSION} ${DISTRIBUTION_CODENAME^}\x1B[0m with $([[ $BRANCH == edge ]] && echo -e "\e[0;91mbleeding\x1B[0m edge " )\e[0;91mLinux $KERNELID\x1B[0m\n"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
@@ -11,13 +11,19 @@
|
||||
# generate system information
|
||||
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
|
||||
THIS_SCRIPT="sysinfo"
|
||||
MOTD_DISABLE=""
|
||||
STORAGE=/dev/sda1
|
||||
SHOW_IP_PATTERN="^bond.*|^[ewr].*|^br.*|^lt.*|^umts.*|^lan.*"
|
||||
|
||||
CPU_TEMP_LIMIT=45
|
||||
# don't change default values - they are lost on upgrades. Use /etc/default/orangepi-motd for your values
|
||||
|
||||
MOTD_DISABLE=""
|
||||
PRIMARY_INTERFACE="eth0"
|
||||
PRIMARY_DIRECTION="rx"
|
||||
STORAGE=/dev/sda1
|
||||
HIDE_IP_PATTERN="^dummy0|^lo"
|
||||
CPU_TEMP_LIMIT=60
|
||||
# Temperature offset in Celcius degrees
|
||||
CPU_TEMP_OFFSET=0
|
||||
HDD_TEMP_LIMIT=60
|
||||
AMB_TEMP_LIMIT=40
|
||||
|
||||
[[ -f /etc/default/orangepi-motd ]] && . /etc/default/orangepi-motd
|
||||
@@ -33,10 +39,10 @@ function display() {
|
||||
# battery red color is opposite, lower number
|
||||
if [[ "$1" == "Battery" ]]; then local great="<"; else local great=">"; fi
|
||||
if [[ -n "$2" && "$2" > "0" && (( "${2%.*}" -ge "$4" )) ]]; then
|
||||
printf "%-14s%s" "$1:"
|
||||
printf "%-14s" "$1:"
|
||||
if awk "BEGIN{exit ! ($2 $great $3)}"; then echo -ne "\e[0;91m $2"; else echo -ne "\e[0;92m $2"; fi
|
||||
printf "%-1s%s\x1B[0m" "$5"
|
||||
printf "%-11s%s\t" "$6"
|
||||
printf "%-1s\x1B[0m" "$5"
|
||||
printf "%-11s\t" "$6"
|
||||
return 1
|
||||
fi
|
||||
} # display
|
||||
@@ -54,6 +60,8 @@ function getboardtemp() {
|
||||
# fallback to PMIC temperature
|
||||
board_temp=$(awk '{printf("%d",$1/1000)}' </etc/orangepimonitor/datasources/pmictemp)
|
||||
fi
|
||||
# Some boards, such as the Orange Pi Zero LTS, report shifted CPU temperatures
|
||||
board_temp=$((board_temp + CPU_TEMP_OFFSET))
|
||||
} # getboardtemp
|
||||
|
||||
function batteryinfo() {
|
||||
@@ -79,8 +87,8 @@ function batteryinfo() {
|
||||
read status_battery_connected < $legacy_dir/axp20x-battery/present
|
||||
if [[ "$status_battery_connected" == "1" ]]; then
|
||||
status_battery_text=" "$(awk '{print tolower($0)}' < $legacy_dir/axp20x-battery/status)
|
||||
read status_ac_connect < $legacy_dir/axp813-ac/present
|
||||
read battery_percent< $legacy_dir/axp20x-battery/capacity
|
||||
read status_ac_connect < $legacy_dir/axp813-ac/present
|
||||
read battery_percent< $legacy_dir/axp20x-battery/capacity
|
||||
fi
|
||||
elif [[ -e "$legacy_dir/battery" ]]; then
|
||||
if [[ (("$(cat $legacy_dir/battery/voltage_now)" -gt "5" )) ]]; then
|
||||
@@ -98,10 +106,9 @@ function ambienttemp() {
|
||||
amb_temp=$(awk '{printf("%d",$1/1000)}' <<<${raw_temp})
|
||||
echo $amb_temp
|
||||
elif [[ -d $W1_DIR && $ONE_WIRE == yes ]]; then
|
||||
device=$(ls -1 $W1_DIR | grep -Eo '^[0-9]{1,4}' | head -1)
|
||||
device=$(ls -1 $W1_DIR | grep -E '^[0-9]{1,4}' | head -1)
|
||||
if [[ -n $device ]]; then
|
||||
if [[ -d ${W1_DIR}${device}/hwmon/hwmon0 ]]; then hwmon=0; else hwmon=1; fi
|
||||
read raw_temp < ${W1_DIR}${device}/hwmon/hwmon${hwmon}/temp1_input 2>/dev/null
|
||||
read raw_temp < ${W1_DIR}${device}/hwmon/$(ls -1 ${W1_DIR}${device}/hwmon)/temp1_input 2>/dev/null
|
||||
amb_temp=$(awk '{printf("%d",$1/1000)}' <<<${raw_temp})
|
||||
echo $amb_temp
|
||||
fi
|
||||
@@ -123,20 +130,15 @@ function ambienttemp() {
|
||||
fi
|
||||
} # ambienttemp
|
||||
|
||||
#function get_ip_addresses() {
|
||||
# # return up to 2 IPv4 address(es) comma separated
|
||||
# hostname -I | tr " " "\n" | \
|
||||
# grep -E "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" | \
|
||||
# tail -n2 | sed ':a;N;$!ba;s/\n/,/g'
|
||||
#} # get_ip_addresses
|
||||
|
||||
function get_ip_addresses() {
|
||||
local ips=()
|
||||
for f in /sys/class/net/*; do
|
||||
local intf=$(basename $f)
|
||||
# match only interface names starting with e (Ethernet), br (bridge), w (wireless), r (some Ralink drivers use ra<number> format)
|
||||
if [[ $intf =~ $SHOW_IP_PATTERN ]]; then
|
||||
local tmp=$(ip -4 addr show dev $intf | awk '/inet/ {print $2}' | cut -d'/' -f1)
|
||||
# match only interface names "dummy0" and "lo"
|
||||
if [[ $intf =~ $HIDE_IP_PATTERN ]]; then
|
||||
continue
|
||||
else
|
||||
local tmp=$(ip -4 addr show dev $intf | grep -v "$intf:avahi" | awk '/inet/ {print $2}' | cut -d'/' -f1)
|
||||
# add both name and IP - can be informative but becomes ugly with long persistent/predictable device names
|
||||
#[[ -n $tmp ]] && ips+=("$intf: $tmp")
|
||||
# add IP only
|
||||
@@ -155,9 +157,15 @@ function storage_info() {
|
||||
if [[ -n "${StorageInfo}" && ${RootInfo} != *$STORAGE* ]]; then
|
||||
storage_usage=$(awk '/\// {print $(NF-1)}' <<<${StorageInfo} | sed 's/%//g')
|
||||
storage_total=$(awk '/\// {print $(NF-4)}' <<<${StorageInfo})
|
||||
if [[ -n "$(command -v smartctl)" ]]; then
|
||||
DISK="${STORAGE::-1}"
|
||||
storage_temp+=$(smartctl -l scttempsts $DISK 2> /dev/null | grep -i 'Current Temperature:' | awk '{print $(NF-1)}')
|
||||
fi
|
||||
fi
|
||||
} # storage_info
|
||||
|
||||
|
||||
|
||||
# query various systems and send some stuff to the background for overall faster execution.
|
||||
# Works only with ambienttemp and batteryinfo since A20 is slow enough :)
|
||||
amb_temp=$(ambienttemp &)
|
||||
@@ -165,7 +173,7 @@ ip_address=$(get_ip_addresses &)
|
||||
batteryinfo
|
||||
storage_info
|
||||
getboardtemp
|
||||
critical_load=$(( 1 + $(grep -c processor /proc/cpuinfo) / 2 ))
|
||||
critical_load=80
|
||||
|
||||
# get uptime, logged in users and load in one take
|
||||
UPTIME=$(LC_ALL=C uptime)
|
||||
@@ -175,33 +183,102 @@ users=${UPT2//*','}
|
||||
users=${users//' '}
|
||||
time=${UPT2%','*}
|
||||
time=${time//','}
|
||||
time=$(echo $time | xargs)
|
||||
load=${UPTIME#*'load average: '}
|
||||
load=${load//','}
|
||||
load=$(echo $load | cut -d" " -f1)
|
||||
[[ $load == 0.0* ]] && load=0.10
|
||||
cpucount=$(grep -c processor /proc/cpuinfo)
|
||||
|
||||
load=$(awk '{printf("%.0f",($1/$2) * 100)}' <<< "$load $cpucount")
|
||||
|
||||
# memory and swap
|
||||
mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem")
|
||||
memory_usage=$(awk '{printf("%.0f",(($2-($4+$6+$7))/$2) * 100)}' <<<${mem_info})
|
||||
memory_total=$(awk '{printf("%d",$2/1024)}' <<<${mem_info})
|
||||
mem_info=$(echo $mem_info | awk '{print $2}')
|
||||
memory_total=$(( mem_info / 1024 ))
|
||||
swap_info=$(LC_ALL=C free -m | grep "^Swap")
|
||||
swap_usage=$( (awk '/Swap/ { printf("%3.0f", $3/$2*100) }' <<<${swap_info} 2>/dev/null || echo 0) | tr -c -d '[:digit:]')
|
||||
swap_total=$(awk '{print $(2)}' <<<${swap_info})
|
||||
|
||||
# display info
|
||||
display "System load" "${load%% *}" "${critical_load}" "0" "" "${load#* }"
|
||||
printf "Up time: \x1B[92m%s\x1B[0m\t\t" "$time"
|
||||
display "System load" "${load%% *}" "${critical_load}" "0" "%" ""
|
||||
|
||||
printf "Up time: \x1B[92m%s\x1B[0m\t" "$time"
|
||||
display "Local users" "${users##* }" "3" "2" ""
|
||||
echo "" # fixed newline
|
||||
display "Memory usage" "$memory_usage" "70" "0" " %" " of ${memory_total}MB"
|
||||
display "Zram usage" "$swap_usage" "75" "0" " %" " of $swap_total""Mb"
|
||||
printf "IP: "
|
||||
if [[ ${memory_total} -gt 1000 ]]; then
|
||||
memory_total=$(awk '{printf("%.2f",$1/1024)}' <<<${memory_total})"G"
|
||||
else
|
||||
memory_total+="M"
|
||||
fi
|
||||
|
||||
if [[ ${swap_total} -gt 500 ]]; then
|
||||
swap_total=$(awk '{printf("%.2f",$1/1024)}' <<<${swap_total})"G"
|
||||
else
|
||||
swap_total+="M"
|
||||
fi
|
||||
|
||||
display "Memory usage" "$memory_usage" "70" "0" "%" " of ${memory_total}"
|
||||
display "Zram usage" "$swap_usage" "75" "0" "%" " of ${swap_total}"
|
||||
printf "IP: "
|
||||
printf "\x1B[92m%s\x1B[0m" "$ip_address"
|
||||
echo "" # fixed newline
|
||||
a=0;b=0;c=0
|
||||
display "CPU temp" "$board_temp" $CPU_TEMP_LIMIT "0" "°C" "" ; a=$?
|
||||
display "Ambient temp" "$amb_temp" $AMB_TEMP_LIMIT "0" "°C" "" ; b=$?
|
||||
(( ($a+$b) >0 )) && echo "" # new line only if some value is displayed
|
||||
display "CPU temp" "$board_temp" $CPU_TEMP_LIMIT "0" "°C" ""
|
||||
display "Ambient temp" "$amb_temp" $AMB_TEMP_LIMIT "0" "°C" ""
|
||||
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 "" # fixed newline
|
||||
a=0
|
||||
display "storage/" "$storage_usage" "90" "1" "%" " of $storage_total" ; a=$((a+$?))
|
||||
display "storage temp" "$storage_temp" $HDD_TEMP_LIMIT "0" "°C" "" ; a=$((a+$?))
|
||||
display "Battery" "$battery_percent" "20" "1" "%" "$status_battery_text" ; a=$((a+$?))
|
||||
(( $a > 0 )) && echo "" # new line only if some value is displayed
|
||||
|
||||
# Check whether PRIMARY_INTERFACE exist in /var/lib/vnstat/
|
||||
PRIMARY_INTERFACE=$(comm -12 <(ls -1 /var/lib/vnstat/ 2> /dev/null) <(echo "$PRIMARY_INTERFACE" | sed 's/+/\n/g') | sed -n -e 'H;${x;s/\n/+/g;s/^+//;p;}')
|
||||
|
||||
line=0
|
||||
if [[ $(command -v vnstat) && -n $PRIMARY_INTERFACE ]]; then
|
||||
traffic=$(vnstat -i $PRIMARY_INTERFACE --oneline | cut -d";" -f4,5)
|
||||
traffic_rx=$(echo $traffic | cut -d";" -f1,1 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/')
|
||||
traffic_tx=$(echo $traffic | cut -d";" -f2,2 | sed -r 's/([0-9]+\.[0-9]{1})[0-9]*/\1/')
|
||||
[[ "$traffic" == *"Not enough"* ]] && { traffic_tx="n/a "; traffic_rx="n/a "; }
|
||||
case $PRIMARY_DIRECTION in
|
||||
tx)
|
||||
printf "TX today: \x1B[92m%s\x1B[0m \t" "$traffic_tx"
|
||||
line=$((line+1))
|
||||
;;
|
||||
rx)
|
||||
printf "RX today: \x1B[92m%s\x1B[0m \t" "$traffic_rx"
|
||||
line=$((line+1))
|
||||
;;
|
||||
both)
|
||||
printf "TX today: \x1B[92m%s\x1B[0m \t" "$traffic_tx"
|
||||
printf "RX today: \x1B[92m%s\x1B[0m \t" "$traffic_rx"
|
||||
line=$((line+1))
|
||||
;;
|
||||
*) #off or whatever
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ $(command -v zpool) ]]; then
|
||||
zpoolstatus="$(zpool status </dev/stdin 2>&1 )"
|
||||
if [[ -n $(echo $zpoolstatus | grep 'not loaded') ]]; then
|
||||
:
|
||||
elif [[ -n $(echo $zpoolstatus | grep 'degraded\|OFFLINE') ]]; then
|
||||
printf "ZFS pool: "
|
||||
echo -ne "\e[0;91mDegraded\x1B[0m"
|
||||
line=$((line+1))
|
||||
elif [[ -n $(echo $zpoolstatus | grep 'no pools available') ]]; then
|
||||
printf "ZFS pool: "
|
||||
echo -ne "n/a"
|
||||
line=$((line+1))
|
||||
else
|
||||
printf "ZFS pool: "
|
||||
echo -ne "\e[0;92mOnline\x1B[0m"
|
||||
line=$((line+1))
|
||||
fi
|
||||
fi
|
||||
[[ $line -ne 0 ]] && echo ""
|
||||
echo ""
|
||||
|
||||
26
external/packages/bsp/common/etc/update-motd.d/35-orangepi-tips
vendored
Executable file
26
external/packages/bsp/common/etc/update-motd.d/35-orangepi-tips
vendored
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: https://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/orangepi-motd
|
||||
# any changes will be lost on board support package update
|
||||
|
||||
THIS_SCRIPT="tips"
|
||||
MOTD_DISABLE=""
|
||||
|
||||
[[ -f /etc/default/orangepi-motd ]] && . /etc/default/orangepi-motd
|
||||
|
||||
for f in $MOTD_DISABLE; do
|
||||
[[ $f == $THIS_SCRIPT ]] && exit 0
|
||||
done
|
||||
|
||||
quotes="/etc/update-motd.d/quotes.txt"
|
||||
if [[ -f $quotes ]]; then
|
||||
random_line=$(shuf -i 1-$(wc -l < $quotes) -n 1)
|
||||
quote=$(sed -n -e "$random_line"p $quotes)
|
||||
[[ -n $quote ]] && echo -e "\e[93mTip of the day:\e[39m $quote\n"
|
||||
fi
|
||||
29
external/packages/bsp/common/etc/update-motd.d/40-orangepi-updates
vendored
Executable file
29
external/packages/bsp/common/etc/update-motd.d/40-orangepi-updates
vendored
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: https://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/orangepi-motd
|
||||
# any changes will be lost on board support package update
|
||||
|
||||
THIS_SCRIPT="updates"
|
||||
MOTD_DISABLE=""
|
||||
|
||||
[[ -f /etc/default/orangepi-motd ]] && . /etc/default/orangepi-motd
|
||||
|
||||
for f in $MOTD_DISABLE; do
|
||||
[[ $f == $THIS_SCRIPT ]] && exit 0
|
||||
done
|
||||
|
||||
NUM_UPDATES=0
|
||||
|
||||
[[ -f /var/cache/apt/archives/updates.number ]] && . /var/cache/apt/archives/updates.number
|
||||
|
||||
if [[ $NUM_UPDATES -gt 0 ]]; then
|
||||
echo -e "[\e[31m $NUM_SECURITY_UPDATES security updates available, $NUM_UPDATES updates total\e[0m: \e[1mapt upgrade\e[0m ]"
|
||||
echo -e "Last check: \e[92m$DATE\e[0m"
|
||||
echo
|
||||
fi
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
8
external/packages/bsp/common/lib/systemd/system/orangepi-disable-autologin.service
vendored
Executable file
8
external/packages/bsp/common/lib/systemd/system/orangepi-disable-autologin.service
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=Disable automated desktop login
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=rm -f /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf
|
||||
TimeoutStopSec= 10
|
||||
ExecStop=systemctl disable orangepi-disable-autologin.timer
|
||||
8
external/packages/bsp/common/lib/systemd/system/orangepi-disable-autologin.timer
vendored
Executable file
8
external/packages/bsp/common/lib/systemd/system/orangepi-disable-autologin.timer
vendored
Executable file
@@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=Disable automated desktop login
|
||||
|
||||
[Timer]
|
||||
OnActiveSec=2min
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
@@ -9,7 +9,7 @@ ConditionPathExists=/boot/orangepi_first_run.txt
|
||||
ConditionPathExists=/root/.not_logged_in_yet
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
Type=idle
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/lib/orangepi/orangepi-firstrun-config
|
||||
TimeoutStartSec=2min
|
||||
|
||||
@@ -1071,26 +1071,26 @@ NetworkMonitorMode() {
|
||||
|
||||
# Allow orangepimonitor to return back to orangepi-config
|
||||
trap "echo ; exit 0" 0 1 2 3 15
|
||||
timerStart
|
||||
kickAllStatsDown
|
||||
|
||||
# Count interfaces - multiple routes causing interfaces to show up more than once, filtering...
|
||||
ifacecount=$(route -n | egrep UG | egrep -o "[a-zA-Z0-9]*$" | sort | uniq)
|
||||
ifacecount=$(route -n | egrep UG | egrep -o '[^ ]*$' | sort | uniq)
|
||||
# If there are two ore more interfaces detected open a dynamic dialog box to select which to monitor
|
||||
if [ "$(echo -e $ifacecount | tr ' ' '\n' | wc -l)" -gt 1 ]; then
|
||||
ifacemenu=$(route -n | egrep UG | egrep -o "[a-zA-Z0-9]*$" | sort | uniq | awk '{a[$1]=$1}END{for(i in a)printf i" "a[i]" "}')
|
||||
ifacemenu=$(route -n | egrep UG | egrep -o '[^ ]*$' | sort | uniq | awk '{a[$1]=$1}END{for(i in a)printf i" "a[i]" "}')
|
||||
ifacefunc() {
|
||||
dialog --backtitle "Interface selector" \
|
||||
--title "Multiple network interfaces detected" \
|
||||
--menu "Choose which interface to monitor:" \
|
||||
15 50 $(route -n | egrep UG | egrep -o "[a-zA-Z0-9]*$" | sort | uniq | wc -l) \
|
||||
15 50 $(route -n | egrep UG | egrep -o '[^ ]*$' | sort | uniq | wc -l) \
|
||||
$(echo $ifacemenu) 2>&1 >$(tty)
|
||||
}
|
||||
iface=$(ifacefunc)
|
||||
else
|
||||
# Use default behavior if one interface is found only
|
||||
iface=$(route -n | egrep UG | egrep -o "[a-zA-Z0-9]*$")
|
||||
iface=$(route -n | egrep UG | egrep -o '[^ ]*$')
|
||||
fi
|
||||
timerStart
|
||||
kickAllStatsDown
|
||||
|
||||
printf "\nruntime network statistics: $(uname -n)\n"
|
||||
printf "network interface: $(echo $iface)\n"
|
||||
|
||||
@@ -28,7 +28,10 @@ else
|
||||
fi
|
||||
|
||||
# give up if packages are broken
|
||||
[[ ! $(dpkg -l | grep ^..r) ]] && exit 0
|
||||
[[ $(dpkg -l | grep ^..r) ]] && exit 0
|
||||
|
||||
# give up if there is a dependency problem
|
||||
[[ "$((apt-get upgrade -s -qq) 2>&1)" == *"Unmet dependencies"* ]] && exit 0
|
||||
|
||||
myfile="/var/cache/apt/archives/updates.number"
|
||||
|
||||
|
||||
164
external/packages/bsp/common/usr/lib/orangepi/orangepi-audio-config
vendored
Executable file
164
external/packages/bsp/common/usr/lib/orangepi/orangepi-audio-config
vendored
Executable file
@@ -0,0 +1,164 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
mixer() {
|
||||
parm=${4:-on}
|
||||
amixer -c "$1" sset "$2" "$3" $parm >/dev/null 2>&1
|
||||
amixer -c "$1" sset "$2" $parm >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
if [ -f $HOME/.config/sound.conf ]; then
|
||||
|
||||
alsactl restore -f $HOME/.config/sound.conf
|
||||
|
||||
else
|
||||
|
||||
# get card num
|
||||
#card=`echo $1 | sed 's/[^0-9]*//g'`
|
||||
card1=`aplay -l | grep "device 0" | awk '{print $3}'`
|
||||
#echo $card
|
||||
|
||||
for card in $card1
|
||||
do
|
||||
|
||||
#echo $card
|
||||
|
||||
# set common mixer params
|
||||
mixer $card Master 0db
|
||||
mixer $card Front 100%
|
||||
mixer $card PCM 0db
|
||||
mixer $card Synth 100%
|
||||
|
||||
# mute CD, since using digital audio instead
|
||||
mixer $card CD 0% mute
|
||||
|
||||
# Only unmute Line and Aux if they are possibly used.
|
||||
# mixer $card Line 100%
|
||||
# mixer $card Aux 100%
|
||||
|
||||
# mute mic
|
||||
mixer $card Mic 0% mute
|
||||
|
||||
# ESS 1969 chipset has 2 PCM channels
|
||||
mixer $card PCM,1 100%
|
||||
|
||||
# Trident/YMFPCI/emu10k1
|
||||
mixer $card Wave 100%
|
||||
mixer $card Music 100%
|
||||
mixer $card AC97 100%
|
||||
mixer $card Surround 90%
|
||||
mixer $card 'Surround Digital' 90%
|
||||
mixer $card 'Wave Surround' 90%
|
||||
mixer $card 'Duplicate Front' 90%
|
||||
mixer $card 'Sigmatel 4-Speaker Stereo' 90%
|
||||
|
||||
# CS4237B chipset:
|
||||
mixer $card 'Master Digital' 100%
|
||||
|
||||
# DRC
|
||||
mixer $card 'Dynamic Range Compression' 90%
|
||||
|
||||
# Envy24 chips with analog outs
|
||||
mixer $card DAC 100%
|
||||
mixer $card DAC,0 100%
|
||||
mixer $card DAC,1 100%
|
||||
|
||||
# some notebooks use headphone instead of master
|
||||
mixer $card Headphone 100%
|
||||
mixer $card Speaker 100%
|
||||
mixer $card 'Internal Speaker' 0% mute
|
||||
mixer $card Playback 100%
|
||||
mixer $card Headphone 100%
|
||||
mixer $card Speaker 100%
|
||||
mixer $card Center 100%
|
||||
mixer $card LFE 100%
|
||||
mixer $card Center/LFE 100%
|
||||
|
||||
# Intel P4P800-MX (Ubuntu bug #5813)
|
||||
mixer $card 'Master Playback Switch' on
|
||||
|
||||
# set digital output mixer params
|
||||
mixer $card 'IEC958' 100% on
|
||||
mixer $card 'IEC958 Output' 100%
|
||||
mixer $card 'IEC958 Coaxial' 100%
|
||||
mixer $card 'IEC958 LiveDrive' 100%
|
||||
mixer $card 'IEC958 Optical Raw' 100%
|
||||
mixer $card 'SPDIF Out' 100%
|
||||
mixer $card 'SPDIF Front' 100%
|
||||
mixer $card 'SPDIF Rear' 100%
|
||||
mixer $card 'SPDIF Center/LFE' 100%
|
||||
mixer $card 'Master Digital' 100%
|
||||
|
||||
mixer $card 'Analog Front' 100%
|
||||
mixer $card 'Analog Rear' 100%
|
||||
mixer $card 'Analog Center/LFE' 100%
|
||||
|
||||
# ASRock ION 330 (and perhaps others) has 2 IEC958 channels
|
||||
mixer $card IEC958,0 on
|
||||
mixer $card IEC958,1 on
|
||||
|
||||
# some ION2 has much more IEC958 channels ...
|
||||
mixer $card IEC958,2 on
|
||||
mixer $card IEC958,3 on
|
||||
|
||||
# ASRock ION 330 has Master Front set to 0
|
||||
mixer $card 'Master Front' 100%
|
||||
|
||||
# Shuttle XS35GT needs this too
|
||||
mixer $card 'Master',0 100% on
|
||||
|
||||
# and this for various Fusion devices like Zotac ZBOX
|
||||
mixer $card 'Front',0 100% on
|
||||
|
||||
# NVidia CK804 sound devices
|
||||
mixer $card 'IEC958 Playback AC97-SPSA' 100%
|
||||
|
||||
# Allwinner H3 Analog
|
||||
mixer $card 'Line Out' 0db on
|
||||
|
||||
# Allwinner A20 Analog
|
||||
mixer $card 'Power Amplifier' 0db
|
||||
mixer $card 'Power Amplifier DAC' on
|
||||
mixer $card 'Power Amplifier Mute' on
|
||||
|
||||
# Allwinner A64 Analog
|
||||
mixer $card Headphone 0db on
|
||||
mixer $card 'AIF1 Slot 0 Digital DAC' on
|
||||
|
||||
# Amlogic G12 HDMI to PCM0
|
||||
mixer $card 'FRDDR_A SINK 1 SEL' 'OUT 1'
|
||||
mixer $card 'FRDDR_A SRC 1 EN' on
|
||||
mixer $card 'TDMOUT_B SRC SEL' 'IN 0'
|
||||
mixer $card 'TOHDMITX I2S SRC' 'I2S B'
|
||||
mixer $card 'TOHDMITX' on
|
||||
|
||||
# Amlogic G12 S/PDIF to PCM1
|
||||
mixer $card 'FRDDR_B SINK 1 SEL' 'OUT 3'
|
||||
mixer $card 'FRDDR_B SRC 1 EN' on
|
||||
mixer $card 'SPDIFOUT SRC SEL' 'IN 1'
|
||||
mixer $card 'SPDIFOUT Playback' on
|
||||
|
||||
# Amlogic GX HDMI and S/PDIF
|
||||
mixer $card 'AIU HDMI CTRL SRC' 'I2S'
|
||||
mixer $card 'AIU SPDIF SRC SEL' 'SPDIF'
|
||||
|
||||
# RockPI 4B Analog
|
||||
mixer $card 'Right Headphone Mixer Right DAC' on
|
||||
mixer $card 'Left Headphone Mixer Left DAC' on
|
||||
|
||||
# NanoPC T4 Analog
|
||||
mixer $card 'HPO L' on
|
||||
mixer $card 'HPO R' on
|
||||
mixer $card 'HPOVOL L' on
|
||||
mixer $card 'HPOVOL R' on
|
||||
mixer $card 'HPO MIX HPVOL' on
|
||||
mixer $card 'OUT MIXL DAC L1' on
|
||||
mixer $card 'OUT MIXR DAC R1' on
|
||||
mixer $card 'Stereo DAC MIXL DAC L1' on
|
||||
mixer $card 'Stereo DAC MIXR DAC R1' on
|
||||
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
@@ -34,19 +34,27 @@ MACADDR=$(printf ${prefixes[$random]}':%02X:%02X:%02X:%02X:%02X\n' $[RANDOM%256]
|
||||
# set fixed IP address from first randomly assigned one. If nothing is deteceted, generate one.
|
||||
set_fixed_mac ()
|
||||
{
|
||||
if [ -n "$(command -v nmcli)" ]; then
|
||||
CONNECTION="$(nmcli -f UUID,ACTIVE,DEVICE,TYPE connection show --active | tail -n1)"
|
||||
UUID=$(awk -F" " '/ethernet/ {print $1}' <<< "${CONNECTION}")
|
||||
DEVNAME=$(awk -F" " '/ethernet/ {print $3}' <<< "${CONNECTION}")
|
||||
else
|
||||
DEVNAME=eth0
|
||||
fi
|
||||
|
||||
CONNECTION="$(nmcli -f UUID,ACTIVE,DEVICE,TYPE connection show --active | tail -n1)"
|
||||
UUID=$(awk -F" " '/ethernet/ {print $1}' <<< "${CONNECTION}")
|
||||
DEVNAME=$(awk -F" " '/ethernet/ {print $3}' <<< "${CONNECTION}")
|
||||
MACADDR=$(/sbin/ip link | grep -A1 ${DEVNAME} | awk -F" " '/ether / {print $2}')
|
||||
MACADDR=$(/sbin/ip link | grep -A1 ${DEVNAME} | awk -F" " '/ether / {print $2}')
|
||||
|
||||
[[ -z $MACADDR ]] && get_random_mac
|
||||
[[ -z $MACADDR ]] && get_random_mac
|
||||
|
||||
if [[ -n $UUID ]]; then
|
||||
nmcli connection modify $UUID ethernet.cloned-mac-address $MACADDR
|
||||
nmcli connection modify $UUID -ethernet.mac-address ""
|
||||
nmcli connection down $UUID >/dev/null 2>&1
|
||||
nmcli connection up $UUID >/dev/null 2>&1
|
||||
if [[ -n "$(command -v nmcli)" && -n $UUID ]]; then
|
||||
nmcli connection modify $UUID ethernet.cloned-mac-address $MACADDR
|
||||
nmcli connection modify $UUID -ethernet.mac-address ""
|
||||
nmcli connection down $UUID >/dev/null 2>&1
|
||||
nmcli connection up $UUID >/dev/null 2>&1
|
||||
elif [[ -f /etc/systemd/network/$DEVNAME.network ]]; then
|
||||
if ! grep '^ *MACAddress=' /etc/systemd/network/$DEVNAME.network > /dev/null; then
|
||||
sed -i "s/#MACAddress=/MACAddress=$MACADDR/g" /etc/systemd/network/$DEVNAME.network
|
||||
fi
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
} # set fixed mac to the 1st active network adapter
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
@@ -8,100 +8,200 @@
|
||||
|
||||
. /etc/orangepi-release
|
||||
|
||||
|
||||
check_abort()
|
||||
{
|
||||
|
||||
echo -e "\nDisabling user account creation procedure\n"
|
||||
rm -f /root/.not_logged_in_yet
|
||||
if [[ ${USER_SHELL} == zsh ]]; then
|
||||
printf "\nYou selected \e[0;91mZSH\x1B[0m as your default shell. If you want to use it right away, please logout and login! \n\n"
|
||||
fi
|
||||
trap - INT
|
||||
exit 0
|
||||
|
||||
}
|
||||
|
||||
|
||||
function read_password()
|
||||
read_password()
|
||||
{
|
||||
unset password
|
||||
prompt="$1 password: "
|
||||
while IFS= read -p "$prompt" -r -s -n 1 char
|
||||
do
|
||||
if [[ $char == $'\0' ]]
|
||||
then
|
||||
break
|
||||
fi
|
||||
prompt='*'
|
||||
password+="$char"
|
||||
done
|
||||
|
||||
unset password
|
||||
unset charcount
|
||||
prompt="$1 password: "
|
||||
|
||||
stty -echo
|
||||
|
||||
charcount=0
|
||||
while IFS= read -p "$prompt" -r -s -n 1 char
|
||||
do
|
||||
if [[ $char == $'\0' ]]
|
||||
then
|
||||
break
|
||||
fi
|
||||
|
||||
# Handle backspace
|
||||
if [[ $char == $'\177' ]]
|
||||
then
|
||||
if [ $charcount -gt 0 ]
|
||||
then
|
||||
charcount=$((charcount-1))
|
||||
prompt=$'\b \b'
|
||||
password="${password%?}"
|
||||
else
|
||||
prompt=''
|
||||
fi
|
||||
else
|
||||
charcount=$((charcount+1))
|
||||
prompt='*'
|
||||
password+="$char"
|
||||
fi
|
||||
done
|
||||
|
||||
stty echo
|
||||
|
||||
}
|
||||
|
||||
|
||||
set_shell()
|
||||
{
|
||||
|
||||
optionsAudits=($(cat /etc/shells | grep "zsh\|/bash" | sed 's/\/bin\///g' | sed 's/\/usr//g' | uniq))
|
||||
USER_SHELL="bash"
|
||||
|
||||
if [[ "${#optionsAudits[@]}" -gt 1 ]]; then
|
||||
while :
|
||||
do
|
||||
i=1
|
||||
echo -e "\nChoose default system command shell:\n"
|
||||
for o in "${optionsAudits[@]}"; do
|
||||
echo "$i) $o"
|
||||
let i++
|
||||
done
|
||||
read -n1 -s reply
|
||||
case $reply in
|
||||
"1"|"${optionsAudits[0]}") USER_SHELL="${optionsAudits[0]}"; break;;
|
||||
"2"|"${optionsAudits[1]}") USER_SHELL="${optionsAudits[1]}"; break;;
|
||||
*) USER_SHELL="${optionsAudits[0]}"; break;;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
SHELL_PATH=$(grep /$USER_SHELL$ /etc/shells | tail -1)
|
||||
|
||||
chsh -s $(grep -iF "/$USER_SHELL" /etc/shells | tail -1)
|
||||
echo -e "\nShell: \x1B[92m${USER_SHELL^^}\x1B[0m"
|
||||
|
||||
# change shell for future users
|
||||
sed -i "s|^SHELL=.*|SHELL=${SHELL_PATH}|" /etc/default/useradd
|
||||
sed -i "s|^DSHELL=.*|DSHELL=${SHELL_PATH}|" /etc/adduser.conf
|
||||
|
||||
}
|
||||
|
||||
set_timezone_and_locales()
|
||||
{
|
||||
|
||||
# Grab this machine's public IP address
|
||||
PUBLIC_IP=`curl --max-time 5 -s https://ipinfo.io/ip`
|
||||
if [ $? -eq 0 ]; then
|
||||
|
||||
# Call the geolocation API and capture the output
|
||||
RES=$(
|
||||
curl --max-time 5 -s http://ipwhois.app/json/${PUBLIC_IP} | \
|
||||
jq '.timezone, .country, .country_code' | \
|
||||
while read -r TIMEZONE; do
|
||||
read -r COUNTRY
|
||||
echo "${TIMEZONE},${COUNTRY},${COUNTRYCODE}" | tr --delete \"
|
||||
done
|
||||
)
|
||||
# Check if we have wireless adaptor
|
||||
WIFI_DEVICE=$(LC_ALL=C nmcli dev status | grep " wifi " 2>/dev/null)
|
||||
|
||||
TZDATA=$(echo ${RES} | cut -d"," -f1)
|
||||
STATE=$(echo ${RES} | cut -d"," -f2)
|
||||
LOCALES=$(grep territory /usr/share/i18n/locales/* | grep "$STATE" | cut -d ":" -f 1 | cut -d "/" -f 6 | xargs -I{} grep {} /usr/share/i18n/SUPPORTED | grep "\.UTF-8" | cut -d " " -f 1)
|
||||
CCODE=$(echo ${RES} | cut -d"," -f3 | awk '{print tolower($0)}' | xargs)
|
||||
options=(`echo ${LOCALES}`);
|
||||
if [ -z "$PUBLIC_IP" ]; then
|
||||
|
||||
# ask for connecting to wireless if wifi device is found
|
||||
if [[ -n "$WIFI_DEVICE" ]]; then
|
||||
echo -e "Internet connection was \x1B[91mnot detected\x1B[0m."
|
||||
echo ""
|
||||
read -n1 -s -r -p "Connect via wireless? [Y/n] " response
|
||||
echo ""
|
||||
if [[ "${response}" =~ ^(Y|y|"")$ ]]; then
|
||||
nmtui-connect
|
||||
fi
|
||||
echo ""
|
||||
fi
|
||||
fi
|
||||
|
||||
# Grab IP once again if not found
|
||||
[[ -z "$PUBLIC_IP" && -n "$WIFI_DEVICE" ]] && PUBLIC_IP=`curl --max-time 5 -s https://ipinfo.io/ip`
|
||||
|
||||
# Call the geolocation API and capture the output
|
||||
RES=$(
|
||||
curl --max-time 5 -s http://ipwhois.app/json/${PUBLIC_IP} | \
|
||||
jq '.timezone, .country, .country_code' | \
|
||||
while read -r TIMEZONE; do
|
||||
read -r COUNTRY
|
||||
echo "${TIMEZONE},${COUNTRY},${COUNTRYCODE}" | tr --delete \"
|
||||
done
|
||||
)
|
||||
|
||||
TZDATA=$(echo ${RES} | cut -d"," -f1)
|
||||
STATE=$(echo ${RES} | cut -d"," -f2)
|
||||
CCODE=$(echo ${RES} | cut -d"," -f3 | xargs)
|
||||
echo -e "Detected timezone: \x1B[92m$TZDATA\x1B[0m"
|
||||
echo ""
|
||||
unset response
|
||||
while [[ ! "${response}" =~ ^(Y|y|N|n)$ ]]; do
|
||||
read -n1 -s -r -p "Set user language based on your location? [Y/n] " response
|
||||
echo ""
|
||||
done
|
||||
# change it only if we have a match and if we agree
|
||||
if [[ "${response}" =~ ^(N|n)$ ]]; then
|
||||
unset CCODE TZDATA
|
||||
fi
|
||||
|
||||
LOCALES=$(grep territory /usr/share/i18n/locales/* | grep _"$CCODE" | cut -d ":" -f 1 | cut -d "/" -f 6 | \
|
||||
xargs -I{} grep {} /usr/share/i18n/SUPPORTED | grep "\.UTF-8" | cut -d " " -f 1)
|
||||
# UTF8 is not present everywhere so check again in case it returns empty value
|
||||
[[ -z "$LOCALES" ]] && LOCALES=$(grep territory /usr/share/i18n/locales/* | grep _"$CCODE" | cut -d ":" -f 1 | cut -d "/" -f 6 | \
|
||||
xargs -I{} grep {} /usr/share/i18n/SUPPORTED | cut -d " " -f 1)
|
||||
|
||||
options=(`echo ${LOCALES}`);
|
||||
|
||||
# when having more locales, prompt for choosing one
|
||||
if [[ "${#options[@]}" -gt 1 ]]; then
|
||||
|
||||
options+=("Skip generating locales")
|
||||
echo -e "\nAt your location, more locales are possible:\n"
|
||||
PS3='Please enter your choice:'
|
||||
select opt in "${options[@]}"
|
||||
do
|
||||
if [[ " ${options[@]} " =~ " ${opt} " ]]; then
|
||||
LOCALES=${opt}
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ "${LOCALES}" != *Skip* ]]; then
|
||||
|
||||
# if TZDATA was not detected, we need to select one
|
||||
if [[ -z ${TZDATA} ]]; then
|
||||
TZDATA=$(tzselect | tail -1)
|
||||
fi
|
||||
|
||||
# reconfigure tzdata
|
||||
timedatectl set-timezone "${TZDATA}"
|
||||
dpkg-reconfigure --frontend=noninteractive tzdata > /dev/null 2>&1
|
||||
|
||||
echo -e "Detected timezone: \x1B[92m$(LC_ALL=C timedatectl | grep "Time zone" | cut -d":" -f2 | xargs)\x1B[0m"
|
||||
echo -e "Do you want to set locales and console keyboard automatically from your location [Y/n]"
|
||||
read -sn1 SetLocales
|
||||
if [ "$SetLocales" != "n" ] && [ "$SetLocales" != "N" ]; then
|
||||
# generate locales
|
||||
echo ""
|
||||
sed -i 's/# '"${LOCALES}"'/'"${LOCALES}"'/' /etc/locale.gen
|
||||
echo -e "Generating locales: \x1B[92m${LOCALES}\x1B[0m"
|
||||
locale-gen "${LOCALES}" > /dev/null 2>&1
|
||||
|
||||
# when having more locales, prompt for choosing one
|
||||
if [[ "${#options[@]}" -gt 1 ]]; then
|
||||
|
||||
echo -e "\nAt your location, more locales are possible:\n"
|
||||
PS3='Please enter your choice:'
|
||||
select opt in "${options[@]}"
|
||||
do
|
||||
if [[ " ${options[@]} " =~ " ${opt} " ]]; then
|
||||
LOCALES=${opt}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
fi
|
||||
|
||||
# generate locales
|
||||
sed -i 's/# '"${LOCALES}"'/'"${LOCALES}"'/' /etc/locale.gen
|
||||
echo -e "Generating locales: \x1B[92m${LOCALES}\x1B[0m"
|
||||
locale-gen $LOCALES > /dev/null 2>&1
|
||||
update-locale LANG=$LOCALES LANGUAGE=$LOCALES LC=$LOCALES LC_MESSAGES=$LOCALES
|
||||
|
||||
# setting up keyboard
|
||||
echo -e "Console keyboard layout: \x1B[92m$CCODE\x1B[0m"
|
||||
sed -i "s/XKBLAYOUT=.*/XKBLAYOUT=\"$CCODE\"/" /etc/default/keyboard
|
||||
setupcon -k --force
|
||||
else
|
||||
|
||||
echo -e "You can use \x1B[92morangepi-config\x1B[0m to set locales and console keyboard."
|
||||
|
||||
fi
|
||||
# setting detected locales only for user
|
||||
echo "export LC_ALL=$LOCALES" >> /home/"$RealUserName"/.bashrc
|
||||
echo "export LANG=$LOCALES" >> /home/"$RealUserName"/.bashrc
|
||||
echo "export LANGUAGE=$LOCALES" >> /home/"$RealUserName"/.bashrc
|
||||
echo "export LC_ALL=$LOCALES" >> /home/"$RealUserName"/.xsessionrc
|
||||
echo "export LANG=$LOCALES" >> /home/"$RealUserName"/.xsessionrc
|
||||
echo "export LANGUAGE=$LOCALES" >> /home/"$RealUserName"/.xsessionrc
|
||||
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
add_profile_sync_settings()
|
||||
{
|
||||
/usr/bin/psd >/dev/null 2>&1
|
||||
@@ -126,72 +226,105 @@ add_profile_sync_settings()
|
||||
|
||||
|
||||
|
||||
|
||||
add_user()
|
||||
{
|
||||
read -t 0 temp
|
||||
|
||||
REPEATS=3
|
||||
while [ -f "/root/.not_logged_in_yet" ]; do
|
||||
echo -e "\nPlease provide a username (eg. your forename): \c"
|
||||
echo -e "\nPlease provide a username (eg. your first name): \c"
|
||||
read -e username
|
||||
if ! grep '^[a-zA-Z]*$' <<< $username > /dev/null ; then
|
||||
echo -e "\n\x1B[91mError\x1B[0m: illegal characters in username"
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
RealUserName="$(echo "$username" | tr '[:upper:]' '[:lower:]' | tr -d -c '[:alnum:]')"
|
||||
[ -z "$RealUserName" ] && return
|
||||
if ! id "$RealUserName" >/dev/null 2>&1; then break; else echo -e "Username \e[0;31m$RealUserName\x1B[0m already exists on the system."; fi
|
||||
done
|
||||
|
||||
while [ -f "/root/.not_logged_in_yet" ]; do
|
||||
read_password "Create"
|
||||
first_input=$password
|
||||
read_password "Create user ($username)"
|
||||
first_input="$password"
|
||||
echo ""
|
||||
read_password "Repeat"
|
||||
second_input=$password
|
||||
read_password "Repeat user ($username)"
|
||||
second_input="$password"
|
||||
echo ""
|
||||
if [[ $first_input == $second_input ]]; then
|
||||
result="$(cracklib-check <<<"$password")"
|
||||
okay="$(awk -F': ' '{ print $2}' <<<"$result")"
|
||||
if [[ "$okay" == "OK" ]]; then
|
||||
echo -e "\nPlease provide your real name (eg. John Doe): \c"
|
||||
read -e RealName
|
||||
adduser --quiet --disabled-password --shell /bin/bash --home /home/"$RealUserName" --gecos "$RealName" "$RealUserName"
|
||||
(echo $first_input;echo $second_input;) | passwd "$RealUserName" >/dev/null 2>&1
|
||||
if [[ "$first_input" == "$second_input" ]]; then
|
||||
result="$(cracklib-check <<<"$password")"
|
||||
okay="$(awk -F': ' '{ print $2}' <<<"$result")"
|
||||
if [[ "$okay" == "OK" ]]; then
|
||||
echo -e ""
|
||||
read -e -p "Please provide your real name: " -i "${RealUserName^}" RealName
|
||||
|
||||
adduser --quiet --disabled-password --home /home/"$RealUserName" --gecos "$RealName" "$RealUserName"
|
||||
(echo "$first_input";echo "$second_input";) | passwd "$RealUserName" >/dev/null 2>&1
|
||||
for additionalgroup in sudo netdev audio video disk tty users games dialout plugdev input bluetooth systemd-journal ssh; do
|
||||
usermod -aG ${additionalgroup} ${RealUserName} 2>/dev/null
|
||||
usermod -aG "${additionalgroup}" "${RealUserName}" 2>/dev/null
|
||||
done
|
||||
|
||||
# fix for gksu in Xenial
|
||||
touch /home/$RealUserName/.Xauthority
|
||||
chown $RealUserName:$RealUserName /home/$RealUserName/.Xauthority
|
||||
touch /home/"$RealUserName"/.Xauthority
|
||||
chown "$RealUserName":"$RealUserName" /home/"$RealUserName"/.Xauthority
|
||||
RealName="$(awk -F":" "/^${RealUserName}:/ {print \$5}" </etc/passwd | cut -d',' -f1)"
|
||||
[ -z "$RealName" ] && RealName=$RealUserName
|
||||
[ -z "$RealName" ] && RealName="$RealUserName"
|
||||
echo -e "\nDear \e[0;92m${RealName}\x1B[0m, your account \e[0;92m${RealUserName}\x1B[0m has been created and is sudo enabled."
|
||||
echo -e "Please use this account for your daily work from now on.\n"
|
||||
rm -f /root/.not_logged_in_yet
|
||||
|
||||
chmod +x /etc/update-motd.d/*
|
||||
# set up profile sync daemon on desktop systems
|
||||
which psd >/dev/null 2>&1
|
||||
command -v psd >/dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
echo -e "${RealUserName} ALL=(ALL) NOPASSWD: /usr/bin/psd-overlay-helper" >> /etc/sudoers
|
||||
touch /home/${RealUserName}/.activate_psd
|
||||
chown $RealUserName:$RealUserName /home/${RealUserName}/.activate_psd
|
||||
touch /home/"${RealUserName}"/.activate_psd
|
||||
chown "$RealUserName":"$RealUserName" /home/"${RealUserName}"/.activate_psd
|
||||
fi
|
||||
break
|
||||
break
|
||||
else
|
||||
echo -e "Rejected - \e[0;31m$okay.\x1B[0m Try again."
|
||||
fi
|
||||
elif [[ -n $password ]]; then
|
||||
echo -e "Rejected - \e[0;31mpasswords do not match.\x1B[0m Try again."
|
||||
fi
|
||||
done
|
||||
echo -e "Rejected - \e[0;31m$okay.\x1B[0m Try again [${REPEATS}]."
|
||||
REPEATS=$((REPEATS - 1))
|
||||
fi
|
||||
elif [[ -n $password ]]; then
|
||||
echo -e "Rejected - \e[0;31mpasswords do not match.\x1B[0m Try again [${REPEATS}]."
|
||||
REPEATS=$((REPEATS - 1))
|
||||
fi
|
||||
[[ "$REPEATS" -eq 0 ]] && exit
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then
|
||||
|
||||
# disable autologin
|
||||
#rm -f /etc/systemd/system/getty@.service.d/override.conf
|
||||
#rm -f /etc/systemd/system/serial-getty@.service.d/override.conf
|
||||
#systemctl daemon-reload
|
||||
|
||||
# detect lightdm
|
||||
# detect display manager
|
||||
#desktop_lightdm=$(dpkg-query -W -f='${db:Status-Abbrev}\n' lightdm 2>/dev/null)
|
||||
#desktop_gdm3=$(dpkg-query -W -f='${db:Status-Abbrev}\n' gdm3 2>/dev/null)
|
||||
|
||||
#echo -e "\nWaiting for system to finish booting ...\n"
|
||||
|
||||
#systemctl is-system-running --wait >/dev/null
|
||||
|
||||
#if [ "$IMAGE_TYPE" != "nightly" ]; then
|
||||
# if [ "$BRANCH" == "dev" ]; then
|
||||
# echo -e "\nYou are using an Orange Pi preview build !!!"
|
||||
# echo -e "\nThis image is provided \e[0;31mAS IS\x1B[0m with \e[0;31mNO WARRANTY\x1B[0m and \e[0;31mNO END USER SUPPORT!\x1B[0m.\n"
|
||||
# elif [ "$DISTRIBUTION_STATUS" != "supported" ]; then
|
||||
# echo -e "\nYou are using an Orange Pi with unsupported ($DISTRIBUTION_CODENAME) userspace !!!"
|
||||
# echo -e "\nThis image is provided \e[0;31mAS IS\x1B[0m with \e[0;31mNO WARRANTY\x1B[0m and \e[0;31mNO END USER SUPPORT!\x1B[0m.\n"
|
||||
# fi
|
||||
#else
|
||||
# echo -e "\nYou are using an Orange Pi nightly build meant only for developers to provide"
|
||||
# echo -e "constructive feedback to improve build system, OS settings or user experience."
|
||||
# echo -e "If this does not apply to you, \e[0;31mSTOP NOW!\x1B[0m. Especially don't use this image for"
|
||||
# echo -e "daily work since things might not work as expected or at all and may break"
|
||||
# echo -e "anytime with next update. \e[0;31mYOU HAVE BEEN WARNED!\x1B[0m"
|
||||
# echo -e "\nThis image is provided \e[0;31mAS IS\x1B[0m with \e[0;31mNO WARRANTY\x1B[0m and \e[0;31mNO END USER SUPPORT!\x1B[0m.\n"
|
||||
#fi
|
||||
|
||||
echo -e "New to Orange Pi? Support: \e[1m\e[39mhttp://www.orangepi.org\x1B[0m\n"
|
||||
|
||||
@@ -214,7 +347,6 @@ if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then
|
||||
# okay="$(awk -F': ' '{ print $2}' <<<"$result")"
|
||||
# if [[ "$okay" == "OK" ]]; then
|
||||
# (echo $first_input;echo $second_input;) | passwd root >/dev/null 2>&1
|
||||
# set_timezone_and_locales
|
||||
# break
|
||||
# else
|
||||
# echo -e "Rejected - \e[0;31m$okay.\x1B[0m Try again."
|
||||
@@ -225,50 +357,124 @@ if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then
|
||||
#done
|
||||
#trap - INT TERM EXIT
|
||||
|
||||
# ask user to select shell
|
||||
#trap '' 2
|
||||
#set_shell
|
||||
#trap - INT TERM EXIT
|
||||
|
||||
#trap check_abort INT
|
||||
|
||||
#while [ -f "/root/.not_logged_in_yet" ]; do
|
||||
# echo -e "\nCreating a new user account. Press <Ctrl-C> to abort"
|
||||
# [ -n "$desktop_lightdm" ] && echo "Desktop environment will not be enabled if you abort the new user creation"
|
||||
# [ -n "$desktop_lightdm" ] && echo -e "\n\e[0;31mDesktop environment will not be enabled if you abort the new user creation\x1B[0m"
|
||||
# add_user
|
||||
#done
|
||||
#trap - INT TERM EXIT
|
||||
|
||||
rm -f /root/.not_logged_in_yet
|
||||
## ask user to select automated locales or not
|
||||
#trap '' 2
|
||||
#set_timezone_and_locales
|
||||
#trap - INT TERM EXIT
|
||||
|
||||
#if [[ ${USER_SHELL} == zsh ]]; then
|
||||
# printf "\nYou selected \e[0;91mZSH\x1B[0m as your default shell. If you want to use it right away, please logout and login! \n\n"
|
||||
#fi
|
||||
|
||||
# check whether desktop environment has to be considered
|
||||
#if [ -n "$desktop_lightdm" ]; then
|
||||
#if [ -n "$desktop_lightdm" ] && [ -n "$RealName" ] ; then
|
||||
|
||||
# # 1st run goes without login
|
||||
# mkdir -p /etc/lightdm/lightdm.conf.d
|
||||
# cat <<-EOF > /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf
|
||||
# [Seat:*]
|
||||
# autologin-user=$RealUserName
|
||||
# autologin-user-timeout=0
|
||||
# user-session=xfce
|
||||
# EOF
|
||||
#
|
||||
# ln -sf /lib/systemd/system/lightdm.service /etc/systemd/system/display-manager.service
|
||||
# if [[ -f /var/run/resize2fs-reboot ]]; then
|
||||
# # Let the user reboot now otherwise start desktop environment
|
||||
# printf "\n\n\e[0;91mWarning: a reboot is needed to finish resizing the filesystem \x1B[0m \n"
|
||||
# printf "\e[0;91mPlease reboot the system now \x1B[0m \n\n"
|
||||
# elif [ -z "$ConfigureDisplay" ] || [ "$ConfigureDisplay" = "n" ] || [ "$ConfigureDisplay" = "N" ]; then
|
||||
# echo -e "\n\e[1m\e[39mNow starting desktop environment...\x1B[0m\n"
|
||||
# sleep 1
|
||||
# service lightdm start 2>/dev/null
|
||||
# if [ -f /root/.desktop_autologin ]; then
|
||||
# rm /root/.desktop_autologin
|
||||
# else
|
||||
# (sleep 20; rm /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf) &
|
||||
# # 1st run goes without login
|
||||
# mkdir -p /etc/lightdm/lightdm.conf.d
|
||||
# cat <<-EOF > /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf
|
||||
# [Seat:*]
|
||||
# autologin-user=$RealUserName
|
||||
# autologin-user-timeout=0
|
||||
# user-session=xfce
|
||||
# EOF
|
||||
|
||||
# # select gnome session (has to be first or it breaks budgie/cinnamon desktop autologin and user-session)
|
||||
# [[ -x $(which gnome-session) ]] && sed -i "s/user-session.*/user-session=ubuntu/" /etc/lightdm/lightdm.conf.d/11-orangepi.conf
|
||||
# [[ -x $(which gnome-session) ]] && sed -i "s/user-session.*/user-session=ubuntu/" /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf
|
||||
|
||||
# # select budgie session
|
||||
# [[ -x $(which budgie-desktop) ]] && sed -i "s/user-session.*/user-session=budgie-desktop/" /etc/lightdm/lightdm.conf.d/11-orangepi.conf
|
||||
# [[ -x $(which budgie-desktop) ]] && sed -i "s/user-session.*/user-session=budgie-desktop/" /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf
|
||||
|
||||
# # select deepin session
|
||||
# [[ -x $(which deepin-wm) ]] && sed -i "s/user-session.*/user-session=deepin/" /etc/lightdm/lightdm.conf.d/11-orangepi.conf
|
||||
# [[ -x $(which deepin-wm) ]] && sed -i "s/user-session.*/user-session=deepin/" /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf
|
||||
|
||||
# # select cinnamon session
|
||||
# [[ -x $(which cinnamon) ]] && sed -i "s/user-session.*/user-session=cinnamon/" /etc/lightdm/lightdm.conf.d/11-orangepi.conf
|
||||
# [[ -x $(which cinnamon) ]] && sed -i "s/user-session.*/user-session=cinnamon/" /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf
|
||||
|
||||
# # select mate session
|
||||
# [[ -x $(which mate-wm) ]] && sed -i "s/user-session.*/user-session=mate/" /etc/lightdm/lightdm.conf.d/11-orangepi.conf
|
||||
# [[ -x $(which mate-wm) ]] && sed -i "s/user-session.*/user-session=mate/" /etc/lightdm/lightdm.conf.d/22-orangepi-autologin.conf
|
||||
|
||||
# ln -sf /lib/systemd/system/lightdm.service /etc/systemd/system/display-manager.service
|
||||
|
||||
# if [[ -f /var/run/resize2fs-reboot ]]; then
|
||||
# # Let the user reboot now otherwise start desktop environment
|
||||
# printf "\n\n\e[0;91mWarning: a reboot is needed to finish resizing the filesystem \x1B[0m \n"
|
||||
# printf "\e[0;91mPlease reboot the system now \x1B[0m \n\n"
|
||||
# elif [ -z "$ConfigureDisplay" ] || [ "$ConfigureDisplay" = "n" ] || [ "$ConfigureDisplay" = "N" ]; then
|
||||
# echo -e "\n\e[1m\e[39mNow starting desktop environment...\x1B[0m\n"
|
||||
# sleep 1
|
||||
# service lightdm start 2>/dev/null
|
||||
# if [ -f /root/.desktop_autologin ]; then
|
||||
# rm /root/.desktop_autologin
|
||||
# else
|
||||
# systemctl -q enable orangepi-disable-autologin.timer
|
||||
# systemctl start orangepi-disable-autologin.timer
|
||||
# fi
|
||||
# # logout if logged at console
|
||||
# [[ -n $(who -la | grep root | grep tty1) ]] && exit 1
|
||||
# fi
|
||||
# # logout if logged at console
|
||||
# #[[ -n $(who -la | grep root | grep tty1) ]] && exit 1
|
||||
# fi
|
||||
|
||||
#elif [ -n "$desktop_gdm3" ] && [ -n "$RealName" ] ; then
|
||||
|
||||
# # 1st run goes without login
|
||||
# mkdir -p /etc/gdm3
|
||||
# cat <<-EOF > /etc/gdm3/custom.conf
|
||||
# [daemon]
|
||||
# AutomaticLoginEnable = true
|
||||
# AutomaticLogin = $RealUserName
|
||||
# EOF
|
||||
|
||||
# ln -sf /lib/systemd/system/gdm3.service /etc/systemd/system/display-manager.service
|
||||
|
||||
# if [[ -f /var/run/resize2fs-reboot ]]; then
|
||||
|
||||
# # Let the user reboot now otherwise start desktop environment
|
||||
# printf "\n\n\e[0;91mWarning: a reboot is needed to finish resizing the filesystem \x1B[0m \n"
|
||||
# printf "\e[0;91mPlease reboot the system now \x1B[0m \n\n"
|
||||
|
||||
# elif [ -z "$ConfigureDisplay" ] || [ "$ConfigureDisplay" = "n" ] || [ "$ConfigureDisplay" = "N" ]; then
|
||||
|
||||
# echo -e "\n\e[1m\e[39mNow starting desktop environment...\x1B[0m\n"
|
||||
# sleep 1
|
||||
# service gdm3 start 2>/dev/null
|
||||
# if [ -f /root/.desktop_autologin ]; then
|
||||
# rm /root/.desktop_autologin
|
||||
# else
|
||||
# (sleep 20; sed -i "s/AutomaticLoginEnable.*/AutomaticLoginEnable = false/" /etc/gdm3/custom.conf) &
|
||||
# fi
|
||||
# # logout if logged at console
|
||||
# [[ -n $(who -la | grep root | grep tty1) ]] && exit 1
|
||||
|
||||
# fi
|
||||
|
||||
#else
|
||||
|
||||
# # Display reboot recommendation if necessary
|
||||
# if [[ -f /var/run/resize2fs-reboot ]]; then
|
||||
# printf "\n\n\e[0;91mWarning: a reboot is needed to finish resizing the filesystem \x1B[0m \n"
|
||||
# printf "\e[0;91mPlease reboot the system now \x1B[0m \n\n"
|
||||
# fi
|
||||
|
||||
#fi
|
||||
|
||||
rm -f /root/.not_logged_in_yet
|
||||
|
||||
fi
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
@@ -19,17 +19,11 @@ case "$1" in
|
||||
cpu_cores=$(grep -c '^processor' /proc/cpuinfo | sed 's/^0$/1/')
|
||||
|
||||
# adjust custom htop initial configuration based on CPU count https://github.com/avafinger/htop-2.1.1_enhanced-version
|
||||
right_meters="Hostname Tasks LoadAverage Uptime"
|
||||
right_meter_modes="2 2 2 2"
|
||||
x=1
|
||||
until [ $x -gt $cpu_cores ]; do
|
||||
right_meters=$right_meters" CpuFreq($x)"
|
||||
right_meter_modes=$right_meter_modes" 2"
|
||||
let x+=1
|
||||
done
|
||||
right_meters="Hostname Tasks LoadAverage DiskIO NetworkIO Uptime Systemd CpuFreq"
|
||||
right_meter_modes="2 2 2 2 2 2 2 2"
|
||||
sed -i 's/header_margin=.*/header_margin=1/g' /etc/skel/.config/htop/htoprc
|
||||
sed -i 's/left_meters=.*/left_meters=AllCPUs Memory Swap CpuTemp/g' /etc/skel/.config/htop/htoprc
|
||||
sed -i 's/left_meter_modes=.*/left_meter_modes=1 1 1 2/g' /etc/skel/.config/htop/htoprc
|
||||
sed -i 's/left_meters=.*/left_meters=AllCPUs Memory Zram Swap CpuTemp/g' /etc/skel/.config/htop/htoprc
|
||||
sed -i 's/left_meter_modes=.*/left_meter_modes=1 1 1 1 2/g' /etc/skel/.config/htop/htoprc
|
||||
sed -i "s/right_meters=.*/right_meters=$right_meters/g" /etc/skel/.config/htop/htoprc
|
||||
sed -i "s/right_meter_modes=.*/right_meter_modes=$right_meter_modes/g" /etc/skel/.config/htop/htoprc
|
||||
# copy predefined settings for root user
|
||||
@@ -108,7 +102,8 @@ case "$1" in
|
||||
esac
|
||||
|
||||
# varios temporary hardware workarounds
|
||||
[[ $LINUXFAMILY == rk3399 ]] && set_fixed_mac
|
||||
#[[ $LINUXFAMILY == rk3399 || $LINUXFAMILY == rockchip64 ]] && [[ $BOARD != helios64 && $BOARD != khadas-edge ]] && set_fixed_mac
|
||||
#[[ $LINUXFAMILY == rk3399 ]] && set_fixed_mac
|
||||
systemctl disable orangepi-firstrun
|
||||
exit 0
|
||||
;;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
@@ -15,9 +15,13 @@
|
||||
|
||||
# Read in basic OS image information
|
||||
. /etc/orangepi-release
|
||||
|
||||
# and script configuration
|
||||
. /usr/lib/orangepi/orangepi-common
|
||||
|
||||
# set audio
|
||||
#. /usr/lib/orangepi/orangepi-audio-config
|
||||
|
||||
set_io_scheduler() {
|
||||
|
||||
# Convert kernel version to integer
|
||||
@@ -48,12 +52,12 @@ prepare_board() {
|
||||
|
||||
CheckDevice=$(for i in /var/log /var / ; do findmnt -n -o SOURCE $i && break ; done)
|
||||
# adjust logrotate configs
|
||||
if [[ "${CheckDevice}" == "/dev/zram0" || "${CheckDevice}" == "orangepi-ramlog" ]]; then
|
||||
for ConfigFile in /etc/logrotate.d/* ; do sed -i -e "s/\/log\//\/log.hdd\//g" "${ConfigFile}"; done
|
||||
sed -i "s/\/log\//\/log.hdd\//g" /etc/logrotate.conf
|
||||
if [[ "${CheckDevice}" == *"/dev/zram"* || "${CheckDevice}" == "orangepi-ramlog" ]]; then
|
||||
for ConfigFile in /etc/logrotate.d/* ; do sed -i -e "s/\/var\/log\//\/var\/log.hdd\//g" "${ConfigFile}"; done
|
||||
sed -i "s/\/var\/log\//\/var\/log.hdd\//g" /etc/logrotate.conf
|
||||
else
|
||||
for ConfigFile in /etc/logrotate.d/* ; do sed -i -e "s/\/log.hdd\//\/log\//g" "${ConfigFile}"; done
|
||||
sed -i "s/\/log.hdd\//\/log\//g" /etc/logrotate.conf
|
||||
for ConfigFile in /etc/logrotate.d/* ; do sed -i -e "s/\/var\/log.hdd\//\/var\/log\//g" "${ConfigFile}"; done
|
||||
sed -i "s/\/var\/log.hdd\//\/var\/log\//g" /etc/logrotate.conf
|
||||
fi
|
||||
|
||||
# unlock cpuinfo_cur_freq to be accesible by a normal user
|
||||
@@ -67,7 +71,7 @@ prepare_board() {
|
||||
[[ -f $prefix/cpuinfo_cur_freq ]] && chmod +r $prefix/cpuinfo_cur_freq 2> /dev/null
|
||||
|
||||
# enable compression where not exists
|
||||
find /etc/logrotate.d/. -type f | xargs grep -H -c 'compress' | grep 0$ | cut -d':' -f1 | xargs -L1 sed -i '/{/ a compress'
|
||||
find /etc/logrotate.d/. -type f | xargs grep -H -c 'compress' | grep 0$ | cut -d':' -f1 | xargs -r -L1 sed -i '/{/ a compress'
|
||||
sed -i "s/#compress/compress/" /etc/logrotate.conf
|
||||
|
||||
# tweak ondemand cpufreq governor settings to increase cpufreq with IO load
|
||||
@@ -85,12 +89,38 @@ prepare_board() {
|
||||
done
|
||||
fi
|
||||
|
||||
chmod +x /etc/update-motd.d/*
|
||||
|
||||
# IRQ distribution based on $BOARDFAMILY and/or $BOARD_NAME
|
||||
case ${BOARD} in
|
||||
|
||||
rockpro64|renegade-elite|pinebook-pro|station-p1)
|
||||
BOARDFAMILY=rk3399
|
||||
;;
|
||||
orangepi3-lts)
|
||||
|
||||
#aplay /usr/share/sounds/alsa/audio.wav -D hw:0,0 > /dev/null 2>&1
|
||||
rfkill unblock all
|
||||
/usr/bin/hciattach_opi -n -s 1500000 /dev/ttyBT0 sprd &
|
||||
;;
|
||||
orangepi800)
|
||||
[[ -f /sys/class/leds/caps_led/brightness ]] && chmod 666 /sys/class/leds/caps_led/brightness
|
||||
[[ -f /sys/class/leds/num_led/brightness ]] && chmod 666 /sys/class/leds/num_led/brightness
|
||||
|
||||
CODEC_CARD=1
|
||||
amixer -c ${CODEC_CARD} cset name='Headphone Playback Volume' 11 > /dev/null 2>&1
|
||||
amixer -c ${CODEC_CARD} cset name='DAC Playback Volume' 170 > /dev/null 2>&1
|
||||
amixer -c ${CODEC_CARD} cset name='ADC Capture Volume' 190 >/dev/null 2>&1
|
||||
amixer -c ${CODEC_CARD} cset name='Differential Mux' 1 >/dev/null 2>&1
|
||||
|
||||
if [[ -c /dev/mpp_service ]]; then
|
||||
chmod 666 /dev/mpp_service
|
||||
|
||||
# Create dummy video node for chromium V4L2 VDA/VEA with rkmpp plugin
|
||||
echo dec > /dev/video-dec0
|
||||
echo enc > /dev/video-enc0
|
||||
chmod 660 /dev/video-*
|
||||
chown root.video /dev/video-*
|
||||
fi
|
||||
|
||||
rfkill unblock all
|
||||
/usr/bin/hciattach_opi -n -s 1500000 /dev/ttyBT0 sprd &
|
||||
@@ -102,7 +132,7 @@ prepare_board() {
|
||||
|
||||
/usr/bin/pwm-fan.sh &
|
||||
;;
|
||||
orangepizero2|orangepizero2-lts|orangepizero2-b)
|
||||
orangepizero2|orangepizero2-lts|orangepizero2-b|orangepi400)
|
||||
if [[ $BRANCH == current ]]; then
|
||||
# Initial hdmi audio
|
||||
aplay /usr/share/sounds/alsa/audio.wav -D hw:0,0 > /dev/null 2>&1
|
||||
@@ -116,9 +146,75 @@ prepare_board() {
|
||||
rfkill unblock all
|
||||
/usr/bin/hciattach_opi -n -s 1500000 /dev/ttyBT0 sprd &
|
||||
;;
|
||||
orangepi400)
|
||||
rfkill unblock all
|
||||
/usr/bin/hciattach_opi -n -s 1500000 /dev/ttyBT0 sprd &
|
||||
|
||||
[[ -f /sys/class/leds/caps_led/brightness ]] && chmod 666 /sys/class/leds/caps_led/brightness
|
||||
[[ -f /sys/class/leds/num_led/brightness ]] && chmod 666 /sys/class/leds/num_led/brightness
|
||||
;;
|
||||
orangepi4-lts)
|
||||
# RK3399 - 1.8GHz
|
||||
# RK3399-T - 1.6GHz
|
||||
sed -i "s/MAX_SPEED=.*/MAX_SPEED=$(cpufreq-info -c 4 -l | awk '{ print $2 }')/" /etc/default/cpufrequtils
|
||||
|
||||
CODEC_CARD=0
|
||||
amixer -c ${CODEC_CARD} cset name='Differential Mux' 1 >/dev/null 2>&1
|
||||
|
||||
if [[ -c /dev/mpp_service ]]; then
|
||||
chmod 666 /dev/mpp_service
|
||||
|
||||
elif [[ -c /dev/vpu_service ]]; then
|
||||
chmod 666 /dev/vpu_service
|
||||
fi
|
||||
|
||||
# Create dummy video node for chromium V4L2 VDA/VEA with rkmpp plugin
|
||||
echo dec > /dev/video-dec0
|
||||
echo enc > /dev/video-enc0
|
||||
chmod 660 /dev/video-*
|
||||
chown root.video /dev/video-*
|
||||
|
||||
rfkill unblock all
|
||||
/usr/bin/hciattach_opi -n -s 1500000 /dev/ttyBT0 sprd &
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
case ${BOARDFAMILY} in
|
||||
rockchip) # RK3288: usb1 on cpu1, usb3 (EHCI) on cpu2, eth0 and GPU on cpu3
|
||||
echo 2 >/proc/irq/$(awk -F":" "/usb1/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity
|
||||
echo 4 >/proc/irq/$(awk -F":" "/usb3/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity
|
||||
echo 8 >/proc/irq/$(awk -F":" "/eth0/ {print \$1}" </proc/interrupts | sed 's/\ //g' | head -n1)/smp_affinity
|
||||
echo 7 >/sys/class/net/eth0/queues/rx-0/rps_cpus
|
||||
for i in $(awk -F':' '/gpu/{print $1}' /proc/interrupts | sed 's/\ //g'); do
|
||||
echo 8 >/proc/irq/$i/smp_affinity
|
||||
done
|
||||
;;
|
||||
rockchip64) # Rock64 and Renegade: GPU on cpu1, USB3 on cpu2, Ethernet on cpu3
|
||||
for i in $(awk -F':' '/Mali/{print $1}' </proc/interrupts | sed 's/\ //g'); do
|
||||
echo 2 >/proc/irq/$i/smp_affinity
|
||||
done
|
||||
for i in $(awk -F":" "/ehci/ {print \$1}" </proc/interrupts | sed 's/\ //g'); do
|
||||
echo 2 >/proc/irq/$i/smp_affinity
|
||||
done
|
||||
for i in $(awk -F":" "/ohci/ {print \$1}" </proc/interrupts | sed 's/\ //g'); do
|
||||
echo 2 >/proc/irq/$i/smp_affinity
|
||||
done
|
||||
for i in $(awk -F":" "/xhci/ {print \$1}" </proc/interrupts | sed 's/\ //g'); do
|
||||
echo 4 >/proc/irq/$i/smp_affinity
|
||||
done
|
||||
|
||||
# Wait (up to 5s) until eth0 brought up
|
||||
for i in {1..5}; do
|
||||
grep -q "eth0" /proc/interrupts && break
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo 8 >/proc/irq/$(awk -F":" "/eth0/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity
|
||||
echo 7 >/sys/class/net/eth0/queues/rx-0/rps_cpus
|
||||
echo 32768 >/proc/sys/net/core/rps_sock_flow_entries
|
||||
echo 32768 >/sys/class/net/eth0/queues/rx-0/rps_flow_cnt
|
||||
;;
|
||||
rk3399)
|
||||
for i in $(awk -F':' '/gpu/{print $1}' </proc/interrupts | sed 's/\ //g'); do
|
||||
echo 2 >/proc/irq/$i/smp_affinity
|
||||
@@ -126,9 +222,22 @@ prepare_board() {
|
||||
for i in $(awk -F':' '/dw-mci/{print $1}' </proc/interrupts | sed 's/\ //g'); do
|
||||
echo 2 >/proc/irq/$i/smp_affinity
|
||||
done
|
||||
echo 2 >/proc/irq/$(awk -F":" "/ehci/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity
|
||||
echo 2 >/proc/irq/$(awk -F":" "/ohci/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity
|
||||
echo 4 >/proc/irq/$(awk -F":" "/xhci/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity
|
||||
for i in $(awk -F":" "/ehci/ {print \$1}" </proc/interrupts | sed 's/\ //g'); do
|
||||
echo 2 >/proc/irq/$i/smp_affinity
|
||||
done
|
||||
for i in $(awk -F":" "/ohci/ {print \$1}" </proc/interrupts | sed 's/\ //g'); do
|
||||
echo 2 >/proc/irq/$i/smp_affinity
|
||||
done
|
||||
for i in $(awk -F":" "/xhci/ {print \$1}" </proc/interrupts | sed 's/\ //g'); do
|
||||
echo 4 >/proc/irq/$i/smp_affinity
|
||||
done
|
||||
|
||||
# Wait (up to 5s) until eth0 brought up
|
||||
for i in {1..5}; do
|
||||
grep -q "eth0" /proc/interrupts && break
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo 8 >/proc/irq/$(awk -F":" "/eth0/ {print \$1}" </proc/interrupts | sed 's/\ //g')/smp_affinity
|
||||
echo 7 >/sys/class/net/eth0/queues/rx-0/rps_cpus
|
||||
echo 32768 >/proc/sys/net/core/rps_sock_flow_entries
|
||||
@@ -141,6 +250,9 @@ prepare_board() {
|
||||
echo performance > /sys/bus/platform/drivers/rockchip-dmc/dmc/devfreq/dmc/governor
|
||||
fi
|
||||
;;
|
||||
sun4i|sun5i|rda8810) # only one core, nothing to improve
|
||||
:
|
||||
;;
|
||||
sun8i*) # H3/R40/V40 boards, try to do the best based on specific board since interfaces vary a lot
|
||||
# 10 or 120 sec user feedback that the board is ready after 1st login with 3.4 kernel
|
||||
SwapState="$(grep swap /etc/fstab)"
|
||||
@@ -202,7 +314,7 @@ prepare_board() {
|
||||
echo 8 >/proc/irq/$(awk -F":" "/eth/ {print \$1}" </proc/interrupts | sed 's/\ //g' | head -n1)/smp_affinity
|
||||
echo 7 >/sys/class/net/eth0/queues/rx-0/rps_cpus
|
||||
# OrangePi win GMAC is very unstable on gigabit. Limit it down to 100Mb solve problems
|
||||
[[ $BOARD == orangepiwin && $BRANCH == default ]] && ethtool -s eth0 speed 100 duplex full
|
||||
[[ $BOARD == orangepiwin && $BRANCH == legacy ]] && ethtool -s eth0 speed 100 duplex full
|
||||
;;
|
||||
esac
|
||||
} # prepare_board
|
||||
@@ -246,6 +358,19 @@ add_usb_storage_quirks() {
|
||||
|
||||
} # add_usb_storage_quirks
|
||||
|
||||
|
||||
branch_naming_workaround()
|
||||
# https://armbian.atlassian.net/browse/AR-748
|
||||
# Once we rework kernel packages, this can be done better
|
||||
{
|
||||
|
||||
if [[ -z $(cat /etc/orangepi-release | grep BRANCH) ]]; then
|
||||
BRANCH=$(dpkg -l | egrep "linux-image" | egrep "current|legacy|edge" | awk '{print $2}' | cut -d"-" -f3 | head -1)
|
||||
[[ -n ${BRANCH} ]] && echo "BRANCH=$BRANCH" >> /etc/orangepi-release
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case $1 in
|
||||
*start*)
|
||||
# set optimal disk scheduler settings
|
||||
@@ -256,5 +381,8 @@ case $1 in
|
||||
|
||||
# add usb quirks
|
||||
add_usb_storage_quirks &
|
||||
|
||||
# branch naming workaround
|
||||
branch_naming_workaround &
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
@@ -23,7 +23,7 @@ LOG_OUTPUT="tee -a $LOG2RAM_LOG"
|
||||
|
||||
isSafe () {
|
||||
[ -d $HDD_LOG ] || (echo "ERROR: $HDD_LOG doesn't exist! Can't sync." >&2 ; exit 1)
|
||||
NoCache=$(which nocache 2>/dev/null)
|
||||
NoCache=$(command -v nocache 2>/dev/null)
|
||||
}
|
||||
|
||||
RecreateLogs (){
|
||||
@@ -48,7 +48,11 @@ syncToDisk () {
|
||||
echo -e "\n\n$(date): Syncing logs to storage\n" | $LOG_OUTPUT
|
||||
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
${NoCache} rsync -aXWv --exclude "lost+found" --exclude orangepi-ramlog.log --links $RAM_LOG $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
${NoCache} rsync -aXWv \
|
||||
--exclude "lost+found" --exclude orangepi-ramlog.log \
|
||||
--links \
|
||||
${XTRA_RSYNC_TO[@]+"${XTRA_RSYNC_TO[@]}"} \
|
||||
$RAM_LOG $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
else
|
||||
${NoCache} cp -rfup $RAM_LOG -T $HDD_LOG 2>&1 | $LOG_OUTPUT
|
||||
fi
|
||||
@@ -62,7 +66,12 @@ syncFromDisk () {
|
||||
echo -e "\n\n$(date): Loading logs from storage\n" | $LOG_OUTPUT
|
||||
|
||||
if [ "$USE_RSYNC" = true ]; then
|
||||
${NoCache} rsync -aXWv --delete --exclude "lost+found" --exclude orangepi-ramlog.log --exclude *.gz --exclude *.xz --exclude='*.[0-9]' --links $HDD_LOG $RAM_LOG 2>&1 | $LOG_OUTPUT
|
||||
${NoCache} rsync -aXWv --delete \
|
||||
--exclude "lost+found" --exclude orangepi-ramlog.log \
|
||||
--exclude *.gz --exclude *.xz --exclude='*.[0-9]' \
|
||||
--links \
|
||||
${XTRA_RSYNC_FROM[@]+"${XTRA_RSYNC_FROM[@]}"} \
|
||||
$HDD_LOG $RAM_LOG 2>&1 | $LOG_OUTPUT
|
||||
else
|
||||
${NoCache} find $HDD_LOG* -maxdepth 1 -type f -not \( -name '*.[0-9]' -or -name '*.xz*' -or -name '*.gz' \) | xargs cp -ut $RAM_LOG
|
||||
fi
|
||||
@@ -86,16 +95,17 @@ case "$1" in
|
||||
mount --make-private $HDD_LOG
|
||||
|
||||
# Check whether zram device is available or we need to use tmpfs
|
||||
if [ "$(blkid -s TYPE /dev/zram0 | awk ' { print $2 } ' | grep ext4)" ]; then
|
||||
LOG_TYPE="zram"
|
||||
else
|
||||
LOG_TYPE="tmpfs"
|
||||
fi
|
||||
|
||||
LOG_TYPE="tmpfs"
|
||||
for rd in /dev/zram*; do
|
||||
if [[ "$(e2label $rd)" == "log2ram" ]]; then
|
||||
LOG_TYPE="zram"
|
||||
break
|
||||
fi
|
||||
done
|
||||
case $LOG_TYPE in
|
||||
zram)
|
||||
echo -e "Mounting /dev/zram0 as $RAM_LOG \c" | $LOG_OUTPUT
|
||||
mount -o discard /dev/zram0 $RAM_LOG 2>&1 | $LOG_OUTPUT
|
||||
echo -e "Mounting $rd as $RAM_LOG \c" | $LOG_OUTPUT
|
||||
mount -o discard $rd $RAM_LOG 2>&1 | $LOG_OUTPUT
|
||||
;;
|
||||
tmpfs)
|
||||
echo -e "Setting up $RAM_LOG as tmpfs \c" | $LOG_OUTPUT
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
@@ -50,10 +50,10 @@ do_expand_partition()
|
||||
case $RESIZE_VALUE in
|
||||
*%)
|
||||
# percentage value, we try to use 16MiB to align partitions since this is
|
||||
# the erase block size of more recent SD cards (512 byte sectors, so we use 32
|
||||
# the erase block size of more recent SD cards (512 byte sectors, so we use 32768
|
||||
# as divider and substract 1)
|
||||
local percentage=$(echo $RESIZE_VALUE | tr -c -d '[:digit:]')
|
||||
local lastsector=$(( 32 * $(parted $rootdevicepath unit s print -sm | grep "^$rootdevicepath" | awk -F":" "{printf (\"%0d\", ( \$2 * $percentage / 3200))}") - 1 ))
|
||||
local lastsector=$(( 32768 * $(parted $rootdevicepath unit s print -sm | grep "^$rootdevicepath" | awk -F":" "{printf (\"%0d\", ( \$2 * $percentage / 3276800))}") - 1 ))
|
||||
[[ $lastsector -lt $partend ]] && unset lastsector
|
||||
;;
|
||||
*s)
|
||||
@@ -64,7 +64,7 @@ do_expand_partition()
|
||||
esac
|
||||
# if SD card is larger than 4GiB then create another partition behind first one(s)
|
||||
if [[ $capacity -ge 5 ]]; then
|
||||
local secondpartition=$(( 32 * $(parted $rootdevicepath unit s print -sm | grep "^$rootdevicepath" | awk -F":" "{printf (\"%0d\", ( \$2 * 99 / 3200))}") -1 ))
|
||||
local secondpartition=$(( 32768 * $(parted $rootdevicepath unit s print -sm | grep "^$rootdevicepath" | awk -F":" "{printf (\"%0d\", ( \$2 * 99 / 3276800))}") -1 ))
|
||||
if [[ $secondpartition -lt $partend ]]; then
|
||||
unset secondpartition
|
||||
fi
|
||||
@@ -76,7 +76,7 @@ do_expand_partition()
|
||||
# to use Orange Pi on a card of inappropriate size so he gets what he deserves (at least he
|
||||
# should know what he's doing)
|
||||
if [[ $capacity -lt 5 ]]; then # 4 GiB or less
|
||||
local lastsector=$(( 32 * $(parted $rootdevicepath unit s print -sm | grep "^$rootdevicepath" | awk -F":" "{printf (\"%0d\", ( \$2 * 95 / 3200))}") -1 ))
|
||||
local lastsector=$(( 32768 * $(parted $rootdevicepath unit s print -sm | grep "^$rootdevicepath" | awk -F":" "{printf (\"%0d\", ( \$2 * 95 / 3276800))}") -1 ))
|
||||
if [[ $lastsector -lt $partend ]]; then
|
||||
unset lastsector
|
||||
else
|
||||
@@ -84,7 +84,7 @@ do_expand_partition()
|
||||
fi
|
||||
elif [[ $capacity -lt 9 ]]; then # 8 GiB or less
|
||||
# Leave 2 percent unpartitioned
|
||||
local lastsector=$(( 32 * $(parted $rootdevicepath unit s print -sm | grep "^$rootdevicepath" | awk -F":" "{printf (\"%0d\", ( \$2 * 98 / 3200))}") -1 ))
|
||||
local lastsector=$(( 32768 * $(parted $rootdevicepath unit s print -sm | grep "^$rootdevicepath" | awk -F":" "{printf (\"%0d\", ( \$2 * 98 / 3276800))}") -1 ))
|
||||
if [[ $lastsector -lt $partend ]]; then
|
||||
unset lastsector
|
||||
else
|
||||
@@ -92,7 +92,7 @@ do_expand_partition()
|
||||
fi
|
||||
else
|
||||
# Leave 1 percent unpartitioned
|
||||
local lastsector=$(( 32 * $(parted $rootdevicepath unit s print -sm | grep "^$rootdevicepath" | awk -F":" "{printf (\"%0d\", ( \$2 * 99 / 3200))}") -1 ))
|
||||
local lastsector=$(( 32768 * $(parted $rootdevicepath unit s print -sm | grep "^$rootdevicepath" | awk -F":" "{printf (\"%0d\", ( \$2 * 99 / 3276800))}") -1 ))
|
||||
if [[ $lastsector -lt $partend ]]; then
|
||||
unset lastsector
|
||||
else
|
||||
@@ -118,6 +118,16 @@ do_expand_partition()
|
||||
((echo n; echo p; echo ; echo $(( $lastsector + 1 )); echo $secondpartition ; echo w;) | fdisk $rootdevicepath) >>${Log} 2>&1
|
||||
local s=0
|
||||
partprobe $rootdevicepath >>${Log} 2>&1 || s=$?
|
||||
|
||||
#
|
||||
# Workaround for Kernel bug in 5.8.y and up. Ignore partprobe returning error and inticating that fs is not expended while it is
|
||||
#
|
||||
KERNELID=$(uname -r | awk -F'.' '{print ($1 * 100) + $2}')
|
||||
[[ ${KERNELID} -gt 507 ]] && s=0
|
||||
#
|
||||
#
|
||||
#
|
||||
|
||||
echo -e "New partition table:\n" >>${Log}
|
||||
cat /proc/partitions >>${Log}
|
||||
echo -e "\nNow trying to resize $1 filesystem on $rootsource to the limits:\n" >>${Log}
|
||||
@@ -131,7 +141,7 @@ do_expand_partition()
|
||||
ext4)
|
||||
resize2fs $rootsource >>${Log} 2>&1
|
||||
# check whether reboot is necessary for resize2fs to take effect
|
||||
local usedpercent=$(findmnt --target / -n -o USE% -b) # images before resize have 70-75%
|
||||
local usedpercent=$(findmnt --target / -n -o USE% -b | sed 's/[^0-9]*//g') # images before resize have 70-75%
|
||||
if [[ $s != 0 || $usedpercent -gt 70 ]]; then
|
||||
touch /var/run/resize2fs-reboot
|
||||
echo -e "\n### [resize2fs] Automated reboot needed to finish the resize procedure" >>${Log}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
@@ -10,6 +10,7 @@
|
||||
# working only when orangepi-ramlog is enabled
|
||||
|
||||
treshold=75 # %
|
||||
JOURNAL_SIZE=5M # size to shrink systemd-journal
|
||||
|
||||
[ -f /etc/default/orangepi-ramlog ] && . /etc/default/orangepi-ramlog
|
||||
|
||||
@@ -27,4 +28,6 @@ if [ $logusage -ge $treshold ]; then
|
||||
/usr/bin/find /var/log -name 'mail.err' -or -name 'mail.info' -or -name 'mail.warning' | xargs -r truncate --size 0
|
||||
# remove
|
||||
/usr/bin/find /var/log -name '*.[0-9]' -or -name '*.gz' | xargs -r rm -f
|
||||
# vacuum systemd-journald
|
||||
[ -d /var/log/journal ] && journalctl --vacuum-size=${JOURNAL_SIZE}
|
||||
fi
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) Authors: http://www.armbian.com/authors
|
||||
# Copyright (c) Authors: https://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
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
# Functions:
|
||||
#
|
||||
# activate_zram
|
||||
# activate_zram_swap
|
||||
# activate_ramlog_partition
|
||||
# activate_compressed_tmp
|
||||
@@ -18,16 +19,17 @@
|
||||
# and script configuration
|
||||
. /usr/lib/orangepi/orangepi-common
|
||||
|
||||
# It's possible to override ZRAM_PERCENTAGE, ZRAM_MAX_DEVICES, SWAP_ALGORITHM,
|
||||
# RAMLOG_ALGORITHM and TMP_ALGORITHM here:
|
||||
# It's possible to override SWAP, ZRAM_PERCENTAGE, MEM_LIMIT_PERCENTAGE, ZRAM_MAX_DEVICES,
|
||||
# SWAP_ALGORITHM, RAMLOG_ALGORITHM, TMP_ALGORITHM and TMP_SIZE here:
|
||||
ENABLED=false
|
||||
[ -f /etc/default/orangepi-zram-config ] && . /etc/default/orangepi-zram-config
|
||||
# Exit if not Enabled
|
||||
[[ "$ENABLED" != "true" ]] && exit 0
|
||||
|
||||
activate_zram_swap() {
|
||||
# Do not interfere with already present config-zram package
|
||||
dpkg -l | grep -q 'zram-config' && exit 0
|
||||
|
||||
[[ "$ENABLED" != "true" ]] && exit 0
|
||||
# Do not interfere with already present zram-config package
|
||||
dpkg -l | grep -q 'zram-config' && exit 0
|
||||
|
||||
activate_zram() {
|
||||
# Load zram module with n instances for swap: one per CPU core, $ZRAM_MAX_DEVICES
|
||||
# defines the maximum, on modern kernels we overwrite this with 1 and rely on
|
||||
# max_comp_streams being set to count of CPU cores or $ZRAM_MAX_DEVICES
|
||||
@@ -37,36 +39,50 @@ activate_zram_swap() {
|
||||
module_args="$(modinfo zram | awk -F" " '/num_devices/ {print $2}' | cut -f1 -d:)"
|
||||
[[ -n ${module_args} ]] && modprobe zram ${module_args}=$(( ${zram_devices} + 2 )) || return
|
||||
|
||||
swap_algo=${SWAP_ALGORITHM:=lzo}
|
||||
# Expose 50% of real memory as swap space by default
|
||||
zram_percent=${ZRAM_PERCENTAGE:=50}
|
||||
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_info=$(echo $mem_info | awk '{print $2}')
|
||||
memory_total=$(( mem_info * 1024 ))
|
||||
mem_per_zram_device=$(( ${memory_total} / ${zram_devices} * ${zram_percent} / 100 ))
|
||||
|
||||
# Limit memory available to zram to 50% by default
|
||||
mem_limit_percent=${MEM_LIMIT_PERCENTAGE:=50}
|
||||
mem_limit_per_zram_device=$(( ${memory_total} / ${zram_devices} * ${mem_limit_percent} / 100 ))
|
||||
}
|
||||
|
||||
activate_zram_swap() {
|
||||
# Return is SWAP is disabled (enabled by default)
|
||||
[[ -n "$SWAP" && "$SWAP" != "true" ]] && return;
|
||||
|
||||
# Disable zswap if zram should be used. To make use of zswap instead a
|
||||
# swap file or partition on *capable* storage needs to be chosen and
|
||||
# defined as swap and also in /etc/default/orangepi-zram-config SWAP=false
|
||||
# needs to be set.
|
||||
echo 0 >/sys/module/zswap/parameters/enabled 2>/dev/null
|
||||
|
||||
# Limit Journal size to 20Mb
|
||||
sed -i "s/.*SystemMaxUse=$/SystemMaxUse=20M/" /etc/systemd/journald.conf
|
||||
|
||||
swap_algo=${SWAP_ALGORITHM:=lzo}
|
||||
for (( i=1; i<=zram_devices; i++ )); do
|
||||
if [ -f /sys/block/zram${i}/comp_algorithm ]; then
|
||||
swap_device=$(zramctl -f |sed 's/\/dev\///')
|
||||
[[ ! ${swap_device} =~ ^zram ]] && echo -e "\n### No more available zram devices (${swap_device})\n" >>${Log} && exit 1;
|
||||
if [ -f /sys/block/${swap_device}/comp_algorithm ]; then
|
||||
# set compression algorithm, if defined as lzo choose lzo-rle if available
|
||||
# https://www.phoronix.com/scan.php?page=news_item&px=ZRAM-Linux-5.1-Better-Perform
|
||||
grep -q 'lzo-rle' /sys/block/zram${i}/comp_algorithm && \
|
||||
grep -q 'lzo-rle' /sys/block/${swap_device}/comp_algorithm && \
|
||||
[[ "X${swap_algo}" = "Xlzo" ]] && swap_algo="lzo-rle"
|
||||
echo ${swap_algo} >/sys/block/zram${i}/comp_algorithm 2>/dev/null
|
||||
echo ${swap_algo} >/sys/block/${swap_device}/comp_algorithm 2>/dev/null
|
||||
fi
|
||||
if [ "X${ZRAM_BACKING_DEV}" != "X" ]; then
|
||||
echo ${ZRAM_BACKING_DEV} >/sys/block/zram${i}/backing_dev
|
||||
echo ${ZRAM_BACKING_DEV} >/sys/block/${swap_device}/backing_dev
|
||||
fi
|
||||
echo -n ${ZRAM_MAX_DEVICES:=4} > /sys/block/zram${i}/max_comp_streams
|
||||
echo -n ${mem_per_zram_device} > /sys/block/zram${i}/disksize
|
||||
echo -n ${mem_limit_per_zram_device} > /sys/block/zram${i}/mem_limit
|
||||
mkswap /dev/zram${i}
|
||||
swapon -p 5 /dev/zram${i}
|
||||
echo -n ${ZRAM_MAX_DEVICES:=4} > /sys/block/${swap_device}/max_comp_streams
|
||||
echo -n ${mem_per_zram_device} > /sys/block/${swap_device}/disksize
|
||||
echo -n ${mem_limit_per_zram_device} > /sys/block/${swap_device}/mem_limit
|
||||
mkswap /dev/${swap_device}
|
||||
swapon -p 5 /dev/${swap_device}
|
||||
done
|
||||
|
||||
# Swapping to HDDs is stupid so switch to settings made for flash memory and zram/zswap
|
||||
@@ -80,7 +96,9 @@ activate_ramlog_partition() {
|
||||
# ENABLED=true in /etc/default/orangepi-ramlog is set
|
||||
ENABLED=$(awk -F"=" '/^ENABLED/ {print $2}' /etc/default/orangepi-ramlog)
|
||||
[[ "$ENABLED" != "true" ]] && return
|
||||
|
||||
log_device=$(zramctl -f |sed 's/\/dev\///')
|
||||
[[ ! ${log_device} =~ ^zram ]] && echo -e "\n### No more available zram devices (${log_device})\n" >>${Log} && exit 1;
|
||||
|
||||
# read size also from /etc/default/orangepi-ramlog
|
||||
ramlogsize=$(awk -F"=" '/^SIZE/ {print $2}' /etc/default/orangepi-ramlog)
|
||||
disksize=$(sed -e 's/M$/*1048576/' -e 's/K$/*1024/' <<<${ramlogsize:=50M} | bc)
|
||||
@@ -90,46 +108,48 @@ activate_ramlog_partition() {
|
||||
# See https://patchwork.kernel.org/patch/9918897/
|
||||
if [ "X${RAMLOG_ALGORITHM}" = "X" ]; then
|
||||
for algo in lz4 lz4hc quicklz zlib brotli zstd ; do
|
||||
echo ${algo} >/sys/block/zram0/comp_algorithm 2>/dev/null
|
||||
echo ${algo} >/sys/block/${log_device}/comp_algorithm 2>/dev/null
|
||||
done
|
||||
else
|
||||
echo ${RAMLOG_ALGORITHM} >/sys/block/zram0/comp_algorithm 2>/dev/null
|
||||
echo ${RAMLOG_ALGORITHM} >/sys/block/${log_device}/comp_algorithm 2>/dev/null
|
||||
fi
|
||||
echo -n ${disksize} > /sys/block/zram0/disksize
|
||||
echo -n ${disksize} > /sys/block/${log_device}/disksize
|
||||
|
||||
# if it fails, select $swap_algo. Workaround for some older kernels
|
||||
if [[ $? == 1 ]]; then
|
||||
echo ${swap_algo} > /sys/block/zram0/comp_algorithm 2>/dev/null
|
||||
echo -n ${disksize} > /sys/block/zram0/disksize
|
||||
echo ${swap_algo} > /sys/block/${log_device}/comp_algorithm 2>/dev/null
|
||||
echo -n ${disksize} > /sys/block/${log_device}/disksize
|
||||
fi
|
||||
|
||||
mkfs.ext4 -O ^has_journal -s 1024 -L log2ram /dev/zram0
|
||||
algo=$(sed 's/.*\[\([^]]*\)\].*/\1/g' </sys/block/zram0/comp_algorithm)
|
||||
mkfs.ext4 -O ^has_journal -s 1024 -L log2ram /dev/${log_device}
|
||||
algo=$(sed 's/.*\[\([^]]*\)\].*/\1/g' </sys/block/${log_device}/comp_algorithm)
|
||||
echo -e "### Activated Orange Pi ramlog partition with ${algo} compression" >>${Log}
|
||||
} # activate_ramlog_partition
|
||||
|
||||
activate_compressed_tmp() {
|
||||
# create /tmp not as tmpfs but zram compressed if no fstab entry exists
|
||||
grep -q '^tmpfs /tmp' /etc/mtab && return
|
||||
tmp_device=$(zramctl -f |sed 's/\/dev\///')
|
||||
[[ ! ${tmp_device} =~ ^zram ]] && echo -e "\n### No more available zram devices (${tmp_device})\n" >>${Log} && exit 1;
|
||||
|
||||
tmp_device=$(( ${zram_devices} + 1 ))
|
||||
if [[ -f /sys/block/zram${tmp_device}/comp_algorithm ]]; then
|
||||
if [[ -f /sys/block/${tmp_device}/comp_algorithm ]]; then
|
||||
if [ "X${TMP_ALGORITHM}" = "X" ]; then
|
||||
echo ${swap_algo} >/sys/block/zram${tmp_device}/comp_algorithm 2>/dev/null
|
||||
echo ${swap_algo} >/sys/block/${tmp_device}/comp_algorithm 2>/dev/null
|
||||
else
|
||||
echo ${TMP_ALGORITHM} >/sys/block/zram${tmp_device}/comp_algorithm 2>/dev/null
|
||||
echo ${TMP_ALGORITHM} >/sys/block/${tmp_device}/comp_algorithm 2>/dev/null
|
||||
fi
|
||||
fi
|
||||
echo -n $(( ${memory_total} / 2 )) > /sys/block/zram${tmp_device}/disksize
|
||||
mkfs.ext4 -O ^has_journal -s 1024 -L tmp /dev/zram${tmp_device}
|
||||
mount -o nosuid,discard /dev/zram${tmp_device} /tmp
|
||||
chmod 777 /tmp
|
||||
algo=$(sed 's/.*\[\([^]]*\)\].*/\1/g' </sys/block/zram${tmp_device}/comp_algorithm)
|
||||
[[ -z ${TMP_SIZE} ]] && echo -n $(( ${memory_total} / 2 )) > /sys/block/${tmp_device}/disksize || echo -n ${TMP_SIZE} > /sys/block/${tmp_device}/disksize
|
||||
mkfs.ext4 -O ^has_journal -s 1024 -L tmp /dev/${tmp_device}
|
||||
mount -o nosuid,discard /dev/${tmp_device} /tmp
|
||||
chmod 1777 /tmp
|
||||
algo=$(sed 's/.*\[\([^]]*\)\].*/\1/g' </sys/block/${tmp_device}/comp_algorithm)
|
||||
echo -e "\n### Activated ${algo} compressed /tmp" >>${Log}
|
||||
} # activate_compressed_tmp
|
||||
|
||||
case $1 in
|
||||
*start*)
|
||||
activate_zram
|
||||
activate_zram_swap
|
||||
activate_ramlog_partition
|
||||
activate_compressed_tmp
|
||||
|
||||
@@ -64,11 +64,11 @@ fi
|
||||
mkopts[btrfs]='-f'
|
||||
mkopts[f2fs]='-f'
|
||||
|
||||
mountopts[ext2]='defaults,noatime,nodiratime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
|
||||
mountopts[ext3]='defaults,noatime,nodiratime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
|
||||
mountopts[ext4]='defaults,noatime,nodiratime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
|
||||
mountopts[btrfs]='defaults,noatime,nodiratime,commit=600,compress=lzo,x-gvfs-hide 0 2'
|
||||
mountopts[f2fs]='defaults,noatime,nodiratime,x-gvfs-hide 0 2'
|
||||
mountopts[ext2]='defaults,noatime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
|
||||
mountopts[ext3]='defaults,noatime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
|
||||
mountopts[ext4]='defaults,noatime,commit=600,errors=remount-ro,x-gvfs-hide 0 1'
|
||||
mountopts[btrfs]='defaults,noatime,commit=600,compress=lzo,x-gvfs-hide 0 2'
|
||||
mountopts[f2fs]='defaults,noatime,x-gvfs-hide 0 2'
|
||||
|
||||
# Create boot and root file system "$1" = boot, "$2" = root (Example: create_orangepi "/dev/nand1" "/dev/sda3")
|
||||
create_orangepi()
|
||||
@@ -193,7 +193,7 @@ create_orangepi()
|
||||
This will take approximately $(( $((USAGE/300)) * 1 )) minutes to finish. Please wait!\n\n" 11 80
|
||||
|
||||
# run rsync again to silently catch outstanding changes between / and "${TempDir}"/rootfs/
|
||||
dialog --title "$title" --backtitle "$backtitle" --infobox "\n Cleaning up ... Almost done." 5 40
|
||||
dialog --title "$title" --backtitle "$backtitle" --infobox "\n Cleaning up ... Almost done." 5 60
|
||||
rsync -avrltD --delete --exclude-from=$EX_LIST / "${TempDir}"/rootfs >/dev/null 2>&1
|
||||
|
||||
# creating fstab from scratch
|
||||
@@ -211,7 +211,7 @@ create_orangepi()
|
||||
echo "Finishing installation to NAND." >> $logfile
|
||||
REMOVESDTXT="and remove SD to boot from NAND"
|
||||
echo "$1 /boot vfat defaults 0 0" >> "${TempDir}"/rootfs/etc/fstab
|
||||
echo "$2 / ext4 defaults,noatime,nodiratime,commit=600,errors=remount-ro 0 1" >> "${TempDir}"/rootfs/etc/fstab
|
||||
echo "$2 / ext4 defaults,noatime,commit=600,errors=remount-ro 0 1" >> "${TempDir}"/rootfs/etc/fstab
|
||||
dialog --title "$title" --backtitle "$backtitle" --infobox "\nConverting kernel ... few seconds." 5 60
|
||||
mkimage -A arm -O linux -T kernel -C none -a "0x40008000" -e "0x40008000" -n "Linux kernel" -d \
|
||||
/boot/zImage "${TempDir}"/bootfs/uImage >/dev/null 2>&1
|
||||
@@ -278,7 +278,13 @@ create_orangepi()
|
||||
[[ -f "${TempDir}"/bootfs/boot/boot.ini ]] && sed -e 's,^setenv rootdev.*$,setenv rootdev "'"$targetuuid"'",' -i "${TempDir}"/bootfs/boot/boot.ini
|
||||
[[ -f "${TempDir}"/rootfs/boot/boot.ini ]] && sed -e 's,^setenv rootdev.*$,setenv rootdev "'"$targetuuid"'",' -i "${TempDir}"/rootfs/boot/boot.ini
|
||||
fi
|
||||
mkimage -C none -A arm -T script -d "${TempDir}"/bootfs/boot/boot.cmd "${TempDir}"/bootfs/boot/boot.scr >/dev/null 2>&1 || (echo 'Error while creating U-Boot loader image with mkimage' >&2 ; exit 5)
|
||||
|
||||
if [[ -f "${TempDir}"/bootfs/boot/extlinux/extlinux.conf ]]; then
|
||||
sed -e 's,root='"$root_uuid"',root='"$targetuuid"',g' -i "${TempDir}"/bootfs/boot/extlinux/extlinux.conf
|
||||
[[ -f "${TempDir}"/bootfs/boot/boot.cmd ]] && rm "${TempDir}"/bootfs/boot/boot.cmd
|
||||
else
|
||||
mkimage -C none -A arm -T script -d "${TempDir}"/bootfs/boot/boot.cmd "${TempDir}"/bootfs/boot/boot.scr >/dev/null 2>&1 || (echo 'Error while creating U-Boot loader image with mkimage' >&2 ; exit 5)
|
||||
fi
|
||||
|
||||
# fstab adj
|
||||
if [[ "$1" != "$2" ]]; then
|
||||
@@ -327,6 +333,10 @@ create_orangepi()
|
||||
sed -e 's,setenv rootfstype.*,setenv rootfstype '"$FilesystemChoosen"',' -i /boot/boot.cmd
|
||||
sed -e 's,setenv rootfstype.*,setenv rootfstype '"$FilesystemChoosen"',' -i /boot/boot.ini
|
||||
fi
|
||||
if [[ -f /bootfs/boot/extlinux/extlinux.conf ]]; then
|
||||
sed -e 's,root='"$root_uuid"',root='"$satauuid"',g' -i /boot/extlinux/extlinux.conf
|
||||
[[ -f /boot/boot.cmd ]] && rm /boot/boot.cmd
|
||||
fi
|
||||
[[ -f /boot/boot.cmd ]] && mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr >/dev/null 2>&1 || (echo 'Error while creating U-Boot loader image with mkimage' >&2 ; exit 7)
|
||||
mkdir -p "${TempDir}"/rootfs/media/mmc/boot
|
||||
echo "${sduuid} /media/mmcboot ext4 ${mountopts[ext4]}" >> "${TempDir}"/rootfs/etc/fstab
|
||||
@@ -407,7 +417,7 @@ format_nand()
|
||||
|
||||
show_nand_warning
|
||||
|
||||
dialog --title "$title" --backtitle "$backtitle" --infobox "\nFormating ... up to one minute." 5 40
|
||||
dialog --title "$title" --backtitle "$backtitle" --infobox "\n Formatting ... up to one minute." 5 60
|
||||
if [[ $DEVICE_TYPE = a20 ]]; then
|
||||
(echo y;) | sunxi-nand-part -f a20 /dev/nand 65536 'bootloader 65536' 'linux 0' >> $logfile 2>&1
|
||||
else
|
||||
@@ -443,15 +453,21 @@ format_emmc()
|
||||
QUOTED_DEVICE=$(echo "$1" | sed 's:/:\\\/:g')
|
||||
CAPACITY=$(parted "$1" unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", \$2 / ( 1024 / \$4 ))}")
|
||||
|
||||
# We use 16MiB to align partitions which may overestimate the erase block
|
||||
# size of a NAND device. Overestimating is harmless. (512 byte
|
||||
# sectors, so we use 32768 as divider and substract 1)
|
||||
if [[ $CAPACITY -lt 4000000 ]]; then
|
||||
# Leave 2 percent unpartitioned when eMMC size is less than 4GB (unlikely)
|
||||
LASTSECTOR=$(( 32 * $(parted "$1" unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", ( \$2 * 98 / 3200))}") -1 ))
|
||||
LASTSECTOR=$(( 32768 * $(parted "$1" unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", ( \$2 * 98 / 3276800))}") -1 ))
|
||||
else
|
||||
# Leave 1 percent unpartitioned
|
||||
LASTSECTOR=$(( 32 * $(parted "$1" unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", ( \$2 * 99 / 3200))}") -1 ))
|
||||
LASTSECTOR=$(( 32768 * $(parted "$1" unit s print -sm | awk -F":" "/^${QUOTED_DEVICE}/ {printf (\"%0d\", ( \$2 * 99 / 3276800))}") -1 ))
|
||||
fi
|
||||
|
||||
parted -s "$1" -- mklabel msdos
|
||||
# get target partition table type from the root partition device
|
||||
PART_TABLE_TYPE=$(parted "$root_partition_device" print -sm | awk -F ":" -v pattern="$root_partition_device" '$0 ~ pattern {print $6}')
|
||||
|
||||
parted -s "$1" -- mklabel "$PART_TABLE_TYPE"
|
||||
dialog --title "$title" --backtitle "$backtitle" --infobox "\nFormating $1 to $eMMCFilesystemChoosen ... please wait." 5 60
|
||||
# we can't boot from btrfs or f2fs
|
||||
if [[ $eMMCFilesystemChoosen =~ ^(btrfs|f2fs)$ ]]; then
|
||||
@@ -461,7 +477,7 @@ format_emmc()
|
||||
fi
|
||||
|
||||
# default boot partition size, in MiB
|
||||
DEFAULT_BOOTSIZE=96
|
||||
DEFAULT_BOOTSIZE=256
|
||||
|
||||
# (convert to sectors for partitioning)
|
||||
DEFAULT_BOOTSIZE_SECTORS=$(((${DEFAULT_BOOTSIZE} * 1024 * 1024) / 512))
|
||||
@@ -573,7 +589,7 @@ update_bootscript()
|
||||
# show warning [TEXT]
|
||||
show_warning()
|
||||
{
|
||||
dialog --title "$title" --backtitle "$backtitle" --cr-wrap --colors --yesno " \Z1$(toilet -W -f ascii9 WARNING)\Zn\n$1" 14 53
|
||||
dialog --title "$title" --backtitle "$backtitle" --cr-wrap --colors --yesno " \Z1$(toilet -W -f ascii9 ' WARNING')\Zn\n$1" 16 67
|
||||
[[ $? -ne 0 ]] && exit 13
|
||||
}
|
||||
|
||||
@@ -587,6 +603,20 @@ stop_running_services()
|
||||
done
|
||||
}
|
||||
|
||||
# show warning and write u-boot to SPI flash $1 = spi device name, $2 = u-boot files directory
|
||||
write_uboot_to_spi_flash()
|
||||
{
|
||||
local MTD_BLK="/dev/$1"
|
||||
local DIR="$2"
|
||||
local MESSAGE="This script will update the bootloader on SPI Flash $MTD_BLK. Continue?\nIt will take up to a few minutes."
|
||||
dialog --title "$title" --backtitle "$backtitle" --cr-wrap --colors --yesno " \Z1$(toilet -W -f ascii9 ' WARNING')\Zn\n$MESSAGE" 16 67
|
||||
if [[ $? -eq 0 ]]; then
|
||||
write_uboot_platform_mtd "$DIR" $MTD_BLK
|
||||
update_bootscript
|
||||
echo 'Done'
|
||||
fi
|
||||
}
|
||||
|
||||
main()
|
||||
{
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
@@ -599,15 +629,15 @@ main()
|
||||
|
||||
# Check if we run it from SD card
|
||||
# TODO: Disable/remove this in the future
|
||||
case ${root_partition_device} in
|
||||
/dev/mmcblk*) # mmc device, we can continue
|
||||
:
|
||||
;;
|
||||
*)
|
||||
dialog --title "$title" --backtitle "$backtitle" --colors --infobox '\n\Z1This tool must run from SD-card! \Zn' 5 37
|
||||
exit 15
|
||||
;;
|
||||
esac
|
||||
# case ${root_partition_device} in
|
||||
# /dev/mmcblk*) # mmc device, we can continue
|
||||
# :
|
||||
# ;;
|
||||
# *)
|
||||
# dialog --title "$title" --backtitle "$backtitle" --colors --infobox '\n\Z1 This tool must run from SD-card! \Zn' 5 60
|
||||
# exit 15
|
||||
# ;;
|
||||
# esac
|
||||
|
||||
[ -f $logfile ] && echo -e '\n\n\n' >> $logfile
|
||||
LANG=C echo -e "$(date): Start ${0##*/}.\n" >> $logfile
|
||||
@@ -691,6 +721,15 @@ main()
|
||||
show_warning "This script will erase your device $DISK_ROOT_PART. Continue?"
|
||||
format_disk "$DISK_ROOT_PART"
|
||||
create_orangepi 'spi' "$DISK_ROOT_PART"
|
||||
|
||||
if [[ $(type -t write_uboot_platform_mtd) == function ]]; then
|
||||
dialog --title "$title" --backtitle "$backtitle" --yesno \
|
||||
"Do you want to write the bootloader to SPI flash?\n\nIt is required if you have not done it before or if you have some non-OrangePi bootloader in SPI." 8 60
|
||||
|
||||
if [[ $? -eq 0 ]]; then
|
||||
write_uboot_to_spi_flash $spicheck "$DIR"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
5)
|
||||
show_warning 'This script will update the bootloader on SD/eMMC. Continue?'
|
||||
@@ -711,11 +750,7 @@ main()
|
||||
return
|
||||
;;
|
||||
7)
|
||||
MTD_BLK="/dev/${spicheck}"
|
||||
show_warning "This script will update the bootloader on SPI Flash $MTD_BLK. Continue?"
|
||||
write_uboot_platform_mtd "$DIR" $MTD_BLK
|
||||
update_bootscript
|
||||
echo 'Done'
|
||||
write_uboot_to_spi_flash $spicheck "$DIR"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
|
||||
@@ -36,7 +36,7 @@ fi
|
||||
. /etc/orangepi-release
|
||||
|
||||
case "${LINUXFAMILY}" in
|
||||
sunxi|sunxi64|rockchip64|sun50iw9)
|
||||
sunxi|sunxi64|rockchip64|sun50iw9|rk3399)
|
||||
:;;
|
||||
*)
|
||||
echo >&2 "Overlays are not supported on ${LINUXFAMILY^} based boards."
|
||||
|
||||
Reference in New Issue
Block a user