Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revisionBoth sides next revision
docs:guide-user:advanced:opkg_extras [2023/02/24 15:31] – [Opkg extras] update description vgaeteradocs:guide-user:advanced:opkg_extras [2023/10/03 18:19] – [Instructions] delay for networking to become ready vgaetera
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 for upgraded packages. 
   * Fix symbolic links for installed alternatives.   * Fix symbolic links for installed alternatives.
 +  * Find new configurations for upgraded packages.
  
 ===== Implementation ===== ===== Implementation =====
Line 21: Line 21:
   * Identify package types with [[man>grep(1)|grep]] and [[man>find(1)|find]], and RWM with [[man>mount(8)|mount]].   * Identify package types with [[man>grep(1)|grep]] and [[man>find(1)|find]], and RWM with [[man>mount(8)|mount]].
   * Support importing [[https://github.com/openwrt/openwrt/blob/master/package/base-files/files/sbin/sysupgrade#L249-L255|user-installed]] packages from [[docs:techref:sysupgrade|Sysupgrade]].   * Support importing [[https://github.com/openwrt/openwrt/blob/master/package/base-files/files/sbin/sysupgrade#L249-L255|user-installed]] packages from [[docs:techref:sysupgrade|Sysupgrade]].
-  * Use [[docs:guide-user:base-system:hotplug|Hotplug]] to detect WAN connectivity and trigger profile restore.+  * Use [[docs:guide-user:advanced:hotplug_extras|Hotplug extras]] to detect WAN connectivity and trigger profile restore.
   * Utilize lockfiles with [[https://github.com/openwrt/openwrt/blob/master/package/utils/busybox/patches/220-add_lock_util.patch|lock]] to avoid race conditions and loops.   * Utilize lockfiles with [[https://github.com/openwrt/openwrt/blob/master/package/utils/busybox/patches/220-add_lock_util.patch|lock]] to avoid race conditions and loops.
   * Perform [[man>reboot(8)|reboot]] to apply changes after automatic profile restore.   * Perform [[man>reboot(8)|reboot]] to apply changes after automatic profile restore.
-  * Write and read non-interactive logs with [[docs:guide-user:base-system:log.essentials|Syslog]] for troubleshooting. 
   * 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 42: Line 41:
 | ''**proc** <cmd> < <pkgs>'' | Process packages from stdin with the given sub-command. | | ''**proc** <cmd> < <pkgs>'' | Process packages from stdin with the given sub-command. |
 | ''**reinstall** <pkgs>'' | Reinstall specific packages. | | ''**reinstall** <pkgs>'' | Reinstall specific packages. |
-| ''**newconf** [<path>]'' | Find new configurations for upgraded packages. | 
 | ''**altlink**'' | Fix symbolic links for installed alternatives. | | ''**altlink**'' | Fix symbolic links for installed alternatives. |
 +| ''**newconf** [<path>]'' | Find new configurations for upgraded packages. |
  
 ===== Instructions ===== ===== Instructions =====
Line 56: Line 55:
 case "${OPKG_CMD}" in case "${OPKG_CMD}" in
 (init|uci|import|save|restore|rollback|upgr\ (init|uci|import|save|restore|rollback|upgr\
-|export|proc|reinstall|newconf|altlink) opkg_"${@}" ;;+|export|proc|reinstall|altlink|newconf) opkg_"${@}" ;;
 (*) command opkg "${@}" ;; (*) command opkg "${@}" ;;
 esac esac
Line 242: Line 241:
 local OPKG_OPT="${OPKG_UCI}" local OPKG_OPT="${OPKG_UCI}"
 opkg install "${@}" ${OPKG_OPT} opkg install "${@}" ${OPKG_OPT}
-} 
- 
-opkg_newconf() { 
-local OPKG_OPT="${1:-${OPKG_UCI}}" 
-find "${OPKG_OPT}" -name "*-opkg" 
 } }
  
Line 256: Line 250:
 do ln -f -s "${OPKG_ALT}" "${OPKG_LINK}" do ln -f -s "${OPKG_ALT}" "${OPKG_LINK}"
 done done
 +}
 +
 +opkg_newconf() {
 +local OPKG_OPT="${1:-${OPKG_UCI}}"
 +find "${OPKG_OPT}" -name "*-opkg"
 } }
 EOF EOF
Line 267: Line 266:
 do if [ ! -e /etc/opkg-restore-"${OPKG_CONF}" ] \ do if [ ! -e /etc/opkg-restore-"${OPKG_CONF}" ] \
 && lock -n /var/lock/opkg-restore \ && lock -n /var/lock/opkg-restore \
 +&& sleep 10 \
 && opkg update && opkg update
 then . /etc/profile.d/opkg.sh then . /etc/profile.d/opkg.sh
-opkg restore "${OPKG_CONF}" 2>&+opkg restore "${OPKG_CONF}" &
-| logger -t opkg+/var/log/opkg-restore-"${OPKG_CONF}"
 touch /etc/opkg-restore-"${OPKG_CONF}" touch /etc/opkg-restore-"${OPKG_CONF}"
 lock -u /var/lock/opkg-restore lock -u /var/lock/opkg-restore
Line 295: Line 295:
 opkg rollback opkg rollback
  
-# Set up a custom Opkg profile +# Set up Opkg profiles 
-uci set opkg.defaults.restore="custom"+uci set opkg.defaults.restore="init custom
 +uci set opkg.init="opkg" 
 +uci add_list opkg.init.ipkg="losetup" 
 +uci add_list opkg.init.ipkg="parted" 
 +uci add_list opkg.init.ipkg="resize2fs"
 uci set opkg.custom="opkg" uci set opkg.custom="opkg"
 uci add_list opkg.custom.rpkg="dnsmasq" uci add_list opkg.custom.rpkg="dnsmasq"
Line 306: Line 310:
  
 # Check Opkg log # Check Opkg log
-logread -opkg+tail -f /var/log/opkg-*
  
 # Upgrade packages # Upgrade packages
 opkg update opkg update
 opkg upgr opkg upgr
 +
 +# Maintenance
 +opkg altlink
 +opkg newconf
 </code> </code>
  
 ===== Automated ===== ===== Automated =====
 <code bash> <code bash>
-uclient-fetch -O opkg-extras.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/opkg_extras?codeblock=0"+wget -U "" -O opkg-extras.sh "https://openwrt.org/_export/code/docs/guide-user/advanced/opkg_extras?codeblock=0"
 . ./opkg-extras.sh . ./opkg-extras.sh
 </code> </code>
  
  • Last modified: 2023/11/30 19:06
  • by vgaetera