HOW TO: Keep packages & settings AFTER upgrading.
Hi,
many of you (like me) had troubles / work after each UPGRADE.
- REINSTALL our personal packages, other than what comes as a default.
- COPY specific files / configurations after an upgrade.
Most is done by OpenWRT automatically, however some needs a little tweaking.
So, if you did NOT CHANGE, add some packages or configuration, than just leave everything as is ... OpenWRT works like a charm out of the box
For everyone else here are some suggestions:
What to do:
Make a LIST of all currently install packages:
opkg list-installed > /etc/config/my_installed_packages
You might want to put the command into a CRON ... depending on how much you keep changing the packages on your router
EDIT this file, which keeps track of what to SAVE during image upgrades:
/etc/sysupgrade.conf
Here is a SAMPLE of such a file:
## This file contains files and directories that should
## be preserved during an upgrade.
## Info about packages THIS FILE
/etc/sysupgrade.conf
# LIST of all installed packages
# CREATED using: "opkg list-installed > /etc/config/installed.packages"
# RUN this after you install NEW packages!
/etc/config/installed.packages
# RESTORE suing: "opkg update
# && opkg list-installed | cut -f 1 -d ' ' | sort -u > /tmp/currentpkg
# && cat /etc/config/my_installed_packages | cut -f 1 -d ' ' | sort -u > /tmp/oldpkg
# && grep -v -F -x -f /tmp/currentpkg /tmp/oldpkg > /tmp/inst
# && opkg install $(cat /tmp/inst | sort -u)
# && rm /tmp/currentpkg /tmp/oldpkg /tmp/inst"
#
# "opkg update && opkg list-installed | cut -f 1 -d ' ' | sort -u > /tmp/currentpkg && cat /etc/config/my_installed_packages | cut -f 1 -d ' ' | sort -u > /tmp/oldpkg && grep -v -F -x -f /tmp/currentpkg /tmp/oldpkg > /tmp/inst && opkg install $(cat /tmp/inst | sort -u) && rm /tmp/currentpkg /tmp/oldpkg /tmp/inst"
#
## FOLDERS
# /etc/example/
/etc/crontabs/
/etc/dropbear/
/etc/openvpn/
/etc/profile
/etc/samba/
/etc/unbound/
/root/
## FILES
# /etc/example.conf
/etc/TZ
/etc/banner
AFTER an upgrade run this command:
opkg update && opkg list-installed | cut -f 1 -d ' ' | sort -u > /tmp/currentpkg && cat /etc/config/my_installed_packages | cut -f 1 -d ' ' | sort -u > /tmp/oldpkg && grep -v -F -x -f /tmp/currentpkg /tmp/oldpkg > /tmp/inst && opkg install $(cat /tmp/inst | sort -u) && rm /tmp/currentpkg /tmp/oldpkg /tmp/inst
This will compare your current (after upgrade) list of packages and compares them to the one you previously saved in /etc/config/installed.packages
and copies all missing items. OpenWRT is smart enough to not copy things which are NOT compatible with the current version you have installed.
A few common hurdles:
Can NOT access the CLI with SSH remotely:
check your SSH client and see if it wants to start a SHELL (other than the default ash). In my setup, using PuTTY I have PuTTY execute (setting under connection/SSH/Remote command
:
/bin/bash -l
SAMBA does not work anymore
check your NETWORK SHARES
, you might need to recreate them.
UPDATES:
@jeff was pointing out that in version 19.x of OpenWRT there is a NEW option of sysupgrade -k
include in backup a list of current installed packages at
/etc/backup/installed_packages.txt
This option does what I suggested to be done on the CLI above. The option -k
is set / or not depending on where you get your OpenWRT images from.
I CHANGED the name of the file containing the installed packes to avoid any confusion with what sysupgrade
does.