Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Simple script to check the current release of Invoice Ninja against what you have installed.
- #If you're current, installed will show the version number in green. If not current, in red.
- #Set "ninja_installed" to whatever the path is to your install's version.txt.
- #If you're using the auto-update script with cron, uncomment the bottom section and change
- #"cronjobtime" to whatever time you have the script set to run (HH:MM format) and it will tell
- #you if the update is going to run "today" or "tomorrow" based on what time you run the checker
- #(no good way to check the cron list directly). Drop in your /etc/update-motd.d/ if you want this
- #to run every time you login via terminal or SSH. Just save it with the appropriate number to
- #control where in the motd the output appears. As usual, use at your own risk.
- #!/bin/bash
- ninja_installed=$(cat "/var/www/ninja/storage/version.txt")
- ninja_current="$((wget -T 15 -qO- https://invoiceninja.org/index.php) | (grep -oP 'Download Version \K[0-9]+\.[0-9]+(\.[0-9]+)'))"
- update_required="no"
- set -f
- array_ninja_installed=(${ninja_installed//./ })
- array_ninja_current=(${ninja_current//./ })
- if (( ${#array_ninja_installed[@]} == "2" ))
- then
- array_ninja_installed+=("0")
- fi
- for ((i=0; i<${#array_ninja_installed[@]}; i++))
- do
- if (( ${array_ninja_installed[$i]} < ${array_ninja_current[$i]} ))
- then
- update_required="yes"
- fi
- done
- printf '\n|==============================|'
- printf '\n| Invoice Ninja Version Status |'
- printf '\n|==============================|'
- printf '\n| Current Release \033[1;32mv%s\033[0m%s |' "$ninja_current"
- case $update_required in
- no)
- printf '\n| Installed Version \033[1;32mv%s\033[0m%s |' "$ninja_installed"
- ;;
- yes)
- printf '\n| Installed Version \033[1;31mv%s\033[0m%s |' "$ninja_installed"
- ;;
- esac
- printf '\n|==============================|\n'
- #case $update_required in
- # no)
- # ;;
- # yes)
- # connecttime=$(date "+%H%M")
- # cronjobtime="18:00"
- # if (( "10#$connecttime" < "10#${cronjobtime//:}" ))
- # then
- # printf '\n\033[1;31mInvoice Ninja will update TODAY at %s\033[0m\n' "$cronjobtime"
- # else
- # printf '\n\033[1;32mInvoice Ninja will update TOMORROW at %s\033[0m\n' "$cronjobtime"
- # fi
- # ;;
- #esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement