-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1115 from markshust/feature/blackfire-helper-script
New `bin/blackfire` script to enable, disable, or check status of Blackfire extension
- Loading branch information
Showing
3 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env bash | ||
|
||
S=$(bin/clinotty cat /usr/local/etc/php/conf.d/blackfire.ini | grep -iGc '\;extension=blackfire.so'); | ||
|
||
blackfire_status() { | ||
if [[ $S == 1 ]]; then | ||
echo "Blackfire is disabled." | ||
else | ||
echo "Blackfire is enabled." | ||
fi | ||
} | ||
|
||
blackfire_toggle() { | ||
if [[ $S == 1 ]]; then | ||
blackfire_enable | ||
else | ||
blackfire_disable | ||
fi | ||
} | ||
|
||
blackfire_enable() { | ||
if [[ $S == 1 ]]; then | ||
bin/root sed -i -e 's/^;extension=blackfire.so/extension=blackfire.so/g' /usr/local/etc/php/conf.d/blackfire.ini | ||
sleep 1 | ||
bin/restart phpfpm | ||
echo "Blackfire has been enabled." | ||
else | ||
echo "Blackfire is already enabled." | ||
fi | ||
} | ||
|
||
blackfire_disable() { | ||
if [[ $S == 0 ]]; then | ||
bin/root sed -i -e 's/^extension=blackfire.so/;extension=blackfire.so/g' /usr/local/etc/php/conf.d/blackfire.ini | ||
sleep 1 | ||
bin/restart phpfpm | ||
echo "Blackfire has been disabled." | ||
else | ||
echo "Blackfire is already disabled." | ||
fi | ||
} | ||
|
||
firstArgLetter="$(echo "$1" | head -c 1)" | ||
|
||
if [[ $firstArgLetter == "d" ]]; then | ||
blackfire_disable | ||
elif [[ $firstArgLetter == "e" ]]; then | ||
blackfire_enable | ||
elif [[ $firstArgLetter == "t" ]]; then | ||
blackfire_toggle | ||
elif [[ $firstArgLetter == "s" ]]; then | ||
blackfire_status | ||
else | ||
printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as an argument.\nEx: bin/blackfire status\n" | ||
fi |