Skip to content

Commit

Permalink
Merge pull request #109 from wallmari/install_upgrade
Browse files Browse the repository at this point in the history
* Add upgrade option to install script
  • Loading branch information
pingpongsneak committed Aug 9, 2022
2 parents cd62d75 + dea0e72 commit cf67881
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions install/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ do
echo
exit 0
;;
--upgrade)
UPGRADE=true
IS_SKIP_CONFIG=true
;;
--runasuser)
CUSTOM_USER=$2
shift
Expand Down Expand Up @@ -537,6 +541,17 @@ install_archive() {

user_create

if [ "${UPGRADE}" = true ]; then
SAVE_DIR=/tmp/cypnode_data
printf " %b Upgrade requested - saving existing node data to %s" "${INFO}" "${SAVE_DIR}"
mkdir -p ${SAVE_DIR}
sudo cp ${CYPHER_CYPNODE_OPT_PATH}/appsettings.json ${SAVE_DIR}
sudo cp -r ${CYPHER_CYPNODE_OPT_PATH}/keys ${SAVE_DIR}
# Not sure we need to save/restore the database
#sudo cp -r ${CYPHER_CYPNODE_OPT_PATH}/storedb ${SAVE_DIR}
printf "%b %b Upgrade requested - saving existing node data to %s\n" "${OVER}" "${TICK}" "${SAVE_DIR}"
fi;

printf " %b Unpacking archive to %s" "${INFO}" "${CYPHER_CYPNODE_TMP_PATH}"
mkdir -p "${CYPHER_CYPNODE_TMP_PATH}"
if [ "${IS_LINUX}" = true ]; then
Expand All @@ -558,6 +573,20 @@ install_archive() {
if [ $CUSTOM_GROUP ]; then
CGROUP=${CUSTOM_GROUP}
fi
if [ "${UPGRADE}" = true ]; then
printf " %b Restoring saved node data" "${INFO}"
SAVE_DIR=/tmp/cypnode_data
sudo cp ${SAVE_DIR}/appsettings.json ${CYPHER_CYPNODE_OPT_PATH}
sudo cp -r ${SAVE_DIR}/keys ${CYPHER_CYPNODE_OPT_PATH}
# Not sure we need to save/restore the database
#sudo cp -r ${SAVE_DIR}/storedb ${CYPHER_CYPNODE_OPT_PATH}
# Apply a new chmod/chown to the keys and database in case the user has changed
sudo chmod -R 775 "${CYPHER_CYPNODE_OPT_PATH}/keys"
sudo chown -R "${CUSER}":"${CGROUP}" "${CYPHER_CYPNODE_OPT_PATH}/keys"
sudo chmod -R 775 "${CYPHER_CYPNODE_OPT_PATH}/storedb"
sudo chown -R "${CUSER}":"${CGROUP}" "${CYPHER_CYPNODE_OPT_PATH}/storedb"
printf "%b %b Restored saved node data - %s can be removed if everything is okay\n" "${OVER}" "${TICK}" "${SAVE_DIR}"
fi;
sudo chmod 775 "${CYPHER_CYPNODE_OPT_PATH}"
sudo chown "${CUSER}":"${CGROUP}" "${CYPHER_CYPNODE_OPT_PATH}"
sudo chmod 664 "${CYPHER_CYPNODE_OPT_PATH}"/appsettings.json
Expand Down

0 comments on commit cf67881

Please sign in to comment.