Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision Next revisionBoth sides next revision | ||
| docs:guide-user:advanced:opkg_extras [2021/11/01 04:55] – [Instructions] vgaetera | docs:guide-user:advanced:opkg_extras [2023/10/03 18:19] – [Instructions] delay for networking to become ready vgaetera | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Opkg extras ====== | ====== Opkg extras ====== | ||
| - | {{section> | + | {{section> |
| ===== Introduction ===== | ===== Introduction ===== | ||
| Line 13: | Line 13: | ||
| * Restore automatically after firmware upgrade. | * Restore automatically after firmware upgrade. | ||
| * Upgrade all upgradable packages. | * Upgrade all upgradable packages. | ||
| - | * Find new configurations. | + | |
| + | | ||
| ===== Implementation ===== | ===== Implementation ===== | ||
| Line 19: | Line 20: | ||
| * Rely on [[docs: | * Rely on [[docs: | ||
| * Identify package types with [[man> | * Identify package types with [[man> | ||
| - | * Support importing [[https:// | + | * Support importing [[https:// |
| - | * Use [[docs: | + | * Use [[docs: |
| * Utilize lockfiles with [[https:// | * Utilize lockfiles with [[https:// | ||
| * Perform [[man> | * Perform [[man> | ||
| - | * Write and read non-interactive logs with [[docs: | ||
| * Fetch the default profile to restore and roll back from UCI, unless specified manually. | * Fetch the default profile to restore and roll back from UCI, unless specified manually. | ||
| * Take precedence for remove over install to avoid package conflicts while restoring profile. | * Take precedence for remove over install to avoid package conflicts while restoring profile. | ||
| Line 34: | Line 34: | ||
| | '' | | '' | ||
| | '' | | '' | ||
| - | | '' | + | | '' |
| - | | '' | + | | '' |
| | '' | | '' | ||
| | '' | | '' | ||
| Line 41: | Line 41: | ||
| | '' | | '' | ||
| | '' | | '' | ||
| - | | '' | + | | '' |
| + | | '' | ||
| ===== Instructions ===== | ===== Instructions ===== | ||
| + | Copy the following text and paste it in a SSH or serial console of the device | ||
| <code bash> | <code bash> | ||
| # Configure profile | # Configure profile | ||
| Line 52: | Line 54: | ||
| local OPKG_UCI=" | local OPKG_UCI=" | ||
| case " | case " | ||
| - | (init|uci|import|save|restore|rollback\ | + | (init|uci|import|save|restore|rollback|upgr\ |
| - | |upgr|export|newconf|proc|reinstall) opkg_" | + | |export|proc|reinstall|altlink|newconf) opkg_" |
| (*) command opkg " | (*) command opkg " | ||
| esac | esac | ||
| Line 63: | Line 65: | ||
| set opkg.defaults=' | set opkg.defaults=' | ||
| set opkg.defaults.import='/ | set opkg.defaults.import='/ | ||
| - | set opkg.defaults.save=' | + | set opkg.defaults.restore=' |
| - | set opkg.defaults.restore=' | + | set opkg.defaults.rollback=' |
| - | set opkg.defaults.rollback=' | + | |
| set opkg.defaults.upgr=' | set opkg.defaults.upgr=' | ||
| set opkg.defaults.export=' | set opkg.defaults.export=' | ||
| Line 76: | Line 77: | ||
| opkg_uci() { | opkg_uci() { | ||
| local OPKG_OPT=" | local OPKG_OPT=" | ||
| - | local OPKG_OPT=" | + | local OPKG_OPT=" |
| if ! uci -q get opkg > /dev/null | if ! uci -q get opkg > /dev/null | ||
| then opkg init | then opkg init | ||
| Line 95: | Line 96: | ||
| then sed -n -r -e " | then sed -n -r -e " | ||
| \tipkg/ | \tipkg/ | ||
| - | | opkg uci auto | + | | opkg uci main |
| fi | fi | ||
| } | } | ||
| opkg_save() { | opkg_save() { | ||
| - | local OPKG_OPT=" | ||
| local OPKG_WR=" | local OPKG_WR=" | ||
| local OPKG_WI=" | local OPKG_WI=" | ||
| Line 115: | Line 115: | ||
| sed -e " | sed -e " | ||
| sed -e " | sed -e " | ||
| - | } | opkg uci " | + | } | opkg uci main |
| rm -f " | rm -f " | ||
| } | } | ||
| Line 122: | Line 122: | ||
| local OPKG_OPT=" | local OPKG_OPT=" | ||
| local OPKG_CONF=" | local OPKG_CONF=" | ||
| + | for OPKG_CONF in ${OPKG_CONF} | ||
| + | do | ||
| local OPKG_AI=" | local OPKG_AI=" | ||
| local OPKG_PR=" | local OPKG_PR=" | ||
| Line 130: | Line 132: | ||
| | opkg proc install | | opkg proc install | ||
| rm -f " | rm -f " | ||
| + | done | ||
| } | } | ||
| Line 238: | Line 241: | ||
| local OPKG_OPT=" | local OPKG_OPT=" | ||
| opkg install " | opkg install " | ||
| + | } | ||
| + | |||
| + | opkg_altlink() { | ||
| + | sed -n -e "/ | ||
| + | {s/ | ||
| + | | sort -n -t ":" | ||
| + | | while IFS=":" | ||
| + | do ln -f -s " | ||
| + | done | ||
| } | } | ||
| Line 250: | Line 262: | ||
| mkdir -p / | mkdir -p / | ||
| cat << " | cat << " | ||
| - | OPKG_OPT="init main" | + | OPKG_CONF="$(uci -q get opkg.defaults.restore)" |
| - | for OPKG_OPT | + | for OPKG_CONF |
| - | do if [ ! -e / | + | do if [ ! -e / |
| && lock -n / | && lock -n / | ||
| + | && sleep 10 \ | ||
| && opkg update | && opkg update | ||
| then . / | then . / | ||
| - | opkg restore "${OPKG_OPT/ | + | opkg restore "${OPKG_CONF}" &> \ |
| - | | logger -t opkg | + | /var/log/opkg-restore-" |
| - | touch / | + | touch / |
| lock -u / | lock -u / | ||
| reboot | reboot | ||
| Line 282: | Line 295: | ||
| opkg rollback | opkg rollback | ||
| - | # Set up a custom | + | # Set up Opkg profiles |
| - | uci set opkg.defaults.restore=" | + | uci set opkg.defaults.restore=" |
| + | uci set opkg.init=" | ||
| + | uci add_list opkg.init.ipkg=" | ||
| + | uci add_list opkg.init.ipkg=" | ||
| + | uci add_list opkg.init.ipkg=" | ||
| uci set opkg.custom=" | uci set opkg.custom=" | ||
| uci add_list opkg.custom.rpkg=" | uci add_list opkg.custom.rpkg=" | ||
| Line 293: | Line 310: | ||
| # Check Opkg log | # Check Opkg log | ||
| - | logread | + | tail -f /var/log/opkg-* |
| # Upgrade packages | # Upgrade packages | ||
| opkg update | opkg update | ||
| opkg upgr | opkg upgr | ||
| + | |||
| + | # Maintenance | ||
| + | opkg altlink | ||
| + | opkg newconf | ||
| </ | </ | ||
| ===== Automated ===== | ===== Automated ===== | ||
| <code bash> | <code bash> | ||
| - | alias uclient-fetch="uclient-fetch --no-check-certificate" | + | wget -U "" |
| - | uclient-fetch | + | |
| . ./ | . ./ | ||
| </ | </ | ||