-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
01b9ce7
commit fac5346
Showing
1 changed file
with
46 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
|
||
INSTALL_DIR=~/.phpctl | ||
if [ -z "$1" ]; then | ||
SUDO=sudo | ||
SYMLINK_DIR=/usr/local/bin | ||
else | ||
SUDO="" | ||
SYMLINK_DIR=$1 | ||
fi | ||
|
||
echo -e "\033[0;33mInstalling phpctl at \033[0m$INSTALL_DIR" | ||
if [ -d "$INSTALL_DIR" ]; then | ||
echo "The install directory is not empty. Attempting to remove it..." | ||
rm -rI $INSTALL_DIR | ||
fi | ||
|
||
echo -n "" | ||
git clone --quiet https://github.com/opencodeco/phpctl.git $INSTALL_DIR & | ||
PID=$! | ||
while kill -0 $PID 2> /dev/null; do | ||
for CHAR in '-' '/' '|' '\'; do | ||
printf "\b$CHAR" | ||
sleep 0.1 | ||
done | ||
done | ||
printf "\r" | ||
|
||
|
||
if [ -z "$1" ]; then | ||
echo -n "Sudo will be prompted to symlink the phpctl files." | ||
else | ||
echo -n "Files will be symlinked to ${SYMLINK_DIR}." | ||
fi | ||
echo -e -n " \033[0;32mDo you want to continue? (y/n)\033[0m " | ||
read -r answer | ||
if [ "$answer" != "${answer#[Yy]}" ]; then | ||
$SUDO ${INSTALL_DIR}/scripts/symlink-bins.sh ${INSTALL_DIR} | ||
else | ||
echo -e "\033[0;31mTo use phpctl globally, link the cloned script to your bin directory, like:\033[0m" | ||
echo "" | ||
for file in "${INSTALL_DIR}"/bin/*; do | ||
bin=$(basename "$file") | ||
echo " ${SUDO} ln -sf ${INSTALL_DIR}/bin/$bin ${SYMLINK_DIR}/$bin" | ||
done | ||
fi |