Skip to content

Commit

Permalink
Merge pull request #70 from scline/Upgrade_Remote_Pollers
Browse files Browse the repository at this point in the history
  • Loading branch information
scline authored Jun 10, 2020
2 parents e6d5782 + 8be8fae commit e347c20
Showing 1 changed file with 42 additions and 28 deletions.
70 changes: 42 additions & 28 deletions upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,46 @@ wget -qO- $cacti_download_url | tar xzC /tmp/update/cacti
echo "$(date +%F_%R) [Upgrade] Downloading Spine from $spine_download_url"
wget -qO- /tmp/update $spine_download_url | tar xzC /tmp/update/spine/

# cacti install
echo "$(date +%F_%R) [Upgrade] Installing new version of Cacti."
cp -Rf /tmp/update/cacti/*/* /cacti

# fixing permissions
echo "$(date +%F_%R) [Restore] Setting cacti file permissions."
chown -R apache.apache /cacti/resource/
chown -R apache.apache /cacti/cache/
chown -R apache.apache /cacti/log/
chown -R apache.apache /cacti/scripts/
chown -R apache.apache /cacti/rra/
# if not a remote poller, update cacti bits
if [ ${REMOTE_POLLER} != 1 ]; then
echo "$(date +%F_%R) [Upgrade] System not marked as remote poller, updating cacti."

# cacti install
echo "$(date +%F_%R) [Upgrade] Installing new version of Cacti."
cp -Rf /tmp/update/cacti/*/* /cacti

# fixing permissions
echo "$(date +%F_%R) [Restore] Setting cacti file permissions."
chown -R apache.apache /cacti/resource/
chown -R apache.apache /cacti/cache/
chown -R apache.apache /cacti/log/
chown -R apache.apache /cacti/scripts/
chown -R apache.apache /cacti/rra/

# copy templated config files, makes sed command easier
echo "$(date +%F_%R) [Upgrade] Copying config templates for Cacti."
cp -f /template_configs/config.php /cacti/include

# cacti settings
echo "$(date +%F_%R) [Upgrade] Updating cacti settings."
sed -i -e "s/%DB_HOST%/${DB_HOST}/" \
-e "s/%DB_PORT%/${DB_PORT}/" \
-e "s/%DB_NAME%/${DB_NAME}/" \
-e "s/%DB_USER%/${DB_USER}/" \
-e "s/%DB_PASS%/${DB_PASS}/" \
-e "s/%DB_PORT%/${DB_PORT}/" \
-e "s/%RDB_HOST%/${RDB_HOST}/" \
-e "s/%RDB_PORT%/${RDB_PORT}/" \
-e "s/%RDB_NAME%/${RDB_NAME}/" \
-e "s/%RDB_USER%/${RDB_USER}/" \
-e "s/%RDB_PASS%/${RDB_PASS}/" \
/cacti/include/config.php

# attempt db upgrade via cli
echo "$(date +%F_%R) [Upgrade] Attempting to update database via CLI."
php /cacti/cli/upgrade_database.php

fi

# bootstrap, compile, and install spine
echo "$(date +%F_%R) [Upgrade] Compile + Installing new version of Spine."
Expand All @@ -40,12 +69,11 @@ cd /tmp/update/spine/* && \
chmod +s /spine/bin/spine

# copy templated config files, makes sed command easier
echo "$(date +%F_%R) [Upgrade] Copying config templates for Spine and Cacti."
cp -f /template_configs/config.php /cacti/include
echo "$(date +%F_%R) [Upgrade] Copying config templates for Spine."
cp -f /template_configs/spine.conf /spine/etc

# cacti settings
echo "$(date +%F_%R) [Upgrade] Updating cacti/spine settings."
echo "$(date +%F_%R) [Upgrade] Updating spine settings."
sed -i -e "s/%DB_HOST%/${DB_HOST}/" \
-e "s/%DB_PORT%/${DB_PORT}/" \
-e "s/%DB_NAME%/${DB_NAME}/" \
Expand All @@ -57,22 +85,8 @@ sed -i -e "s/%DB_HOST%/${DB_HOST}/" \
-e "s/%RDB_NAME%/${RDB_NAME}/" \
-e "s/%RDB_USER%/${RDB_USER}/" \
-e "s/%RDB_PASS%/${RDB_PASS}/" \
/cacti/include/config.php \
/spine/etc/spine.conf

# remote poller tasks
if [ ${REMOTE_POLLER} = 1 ]; then
echo "$(date +%F_%R) [Upgrade - Remote Poller] This is slated to be a remote poller, updating cacti configs for these settings."
sed -i -e "s/#$rdatabase/$rdatabase/" \
/cacti/include/config.php
echo "$(date +%F_%R) [Upgrade - Remote Poller] Updating permissions in cacti directory for remote poller template."
chown -R apache.apache /cacti
fi

# attempt db upgrade via clu
echo "$(date +%F_%R) [Upgrade] Attempting to update database via CLI."
php /cacti/cli/upgrade_database.php

# cacti settings
echo "$(date +%F_%R) [Upgrade] Cleaning temp files."
rm -rf /tmp/update
Expand Down

0 comments on commit e347c20

Please sign in to comment.