Skip to content

Instantly share code, notes, and snippets.

@zorbash
Last active February 21, 2017 11:56
Show Gist options
  • Save zorbash/98afb51cb7287ff7fe3b2b9a3331dc5f to your computer and use it in GitHub Desktop.
Save zorbash/98afb51cb7287ff7fe3b2b9a3331dc5f to your computer and use it in GitHub Desktop.
Kitto Core Widgets Updater
main() {
set -e
github_base_url=https://raw.githubusercontent.com/kittoframework/kitto/master
print_banner
ask_continue
update_widgets
print_outro
}
print_banner() {
cat <<EOF
╔═══════════════╗
║ Kitto Updater ║
╚═══════════════╝
╔═════════════════════════════════════════════════════════════════════════════════════╗
║ ║
║ The core widgets will be updated ║
║ ║
║ Please backup your sources or use version control, since files will be overwritten ║
║ or removed. ║
║ ║
╚═════════════════════════════════════════════════════════════════════════════════════╝
EOF
}
ask_continue() {
cat <<EOF
╔══════════════════════════════════════════╗
║ Are you sure you wish to continue? (y/n) ║
╚══════════════════════════════════════════╝
EOF
read answer
if echo "$answer" | grep -iq "^y" ;then
echo Yes
else
echo No
exit 1
fi
}
print_outro() {
echo "Update has been completed."
}
update_widgets() {
local widgets="
clock
graph
image
list
meter
number
text
"
for widget in $widgets
do
echo "Updating: $widget"
install -d widgets/$widget
local url="$github_base_url/installer/templates/new/widgets/$widget/$widget.js"
local style_url="$github_base_url/installer/templates/new/widgets/$widget/$widget.scss"
curl -# $url > "widgets/$widget/$widget.js"
curl -# $style_url > "widgets/$widget/$widget.scss"
done
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment