Created
October 28, 2017 16:33
-
-
Save adriaaah/87cf90ea8417963bda240d69d6add1d0 to your computer and use it in GitHub Desktop.
Automate Cacti (http://www.cacti.net) a bit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
### Adjust settings ### | |
BASE_DIR='/var/www/admin' | |
CACTI_DB='cacti' | |
CACTI_PATH="${BASE_DIR}"/cacti | |
CACTI_OLD="${BASE_DIR}"/cacti_old | |
CACTI_USER='www-data' | |
### Do not change below lines ### | |
WGET=$(which wget) | |
TAR=$(which tar) | |
MYSQLDUMP=$(which mysqldump) | |
echo "Which release do you want to upgrade to? (eg. 1.1.27)" | |
read RELEASE | |
"${WGET}" http://www.cacti.net/downloads/cacti-"${RELEASE}".tar.gz -O "${BASE_DIR}/cacti-${RELEASE}".tar.gz | |
# Step 3 | |
"${TAR}" xvfz "${BASE_DIR}/cacti-${RELEASE}.tar.gz" -C "${BASE_DIR}" | |
rm -f "${BASE_DIR}/cacti-${RELEASE}".tar.gz | |
# Step 1 | |
echo "Type your MySQL password to dump the DB as back up:" | |
"${MYSQLDUMP}" -l --add-drop-table "${CACTI_DB}" > ~/mysql.cacti -u"$(whoami)" -p | |
# Step 2 | |
rm -rf "${BASE_DIR}"/cacti_old | |
mv "${CACTI_PATH}" "${BASE_DIR}"/cacti_old | |
# Step 4 | |
mv "${BASE_DIR}"/cacti{-*,} | |
# Step 5 | |
cp "${CACTI_OLD}"/include/config.php "${CACTI_PATH}"/include | |
# Step 6 | |
cp "${CACTI_OLD}"/rra/* "${CACTI_PATH}"/rra/ | |
# Step 7 | |
cp -u "${CACTI_OLD}"/scripts/* "${CACTI_PATH}"/scripts/ | |
# Step 8 | |
cp -u -R "${CACTI_OLD}"/resource/* "${CACTI_PATH}"/resource/ | |
# Step 9 | |
chown -R "${CACTI_USER}" "${CACTI_PATH}"rra/ | |
chown -R "${CACTI_USER}" "${CACTI_PATH}"log/ | |
# Step 10 | |
echo "Point your browser to http://your-server/cacti/" | |
chown "${CACTI_USER}" "${CACTI_PATH}"/log | |
chown "${CACTI_USER}" "${CACTI_PATH}"/cache/realtime |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment