forked from ophub/amlogic-s9xxx-armbian
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
1,910 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
label Armbian | ||
kernel /zImage | ||
initrd /uInitrd | ||
fdt /dtb/amlogic/meson-g12b-gtking-pro.dtb | ||
append root=LABEL=ROOTFS rootfstype=btrfs rootflags=compress=zstd:6 console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0 loglevel=1 voutmode=hdmi disablehpd=false overscan=100 sdrmode=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
LINUX=/zImage | ||
INITRD=/uInitrd | ||
FDT=/dtb/amlogic/meson-g12b-gtking-pro.dtb | ||
APPEND=root=LABEL=ROOTFS console=ttyAML0,115200n8 console=tty0 no_console_suspend consoleblank=0 fsck.fix=yes fsck.repair=yes net.ifnames=0 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
LABEL=ROOTFS / btrfs defaults,noatime,compress=zstd:6 0 1 | ||
LABEL=BOOT /boot vfat defaults 0 2 | ||
tmpfs /tmp tmpfs defaults,nosuid 0 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
source /etc/network/interfaces.d/* | ||
# Network is managed by Network manager | ||
auto lo | ||
iface lo inet loopback | ||
auto wlan0 | ||
iface wlan0 inet dhcp | ||
auto eth0 | ||
iface eth0 inet dhcp | ||
hwaddress ether 12:34:56:78:9A:BC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# | ||
# /etc/sysctl.conf - Configuration file for setting system variables | ||
# See /etc/sysctl.d/ for additional system variables. | ||
# See sysctl.conf (5) for information. | ||
# | ||
|
||
#kernel.domainname = example.com | ||
|
||
# Uncomment the following to stop low-level messages on console | ||
kernel.printk = 7 4 1 7 | ||
|
||
##############################################################3 | ||
# Functions previously found in netbase | ||
# | ||
|
||
# Uncomment the next two lines to enable Spoof protection (reverse-path filter) | ||
# Turn on Source Address Verification in all interfaces to | ||
# prevent some spoofing attacks | ||
#net.ipv4.conf.default.rp_filter=1 | ||
#net.ipv4.conf.all.rp_filter=1 | ||
|
||
# Uncomment the next line to enable TCP/IP SYN cookies | ||
# See http://lwn.net/Articles/277146/ | ||
# Note: This may impact IPv6 TCP sessions too | ||
#net.ipv4.tcp_syncookies=1 | ||
|
||
# Uncomment the next line to enable packet forwarding for IPv4 | ||
#net.ipv4.ip_forward=1 | ||
|
||
# Uncomment the next line to enable packet forwarding for IPv6 | ||
# Enabling this option disables Stateless Address Autoconfiguration | ||
# based on Router Advertisements for this host | ||
#net.ipv6.conf.all.forwarding=1 | ||
|
||
|
||
################################################################### | ||
# Additional settings - these settings can improve the network | ||
# security of the host and prevent against some network attacks | ||
# including spoofing attacks and man in the middle attacks through | ||
# redirection. Some network environments, however, require that these | ||
# settings are disabled so review and enable them as needed. | ||
# | ||
# Do not accept ICMP redirects (prevent MITM attacks) | ||
#net.ipv4.conf.all.accept_redirects = 0 | ||
#net.ipv6.conf.all.accept_redirects = 0 | ||
# _or_ | ||
# Accept ICMP redirects only for gateways listed in our default | ||
# gateway list (enabled by default) | ||
# net.ipv4.conf.all.secure_redirects = 1 | ||
# | ||
# Do not send ICMP redirects (we are not a router) | ||
#net.ipv4.conf.all.send_redirects = 0 | ||
# | ||
# Do not accept IP source route packets (we are not a router) | ||
#net.ipv4.conf.all.accept_source_route = 0 | ||
#net.ipv6.conf.all.accept_source_route = 0 | ||
# | ||
# Log Martian Packets | ||
#net.ipv4.conf.all.log_martians = 1 | ||
# | ||
|
||
################################################################### | ||
# Magic system request Key | ||
# 0=disable, 1=enable all, >1 bitmask of sysrq functions | ||
# See https://www.kernel.org/doc/html/latest/admin-guide/sysrq.html | ||
# for what other values do | ||
#kernel.sysrq=438 | ||
|
||
vm.swappiness = 100 | ||
|
||
vm.max_map_count = 262144 | ||
# Generated file - do not edit. | ||
# Disable the hung task timer by default. (bnc#552820) | ||
kernel.hung_task_timeout_secs = 0 | ||
|
||
# Increase defaults for IPC (bnc#146656) | ||
kernel.msgmax = 65536 | ||
kernel.msgmnb = 65536 | ||
|
||
net.core.default_qdisc = fq | ||
net.ipv4.tcp_congestion_control = bbr | ||
net.ipv4.ip_local_port_range = 1024 65535 | ||
|
||
net.ipv4.conf.default.arp_ignore = 1 | ||
net.ipv4.conf.all.arp_ignore = 1 | ||
net.ipv4.ip_forward = 1 | ||
net.ipv4.icmp_echo_ignore_broadcasts = 1 | ||
net.ipv4.icmp_ignore_bogus_error_responses = 1 | ||
net.ipv4.igmp_max_memberships = 100 | ||
net.ipv4.tcp_fin_timeout = 30 | ||
net.ipv4.tcp_keepalive_time = 120 | ||
net.ipv4.tcp_syncookies = 1 | ||
net.ipv4.tcp_timestamps = 1 | ||
net.ipv4.tcp_sack = 1 | ||
net.ipv4.tcp_dsack = 1 | ||
|
||
net.ipv6.conf.default.forwarding = 1 | ||
net.ipv6.conf.all.forwarding = 1 | ||
|
||
net.core.rmem_max = 4194304 | ||
net.core.wmem_max = 1048576 | ||
|
||
net.netfilter.nf_conntrack_acct = 1 | ||
net.netfilter.nf_conntrack_checksum = 0 | ||
net.netfilter.nf_conntrack_max = 65535 | ||
net.netfilter.nf_conntrack_tcp_timeout_established = 7440 | ||
net.netfilter.nf_conntrack_udp_timeout = 60 | ||
net.netfilter.nf_conntrack_udp_timeout_stream = 180 | ||
net.netfilter.nf_conntrack_helper = 1 | ||
|
||
# net.ipv6.conf.all.disable_ipv6 = 1 | ||
# net.ipv6.conf.all.disable_ipv6 = 1 |
Binary file not shown.
107 changes: 107 additions & 0 deletions
107
build-armbian/common-files/rootfs/usr/sbin/armbian-ddbr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
#!/bin/bash | ||
#========================================================================= | ||
# 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. | ||
# | ||
# This file is a part of the Armbian Rebuild and kernel Recompile script | ||
# https://github.com/ophub/amlogic-s9xxx-armbian | ||
# | ||
# Description: Backup and restore the system in emmc | ||
# Copyright (C) 2017- The function borrowed from ddbr, Author: xXx | ||
# Copyright (C) 2021- https://github.com/unifreq/openwrt_packit | ||
# Copyright (C) 2021- https://github.com/ophub/amlogic-s9xxx-armbian | ||
# | ||
# Command: armbian-ddbr | ||
#========================================================================= | ||
|
||
# Set font color | ||
blue_font_prefix="\033[94m" | ||
purple_font_prefix="\033[95m" | ||
green_font_prefix="\033[92m" | ||
yellow_font_prefix="\033[93m" | ||
red_font_prefix="\033[91m" | ||
font_color_suffix="\033[0m" | ||
INFO="[${blue_font_prefix}INFO${font_color_suffix}]" | ||
STEPS="[${purple_font_prefix}STEPS${font_color_suffix}]" | ||
SUCCESS="[${green_font_prefix}SUCCESS${font_color_suffix}]" | ||
OPT="[${yellow_font_prefix}OPT${font_color_suffix}]" | ||
ERROR="[${red_font_prefix}ERROR${font_color_suffix}]" | ||
# File name for backup/restore | ||
ddbr_image="BACKUP-arm-64-emmc.img.gz" | ||
# Need remaining space, unit: GB | ||
need_space="2" | ||
# Get device name | ||
mydevice_name=$(cat /proc/device-tree/model | tr -d '\000') | ||
|
||
# Find the EMMC drive | ||
emmc="$(lsblk -l -o NAME | grep -oE "mmcblk[0-9]boot0" | sort | uniq | sed "s/boot0//g")" | ||
if [[ "${emmc}" == "" ]]; then | ||
echo "No emmc can be found to install the openwrt system!" | ||
exit 1 | ||
fi | ||
|
||
# Find the partition where root is located | ||
root_devname=$(df / | tail -n1 | awk '{print $1}' | awk -F '/' '{print substr($3, 1, length($3)-2)}') | ||
if lsblk -l | grep -E "^${root_devname}boot0" >/dev/null; then | ||
echo "You are running in emmc mode, please boot system with TF/SD/USB!" | ||
exit 1 | ||
fi | ||
|
||
# Check the output path | ||
out_path="/ddbr" | ||
[ -d "${out_path}" ] || mkdir -p ${out_path} | ||
|
||
# Check emmc partition size | ||
dev_intsize="$(fdisk -s /dev/${emmc})" | ||
[ -z "$(echo "${dev_intsize}" | sed -n "/^[0-9]\+$/p")" ] && echo -e "${ERROR} Unable to get EMMC size." && exit 1 | ||
|
||
# Check the remaining space | ||
do_checkspace() { | ||
remaining_space="$(df -hT ${out_path} | grep '/dev/' | awk '{print $5}' | sed 's/.$//' | awk -F "." '{print $1}')" | ||
if [ -z "$(echo "${remaining_space}" | sed -n "/^[0-9]\+$/p")" ]; then | ||
echo -e "${ERROR} The path is not available, the remaining space cannot be obtained." | ||
exit 1 | ||
fi | ||
if [[ "${remaining_space}" -lt "${need_space}" ]]; then | ||
echo -e "${ERROR} The remaining space is [ ${remaining_space} ] GB." | ||
echo -e "It is recommended that the remaining space should not be less than [ ${need_space} ] GB." | ||
echo -e "Please use the [ armbian-tf ] command to extended partition first." | ||
exit 1 | ||
fi | ||
} | ||
|
||
# Backup the emmc system | ||
do_backup() { | ||
echo -e "${STEPS} Start to backup the system in emmc." | ||
do_checkspace | ||
echo -e "Saving and Compressing [ /dev/${emmc} ] to [ ${out_path}/${ddbr_image} ], Please wait..." | ||
rm -f ${out_path}/${ddbr_image} 2>/dev/null && sync | ||
dd if=/dev/${emmc} | pv -s ${dev_intsize}"K" | gzip >${out_path}/${ddbr_image} | ||
[ "$?" -eq "0" ] && sync && echo -e "${SUCCESS} Backup is complete." | ||
} | ||
|
||
# Restore the emmc system | ||
do_restore() { | ||
echo -e "${STEPS} Start to restore the system in emmc." | ||
[ ! -f ${out_path}/${ddbr_image} ] && echo -e "${ERROR} The [ ${out_path}/${ddbr_image} ] File not found." && exit 1 | ||
echo -e "Restoring [ ${out_path}/${ddbr_image} ] to [ /dev/${emmc} ], Please wait..." | ||
gunzip -c ${out_path}/${ddbr_image} | pv -s ${dev_intsize}"K" | dd of=/dev/${emmc} | ||
[ "$?" -eq "0" ] && sync && echo -e "${SUCCESS} Restore is complete." | ||
} | ||
|
||
# Output device information | ||
echo -e "${STEPS} Welcome to use the EMMC system backup/restore service." | ||
echo -e "${INFO} The device name: [ ${mydevice_name} ]" | ||
echo -e "${INFO} The device EMMC name: [ /dev/${emmc} ]" | ||
echo -e "${INFO} The device EMMC size: [ $(($dev_intsize / 1024 / 1024))GB ]" | ||
echo -e "${INFO} The ddbr file path: [ ${out_path}/${ddbr_image} ]\n" | ||
|
||
# Prompt the user to select backup/restore | ||
echo -ne "${OPT} Do you want to backup or restore? Backup=(b) Restore=(r): " | ||
read br | ||
case ${br} in | ||
b | B | backup) do_backup ;; | ||
r | R | restore) do_restore ;; | ||
*) exit 0 ;; | ||
esac |
Oops, something went wrong.