immortalwrt-upgrade.sh
· 3.7 KiB · Bash
原始檔案
#!/bin/sh
# ImmortalWrt image generation script
# This is only intended for dot build upgrades!
# Execute inside a new folder.
# Parameters: change to your configuration!
routerUser="root"
routerIp="192.168.0.1"
version="23.05.1"
baseUrl="https://downloads.immortalwrt.org/releases/${version}/targets/x86/64/"
builderFileName="immortalwrt-imagebuilder-${version}-x86-64.Linux-x86_64.tar.xz"
pkgConfig="-dnsmasq dnsmasq-full ip-full vim vim-runtime -ethtool kmod-e1000ethtool-full \
kmod-nf-nat kmod-nf-nat6 kmod-tls kmod-nft-arp kmod-nft-compat kmod-nft-connlimit kmod-nft-dup-inet kmod-nft-queue kmod-nft-socket kmod-nft-tproxy kmod-nft-xfrm kmod-nft-offload \
iptables-nft ip6tables-nft kmod-ipt-nat6 kmod-ipt-nat-extra kmod-ipt-nathelper-rtsp kmod-sched-mqprio kmod-ipt-offload \
kmod-e1000 kmod-e1000e kmod-igb kmod-ixgbe kmod-ixgbevf kmod-igc \
# intel-microcode iucode-tool kmod-i2c-i801 kmod-w83627hf-wdt kmod-itco-wdt \
# kmod-vmxnet3 open-vm-tools open-vm-tools-fuse \
# virtio-console-helper qemu-ga \
kmod-usb2 kmod-usb3 usbutils exfat-fsck exfat-mkfs kmod-fs-exfat kmod-usb-storage kmod-usb-storage-extras kmod-usb-storage-uas kmod-usb-serial kmod-usb-hid \
luci-i18n-opkg-zh-cn luci-i18n-firewall-zh-cn \
luci-i18n-passwall-zh-cn luci-app-passwall xray-core \
luci-app-upnp luci-i18n-upnp-zh-cn \
luci-app-wol luci-i18n-wol-zh-cn \
luci-app-banip luci-i18n-banip-zh-cn \
luci-app-watchcat luci-i18n-watchcat-zh-cn \
luci-app-uhttpd uhttpd \
luci-theme-bootstrap luci-theme-argon \
luci-app-statistics luci-i18n-statistics-zh-cn collectd-mod-disk collectd-mod-cpu collectd-mod-cpufreq collectd-mod-df collectd-mod-interface collectd-mod-processes collectd-mod-uptime collectd-mod-vmem collectd-mod-email collectd-mod-ethstat collectd-mod-conntrack collectd-mod-dhcpleases collectd-mod-syslog collectd-mod-write-http collectd-mod-ping collectd-mod-dns collectd-mod-memory collectd-mod-thermal collectd-mod-nginx collectd-mod-sensors collectd-mod-smart smartmontools smartmontools-drivedb \
"
eval `ssh-agent -s`
ssh-add ~/.ssh/codgi-ssh.pem
echo "# STEP 1. Downloading OpenWrt ${version} Image Builder ..."
# Download OpenWrt image builder and extract
if ! [ -f "./${builderFileName}" ]
then
wget "$baseUrl/$builderFileName" -P .
fi
rm -rf ./builder
mkdir ./builder
tar xf ./$builderFileName -C ./builder/ --strip-components=1
cd ./builder
# echo "# STEP 2. Backing up current configurations ..."
# Backup configurations from router
# routerSsh="${routerUser}@${routerIp}"
# ssh ${routerSsh} 'sysupgrade -b ~/backup.tar.gz'
# scp -O "${routerSsh}:~/backup.tar.gz" ./ || exit 1
# mkdir ./backup
# tar xf ./backup.tar.gz -C ./backup/
# Update custom feed
# sed -i "s/openwrt-[0-9]\{2\}.[0-9]\{2\}.[0-9]/openwrt-${version}/g" ./backup/etc/opkg/customfeeds.conf
echo "# STEP 3. Preparing to build image ..."
# Add custom feeds to builder
# cat ./backup/etc/opkg/customfeeds.conf >> ./repositories.conf
# cp ./backup/etc/opkg/keys/* ./keys
# Set grub timeout to 0
sed -i 's/CONFIG_GRUB_TIMEOUT="[0-9]"/CONFIG_GRUB_TIMEOUT="0"/g' ./.config
# Image generation config
sed -i "s/CONFIG_TARGET_ROOTFS_EXT4FS=y/CONFIG_TARGET_ROOTFS_EXT4FS=n/g" ./.config
sed -i "s/CONFIG_VHDX_IMAGES=y/CONFIG_VHDX_IMAGES=n/g" ./.config
sed -i "s/CONFIG_QCOW2_IMAGES=y/CONFIG_QCOW2_IMAGES=n/g" ./.config
sed -i "s/CONFIG_ISO_IMAGES=y/CONFIG_ISO_IMAGES=n/g" ./.config
#sed -i "s/CONFIG_VMDK_IMAGES=y/CONFIG_VMDK_IMAGES=n/g" ./.config
#sed -i "s/CONFIG_VDI_IMAGES=y/CONFIG_VDI_IMAGES=n/g" ./.config
# Language config
sed -i "s/# CONFIG_LUCI_LANG_en is not set/CONFIG_LUCI_LANG_en=y/g" ./.config
echo "# STEP 4. Building image ..."
make image FILES="backup" PACKAGES="$pkgConfig" ROOTFS_PARTSIZE=1024 j=32 V=sc
echo "# DONE. See built images under: ./builder/bin/targets/x86/64/"
1 | #!/bin/sh |
2 | # ImmortalWrt image generation script |
3 | # This is only intended for dot build upgrades! |
4 | # Execute inside a new folder. |
5 | |
6 | # Parameters: change to your configuration! |
7 | routerUser="root" |
8 | routerIp="192.168.0.1" |
9 | version="23.05.1" |
10 | baseUrl="https://downloads.immortalwrt.org/releases/${version}/targets/x86/64/" |
11 | builderFileName="immortalwrt-imagebuilder-${version}-x86-64.Linux-x86_64.tar.xz" |
12 | pkgConfig="-dnsmasq dnsmasq-full ip-full vim vim-runtime -ethtool kmod-e1000ethtool-full \ |
13 | kmod-nf-nat kmod-nf-nat6 kmod-tls kmod-nft-arp kmod-nft-compat kmod-nft-connlimit kmod-nft-dup-inet kmod-nft-queue kmod-nft-socket kmod-nft-tproxy kmod-nft-xfrm kmod-nft-offload \ |
14 | iptables-nft ip6tables-nft kmod-ipt-nat6 kmod-ipt-nat-extra kmod-ipt-nathelper-rtsp kmod-sched-mqprio kmod-ipt-offload \ |
15 | kmod-e1000 kmod-e1000e kmod-igb kmod-ixgbe kmod-ixgbevf kmod-igc \ |
16 | # intel-microcode iucode-tool kmod-i2c-i801 kmod-w83627hf-wdt kmod-itco-wdt \ |
17 | # kmod-vmxnet3 open-vm-tools open-vm-tools-fuse \ |
18 | # virtio-console-helper qemu-ga \ |
19 | kmod-usb2 kmod-usb3 usbutils exfat-fsck exfat-mkfs kmod-fs-exfat kmod-usb-storage kmod-usb-storage-extras kmod-usb-storage-uas kmod-usb-serial kmod-usb-hid \ |
20 | luci-i18n-opkg-zh-cn luci-i18n-firewall-zh-cn \ |
21 | luci-i18n-passwall-zh-cn luci-app-passwall xray-core \ |
22 | luci-app-upnp luci-i18n-upnp-zh-cn \ |
23 | luci-app-wol luci-i18n-wol-zh-cn \ |
24 | luci-app-banip luci-i18n-banip-zh-cn \ |
25 | luci-app-watchcat luci-i18n-watchcat-zh-cn \ |
26 | luci-app-uhttpd uhttpd \ |
27 | luci-theme-bootstrap luci-theme-argon \ |
28 | luci-app-statistics luci-i18n-statistics-zh-cn collectd-mod-disk collectd-mod-cpu collectd-mod-cpufreq collectd-mod-df collectd-mod-interface collectd-mod-processes collectd-mod-uptime collectd-mod-vmem collectd-mod-email collectd-mod-ethstat collectd-mod-conntrack collectd-mod-dhcpleases collectd-mod-syslog collectd-mod-write-http collectd-mod-ping collectd-mod-dns collectd-mod-memory collectd-mod-thermal collectd-mod-nginx collectd-mod-sensors collectd-mod-smart smartmontools smartmontools-drivedb \ |
29 | " |
30 | |
31 | eval `ssh-agent -s` |
32 | ssh-add ~/.ssh/codgi-ssh.pem |
33 | |
34 | echo "# STEP 1. Downloading OpenWrt ${version} Image Builder ..." |
35 | |
36 | # Download OpenWrt image builder and extract |
37 | if ! [ -f "./${builderFileName}" ] |
38 | then |
39 | wget "$baseUrl/$builderFileName" -P . |
40 | fi |
41 | rm -rf ./builder |
42 | mkdir ./builder |
43 | tar xf ./$builderFileName -C ./builder/ --strip-components=1 |
44 | cd ./builder |
45 | |
46 | # echo "# STEP 2. Backing up current configurations ..." |
47 | |
48 | # Backup configurations from router |
49 | # routerSsh="${routerUser}@${routerIp}" |
50 | # ssh ${routerSsh} 'sysupgrade -b ~/backup.tar.gz' |
51 | # scp -O "${routerSsh}:~/backup.tar.gz" ./ || exit 1 |
52 | # mkdir ./backup |
53 | # tar xf ./backup.tar.gz -C ./backup/ |
54 | |
55 | # Update custom feed |
56 | # sed -i "s/openwrt-[0-9]\{2\}.[0-9]\{2\}.[0-9]/openwrt-${version}/g" ./backup/etc/opkg/customfeeds.conf |
57 | |
58 | echo "# STEP 3. Preparing to build image ..." |
59 | |
60 | # Add custom feeds to builder |
61 | # cat ./backup/etc/opkg/customfeeds.conf >> ./repositories.conf |
62 | # cp ./backup/etc/opkg/keys/* ./keys |
63 | |
64 | # Set grub timeout to 0 |
65 | sed -i 's/CONFIG_GRUB_TIMEOUT="[0-9]"/CONFIG_GRUB_TIMEOUT="0"/g' ./.config |
66 | |
67 | # Image generation config |
68 | sed -i "s/CONFIG_TARGET_ROOTFS_EXT4FS=y/CONFIG_TARGET_ROOTFS_EXT4FS=n/g" ./.config |
69 | sed -i "s/CONFIG_VHDX_IMAGES=y/CONFIG_VHDX_IMAGES=n/g" ./.config |
70 | sed -i "s/CONFIG_QCOW2_IMAGES=y/CONFIG_QCOW2_IMAGES=n/g" ./.config |
71 | sed -i "s/CONFIG_ISO_IMAGES=y/CONFIG_ISO_IMAGES=n/g" ./.config |
72 | #sed -i "s/CONFIG_VMDK_IMAGES=y/CONFIG_VMDK_IMAGES=n/g" ./.config |
73 | #sed -i "s/CONFIG_VDI_IMAGES=y/CONFIG_VDI_IMAGES=n/g" ./.config |
74 | |
75 | # Language config |
76 | sed -i "s/# CONFIG_LUCI_LANG_en is not set/CONFIG_LUCI_LANG_en=y/g" ./.config |
77 | |
78 | echo "# STEP 4. Building image ..." |
79 | make image FILES="backup" PACKAGES="$pkgConfig" ROOTFS_PARTSIZE=1024 j=32 V=sc |
80 | |
81 | echo "# DONE. See built images under: ./builder/bin/targets/x86/64/" |