Skip to content

Instantly share code, notes, and snippets.

@ifthenelse
Last active March 16, 2016 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ifthenelse/1bfecb528cebd045390a to your computer and use it in GitHub Desktop.
Save ifthenelse/1bfecb528cebd045390a to your computer and use it in GitHub Desktop.
Aliases collection for Symfony 2
#!/bin/sh
# If superuser warn and prompt to continue
prompt_exec_as_root () {
if [[ `whoami` = 'root' -o $(id -u) == 0 -a -z "$SUDO_COMMAND" ]]; then
/bin/echo "Warning: you're running the script as superuser.";
/bin/echo "This may cause directory permission issues and you'll probably be unable to access your files anymore. \nIn malmost all the cases you're adviced to run as regular user."
/bin/echo "Do you still want to continue? [Yes/No/Abort] (default: No) "
read REPLY;
else if [[ ! $REPLY -o $REPLY =~ ^[Nn][Oo]?$ -o $REPLY =~ ^[Aa]([Bb][Oo][Rr][Tt])?$ ]]; then
/bin/echo "Operation aborted.\n";
exit $E_NOTROOT;
else if [[ $REPLY != ^[Yy]([Ee][Ss])?$ ]]; then
/bin/echo "Invalid answer.\n";
prompt_exec_as_root;
fi
else
/bin/echo "Greetings $USER, you're not acting as superuser";
fi
}
# Clear all caches
clear_all_caches () {
rm -rf app/cache/*
rm -rf .sass-cache/*
app/console ca:cl --env=prod
app/console ca:cl --env=dev
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment