Update Your Node
There are several ways to update a FIO node, however, all of them basically come down to just replacing the nodeos binary; the differences being how the nodeos binary is running, i.e. as a daemon (using systemctl). While the instructions below pertain specifically to a FIO node being installed and configured using a pre-built FIO deb package, it will apply to production-level nodes.
FIO Node Installed from Deb Package
For a FIO node installed using a pre-built FIO package, including the full package as well as the tar and minimal packages, the process of updating the nodeos binary is a matter of
- Downloading the latest package
- Extract the FIO blockchain binaries
- Replace the installed binaries with the new ones
The following script assumes that the node was installed using the full FIO package deb based on instructions found at Installation Using Packages, specifically that the nodeos application is running as a daemon and that logging is configured.
Destructive
The following script must be run as root/using sudo. Note that the use of 'sudo' is for Advanced users!
#!/usr/bin/env bash
#set -x
echo
if [[ "$EUID" -ne 0 ]]; then
echo "ERROR: Script must be run as root! Use sudo command as follows; sudo ./<script name>"
echo
exit 1
fi
# Utility functions
function pause(){
read -s -n 1 -p "Press any key to continue..."
echo ""
}
if [[ ! -r "${1}" ]]; then
echo "ERROR: A valid archive was NOT specified on the command-line!"
echo " An archive, either the fio package deb or tar.gz file must be specified on the command-line"
echo " Example: sudo ./upgrade-node.sh fioprotocol-3.5.1-ubuntu-20.04-amd64.deb"
echo
echo "Exiting..." && echo
exit 1
fi
archive="${1}"
isValid=false
filetype=$(file -bi --extension ${archive})
if [[ $filetype =~ "deb" ]]; then
isValid=true
elif [[ $filetype =~ "gzip" ]]; then
isValid=true
fi
if ! $isValid; then
echo "ERROR: Only a deb package archive, *.deb, or a tar-gzip, *.tgz/*.tar.gz, file is allowed!"
echo "Exiting ..." && echo
exit 1
fi
# Main script functionality
echo
echo FIO Package Update...
echo
echo "Before proceeding it is recommended to download the most recent snapshot and/or blocks.log"
echo "as a safetly precaution as a node shutdown and start up may corrupt the database."
echo
echo "Caution: Do not perform a 'systemctl restart fio-nodeos' as the restart action occurs too"
echo "fast to properly shutdown, capture the current state, and start up a FIO node!"
echo
pause
echo "If desired, download the latest snapshot and/or blocks.log from https://snap.blockpane.com"
echo
pause
echo -n "Shutting down fio-nodeos..."
#sudo systemctl status fio-nodeos
if (systemctl -q is-active fio-nodeos); then
systemctl stop fio-nodeos >/dev/null 2>&1
fi
echo "Confirm that nodeos is stopped before proceeding"
echo
pause
# A log rotation is needed; not doing this causes odd logging behavior; while nodeos will
# start up fine either
# - nodeos loses its pointer to the end of the log file
# - nodeos has to re-read the entire log file which may take a long time
echo "Forcing a log rotation. Note that this might take 10-20 seconds..."
logrotate -vf /etc/logrotate.d/fio-nodeos >/dev/null 2>&1
echo
sleep 5
pushd /tmp >/dev/null
if [[ $filetype =~ "deb" ]]; then
echo -n "Extracting archive..."
ar x ${archive} data.tar.xz
pushd /usr/local/bin >/dev/null
mv fio-nodeos-run fio-nodeos-run.bak
rm -f clio fio-nodeos fio-wallet
tar xf /tmp/data.tar.xz --transform='s|.*/||' --wildcards './usr/local/bin/*'
mv fio-nodeos-run.bak fio-nodeos-run
rm -f /tmp/data.tar.xz
popd
elif [[ $filetype =~ "gzip" ]]; then
echo -n "Extracting archive..."
tar -zxf ${archive}
pushd /usr/local/bin >/dev/null
rm -f clio fio-nodeos fio-wallet
cp /tmp/fio/*/bin/clio .
cp /tmp/fio/*/bin/fio-nodeos .
cp /tmp/fio/*/bin/fio-wallet .
rm -rf /tmp/fio
popd >/dev/null
fi
popd >/dev/null
echo "Update complete"
echo
echo "Restarting FIO..."
sleep 5
systemctl start fio-nodeos
Updated 9 days ago