|
16 | 16 | # |
17 | 17 | #=============================== Set default parameters =============================== |
18 | 18 | # |
| 19 | +export DEBIAN_FRONTEND=noninteractive |
| 20 | + |
19 | 21 | # Set the armbian release check file |
20 | 22 | armbian_release_file="/etc/armbian-release" |
21 | 23 | armbian_image_file="/etc/armbian-image-release" |
@@ -66,13 +68,28 @@ echo "" >${fix_log} && tolog "Start fixing..." |
66 | 68 |
|
67 | 69 | # Remove packages |
68 | 70 | sudo apt-get clean -y && sudo rm -rf /var/cache/apt/* && sudo rm -rf /var/lib/apt/* && tolog "20. Clean up local installation packages" |
69 | | -[[ -n "$(dpkg -l | awk '{print $2}' | grep linux-image-*)" ]] && sudo apt-get remove -qq --purge -y linux-image-* && tolog "21. Remove linux-image-*" |
70 | | -[[ -n "$(dpkg -l | awk '{print $2}' | grep linux-dtb-*)" ]] && sudo apt-get remove -qq --purge -y linux-dtb-* && tolog "22. Remove linux-dtb-*" |
71 | | -[[ -n "$(dpkg -l | awk '{print $2}' | grep linux-u-boot-*)" ]] && sudo apt-get remove -qq --purge -y linux-u-boot-* && tolog "23. Remove linux-u-boot-*" |
72 | | -[[ -n "$(dpkg -l | awk '{print $2}' | grep armbian-bsp-cli-*)" ]] && sudo apt-mark hold armbian-bsp-cli-* && tolog "24. Hold armbian-bsp-cli-*" |
73 | | -[[ -n "$(dpkg -l | awk '{print $2}' | grep u-boot-tools)" ]] && sudo apt-mark hold u-boot-tools && tolog "25. Hold u-boot-tools" |
74 | | -[[ -n "$(dpkg -l | awk '{print $2}' | grep sunxi-tools)" ]] && sudo apt-mark hold sunxi-tools && tolog "26. Hold sunxi-tools" |
75 | | -[[ -n "$(dpkg -l | awk '{print $2}' | grep initramfs-tools*)" ]] && sudo apt-mark hold initramfs-tools* && tolog "27. Hold initramfs-tools*" |
| 71 | + |
| 72 | +# 21. Remove linux-image-* |
| 73 | +pkg_linux_image=$(dpkg -l | awk '{print $2}' | grep "^linux-image-" || true) |
| 74 | +if [[ -n "${pkg_linux_image}" ]]; then |
| 75 | + sudo apt-get remove -qq --purge -y --allow-change-held-packages ${pkg_linux_image} 2>/dev/null && tolog "21. Remove linux-image-*" |
| 76 | +fi |
| 77 | +# 22. Remove linux-dtb-* |
| 78 | +pkg_linux_dtb=$(dpkg -l | awk '{print $2}' | grep "^linux-dtb-" || true) |
| 79 | +if [[ -n "${pkg_linux_dtb}" ]]; then |
| 80 | + sudo apt-get remove -qq --purge -y --allow-change-held-packages ${pkg_linux_dtb} 2>/dev/null && tolog "22. Remove linux-dtb-*" |
| 81 | +fi |
| 82 | +# 23. Remove linux-u-boot-* |
| 83 | +pkg_linux_uboot=$(dpkg -l | awk '{print $2}' | grep "^linux-u-boot-" || true) |
| 84 | +if [[ -n "${pkg_linux_uboot}" ]]; then |
| 85 | + sudo apt-get remove -qq --purge -y --allow-change-held-packages ${pkg_linux_uboot} 2>/dev/null && tolog "23. Remove linux-u-boot-*" |
| 86 | +fi |
| 87 | + |
| 88 | +# Hold packages |
| 89 | +[[ -n "$(dpkg -l | awk '{print $2}' | grep armbian-bsp-cli-)" ]] && sudo apt-mark hold armbian-bsp-cli-* 2>/dev/null && tolog "24. Hold armbian-bsp-cli-*" |
| 90 | +[[ -n "$(dpkg -l | awk '{print $2}' | grep u-boot-tools)" ]] && sudo apt-mark hold u-boot-tools 2>/dev/null && tolog "25. Hold u-boot-tools" |
| 91 | +[[ -n "$(dpkg -l | awk '{print $2}' | grep sunxi-tools)" ]] && sudo apt-mark hold sunxi-tools 2>/dev/null && tolog "26. Hold sunxi-tools" |
| 92 | +[[ -n "$(dpkg -l | awk '{print $2}' | grep initramfs-tools)" ]] && sudo apt-mark hold initramfs-tools* 2>/dev/null && tolog "27. Hold initramfs-tools*" |
76 | 93 |
|
77 | 94 | # Remove the scripts contained in [ armbian-bsp-cli-odroidn2 ] that will cause the system to fail to start |
78 | 95 | # [ dpkg -c armbian-bsp-cli-odroidn2_23.02.2_arm64.deb ] : https://paste.armbian.com/aloxuvokol |
@@ -109,15 +126,15 @@ quotes_cron="/etc/cron.daily/armbian-quotes" |
109 | 126 | # Remove motd-news service |
110 | 127 | motd_timer="/usr/lib/systemd/system/motd-news.timer" |
111 | 128 | [[ -f "${motd_timer}" ]] && { |
112 | | - sudo systemctl stop motd-news.timer |
113 | | - sudo systemctl disable motd-news.timer |
| 129 | + sudo systemctl stop motd-news.timer 2>/dev/null |
| 130 | + sudo systemctl disable motd-news.timer 2>/dev/null |
114 | 131 | sudo rm -f ${motd_timer} |
115 | 132 | tolog "56. Disable motd-news.timer" |
116 | 133 | } |
117 | 134 | motd_service="/usr/lib/systemd/system/motd-news.service" |
118 | 135 | [[ -f "${motd_service}" ]] && { |
119 | | - sudo systemctl stop motd-news.service |
120 | | - sudo systemctl disable motd-news.service |
| 136 | + sudo systemctl stop motd-news.service 2>/dev/null |
| 137 | + sudo systemctl disable motd-news.service 2>/dev/null |
121 | 138 | sudo rm -f ${motd_service} |
122 | 139 | tolog "57. Disable motd-news.service" |
123 | 140 | } |
@@ -150,10 +167,10 @@ tolog "59. Disable the ssh.socket and enable ssh.service" |
150 | 167 | # Confirm device information |
151 | 168 | [[ -f "${ophub_release_file}" ]] && { |
152 | 169 | # Get welcome banner value |
153 | | - family_name="$(cat ${ophub_release_file} | grep -E "^FAMILY=" | cut -d"'" -f2)" |
154 | | - platform_name="$(cat ${ophub_release_file} | grep -E "^PLATFORM=" | cut -d"'" -f2)" |
155 | | - soc_name="$(cat ${ophub_release_file} | grep -E "^SOC=" | cut -d"'" -f2 | sed -e "s|\b[a-z]|\U&|g")" |
156 | | - board_name="$(cat ${ophub_release_file} | grep -E "^BOARD=" | cut -d"'" -f2 | sed -e "s|\b[a-z]|\U&|g")" |
| 170 | + family_name="$(cat ${ophub_release_file} | grep -E "^FAMILY=" | cut -d"'" -f2 || true)" |
| 171 | + platform_name="$(cat ${ophub_release_file} | grep -E "^PLATFORM=" | cut -d"'" -f2 || true)" |
| 172 | + soc_name="$(cat ${ophub_release_file} | grep -E "^SOC=" | cut -d"'" -f2 | sed -e "s|\b[a-z]|\U&|g" || true)" |
| 173 | + board_name="$(cat ${ophub_release_file} | grep -E "^BOARD=" | cut -d"'" -f2 | sed -e "s|\b[a-z]|\U&|g" || true)" |
157 | 174 |
|
158 | 175 | # Adjustment parameter name for ANDROID_UBOOT |
159 | 176 | [[ -n "$(cat ${ophub_release_file} | grep -E "^ANDROID_UBOOT=")" ]] && { |
@@ -270,24 +287,12 @@ todo_rootfs_resize="/root/.no_rootfs_resize" |
270 | 287 | tolog "91. Root partition resized successfully" |
271 | 288 | } |
272 | 289 |
|
273 | | -# Update the MAC address for the wireless network card |
274 | | -[[ -d "/lib/firmware" ]] && { |
275 | | - find "/lib/firmware" \ |
276 | | - -type f -name "*.txt" ! -xtype l \ |
277 | | - -exec grep -q '^macaddr=.*' {} \; \ |
278 | | - -exec sh -c ' |
279 | | - new_mac=$(openssl rand -hex 6 | sed "s/\(..\)/\1:/g; s/.$//; s/^./2/") |
280 | | - sed -i "s/^macaddr=.*/macaddr=${new_mac}/" "${1}" |
281 | | - ' _ {} \; 2>/dev/null |
282 | | - tolog "92. Update the MAC address for the wireless network card" |
283 | | -} |
284 | | - |
285 | 290 | # Hidd the IP address of WAN & IPv6 |
286 | 291 | ip_info_file="/etc/update-motd.d/20-ip-info" |
287 | 292 | [[ -f "${ip_info_file}" ]] && { |
288 | 293 | sed -i '/^get_wan.*_address/s/{.*/{ true; }/' ${ip_info_file} |
289 | 294 | sed -i '/if.*ipv6s.*||.*wan6/,/fi/s/^/#/' ${ip_info_file} |
290 | | - tolog "93. Hide the IP address of WAN & IPv6" |
| 295 | + tolog "92. Hide the IP address of WAN & IPv6" |
291 | 296 | } |
292 | 297 |
|
293 | 298 | # Show end message |
|
0 commit comments