Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
— |
user:sprobst:blog:openwrt_-_kleines_buildimage_script_v0.2 [2024/10/17 07:28] (aktuell) SProbst angelegt |
||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
+ | ====== openwrt - kleines Buildimage Script v0.2 ====== | ||
+ | |||
+ | Ich habe das Script für openwrt Buildimage etwas optimiert. | ||
+ | |||
+ | <code bash| owrt_buildimage.sh> | ||
+ | #!/usr/bin/bash | ||
+ | |||
+ | # Funktion zum Setzen der Konfigurationsvariablen | ||
+ | set_config() { | ||
+ | KERNEL_PARTSIZE=256 | ||
+ | ROOTFS_PARTSIZE=2048 | ||
+ | OWRTVER="23.05.4" | ||
+ | ARCH="bcm27xx/bcm2711" | ||
+ | ARCHSUB=${ARCH////-} | ||
+ | PKGS="luci-app-snmpd snmpd usbutils tio tmux vim tcpdump luci-app-lxc luci-i18n-lxc-de lxc lxc-attach lxc-auto lxc-autostart lxc-cgroup lxc-checkconfig lxc-common lxc-config lxc-configs lxc-console lxc-copy lxc-create lxc-destroy lxc-device lxc-execute lxc-freeze lxc-hooks lxc-info lxc-init lxc-ls lxc-monitor lxc-monitord lxc-snapshot lxc-start lxc-stop lxc-templates lxc-top lxc-unfreeze lxc-unprivileged lxc-unshare lxc-user-nic lxc-usernsexec docker docker-compose podman luci-app-dockerman luci-i18n-dockerman-de luci-app-adblock luci-app-attendedsysupgrade luci-app-firewall luci-app-opkg luci-app-snmpd luci-app-statistics luci-i18n-adblock-de luci-i18n-attendedsysupgrade-de luci-i18n-base-de luci-i18n-lxc-de" | ||
+ | PROFIL="NONE" | ||
+ | DOWNPATH="$HOME/Downloads" | ||
+ | FOLDER="openwrt-imagebuilder-$OWRTVER-$ARCHSUB.Linux-x86_64" | ||
+ | } | ||
+ | |||
+ | # Funktion zum Herunterladen und Entpacken des Image Builders | ||
+ | download_and_extract() { | ||
+ | [[ -d $DOWNPATH ]] || mkdir -p $DOWNPATH | ||
+ | cd $DOWNPATH/ | ||
+ | if [[ ! -d $FOLDER ]]; then | ||
+ | wget -q -O - https://downloads.openwrt.org/releases/$OWRTVER/targets/$ARCH/openwrt-imagebuilder-$OWRTVER-$ARCHSUB.Linux-x86_64.tar.xz | tar xfJ - | ||
+ | fi | ||
+ | cd $FOLDER | ||
+ | } | ||
+ | |||
+ | # Funktion zum Anpassen der Partitionsgrößen in der Konfiguration | ||
+ | adjust_partition_sizes() { | ||
+ | sed -i "s/CONFIG_TARGET_KERNEL_PARTSIZE=.*/CONFIG_TARGET_KERNEL_PARTSIZE=$KERNEL_PARTSIZE/; s/CONFIG_TARGET_ROOTFS_PARTSIZE=.*/CONFIG_TARGET_ROOTFS_PARTSIZE=$ROOTFS_PARTSIZE/" .config | ||
+ | } | ||
+ | |||
+ | # Funktion zum Erstellen des Images | ||
+ | build_image() { | ||
+ | if [[ $PROFIL == "NONE" ]]; then | ||
+ | make image PACKAGES="${PKGS}" | ||
+ | else | ||
+ | make image PROFILE=$PROFIL PACKAGES="${PKGS}" | ||
+ | fi | ||
+ | } | ||
+ | |||
+ | # Funktion zum Anzeigen des Ausgabepfads | ||
+ | show_output_path() { | ||
+ | echo "Das Image ist unter $DOWNPATH/$FOLDER/bin/targets/$ARCH zu finden." | ||
+ | echo "Einfach cd $DOWNPATH/$FOLDER/bin/targets/$ARCH in der Konsole eingeben oder im Filer/Dateimanager suchen." | ||
+ | } | ||
+ | |||
+ | # Hauptfunktion | ||
+ | main() { | ||
+ | set_config | ||
+ | download_and_extract | ||
+ | adjust_partition_sizes | ||
+ | build_image | ||
+ | show_output_path | ||
+ | } | ||
+ | |||
+ | # Ausführung der Hauptfunktion | ||
+ | main | ||
+ | </code> | ||
+ | |||
+ | |||
+ | {{tag>openwrt build script image}} | ||
+ | |||
+ | |||
+ | |||