Skip to content

Instantly share code, notes, and snippets.

@denpamusic
Created August 18, 2019 23:36
Show Gist options
  • Save denpamusic/c75b039deed76f29d807cf936bfba547 to your computer and use it in GitHub Desktop.
Save denpamusic/c75b039deed76f29d807cf936bfba547 to your computer and use it in GitHub Desktop.
Aliases to commonly used package management tasks for OpenWRT
#!/bin/sh
# /etc/profile.d/opkg.sh
# 'opkg-upgrade' - tries to upgrade every package to the latest version.
alias opkg-upgrade='opkg update; echo; u=$(opkg list-upgradable); [ "x${u}" != "x" ] && (opkg install netifd; echo "${u}" | cut -f1 -d" " | xargs opkg upgrade) || echo Nothing to upgrade.'
# 'opkg-save' - saves list of installed packages to /etc/installed-packages.list,
# which can then be use to reinstall packages with 'opkg-restore'.
# Useful after sysupgrade.
alias opkg-save='opkg list-installed | cut -f1 -d" " > /etc/installed-packages.list'
# 'opkg-restore' - reinstall packages saved by 'opkg-save'.
alias opkg-restore='[ -f "/etc/installed-packages.list" ] && opkg update && while read -r pkg; do opkg install "${pkg}"; done < /etc/installed-packages.list'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment