I am trying to run a simple Bash script called deploy-site.sh
(by http://klau.si/dev). I made the necessary edits to run it locally (change of WORKDIR, etc). I also followed the instructions here.
mkdir ~/bin
chmod 755 ~/bin
(To store the script in my home folder. Then I rebooted, so the system recognizes it.)
sudo chmod +x <path>
sudo chmod 755 <filename>
However, whenever I go to the terminal to execute the Bash script, I get:
$ sudo deploy-site.sh <sitename>
sudo: deploy-site.sh: command not found
How can I fix this problem?
Here is the original script:
#!/bin/bash
if [[ $# -lt 1 || $1 == "--help" || $1 == "-h" ]]
then
echo "Usage:"
echo " sudo `basename $0` SITENAME"
echo "Examples:"
echo " sudo `basename $0` drupal-8"
exit
fi
WORKDIR="/home/klausi/workspace"
APACHEDIR="/etc/apache2/sites-available"
HOSTSFILE="/etc/hosts"
echo "<VirtualHost *:80>
ServerAlias $1.localhost
DocumentRoot $WORKDIR/$1
<Directory \"$WORKDIR/$1\">
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>" > $APACHEDIR/$1.conf
a2ensite $1
service apache2 restart
grep -q "127.0.0.1 $1.localhost" $HOSTSFILE
if [ $? -ne 0 ]; then
echo "127.0.0.1 $1.localhost" >> $HOSTSFILE
fi
As requested, here is the results of echo $PATH
/home/getoprodigy/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
Best Answer
deploy-site.sh
is not in PATH. You have to run it as./deploy-site.sh
if you are in the same directory or/path/deploy-site.sh
if not