Skip to content

Instantly share code, notes, and snippets.

@cosic
Last active June 7, 2021 12:50
Show Gist options
  • Save cosic/a6983277686dd8fb120da228d3c22a1f to your computer and use it in GitHub Desktop.
Save cosic/a6983277686dd8fb120da228d3c22a1f to your computer and use it in GitHub Desktop.
Mirakle Activation Script
#!/bin/bash
###############################################
# How to use from terminal:
# $> mirakle.sh on – to enable
# $> mirakle.sh off – to disable
###############################################
MIRAKLE_INIT_SCRIPT_DIR="${HOME}/.gradle/init.d/"
MIRAKLE_INIT_SCRIPT_FILE="${MIRAKLE_INIT_SCRIPT_DIR}/mirakle_init.gradle"
function howTo {
echo
echo "Usage:"
echo "Run ./$(basename $BASH_SOURCE) [command]"
echo
echo "Supported commands:"
echo -e "\tinstall – install mirakle and switch ON them"
echo -e "\tuninstall – remove mirakle at all"
echo -e "\tenable|on – to switch ON mirakle"
echo -e "\tdisable|off – to switch OFF mirakle"
echo
}
COMMAND=$1
case ${COMMAND} in
h|help) howTo
;;
on|enable)
COMMENT_SIGN=""
FINAL_MESSAGE="Mirakle is enabled"
;;
off|disable)
COMMENT_SIGN="//"
FINAL_MESSAGE="Mirakle is disabled"
;;
install)
COMMENT_SIGN=""
FINAL_MESSAGE="Mirakle successfully installed and enabled"
;;
uninstall)
rm ${MIRAKLE_INIT_SCRIPT_FILE}
echo
echo "::Mirakle successfully uninstalled"
exit 0
;;
*)
echo "Wrong argument"
howTo
exit 1
esac
if [[ ! -d ${MIRAKLE_INIT_SCRIPT_DIR} ]]; then
mkdir -p ${MIRAKLE_INIT_SCRIPT_DIR}
fi
if [[ ! -f ${MIRAKLE_INIT_SCRIPT_FILE} ]]; then
touch ${MIRAKLE_INIT_SCRIPT_FILE}
fi
echo "initscript {
repositories {
mavenCentral()
}
dependencies {
classpath \"io.github.adambl4:mirakle:1.4.2\"
}
}
${COMMENT_SIGN}apply plugin: Mirakle
" > ${MIRAKLE_INIT_SCRIPT_FILE}
echo
echo "::${FINAL_MESSAGE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment