Skip to content

Commit

Permalink
added the option to explicitly specify the user
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanix2002 committed Jun 9, 2015
1 parent ae9c3ff commit 1a4a938
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions www-appsetup.sh
Expand Up @@ -16,6 +16,7 @@ show_help() {

set_permissions() {
app_directory=$1
username=$2
current_working_directory=`pwd`
if [ ! -d $app_directory ]; then
#directory does not exist
Expand All @@ -31,7 +32,7 @@ set_permissions() {
if [[ -f "./index.php" || -f "./index.html" || -d "./html" || $html_directories -gt 0 ]]; then
# it's a project's web root
echo "Changing ownership..."
chown -R $USER:www-data .
chown -R $username:www-data .
echo "Changing file and directory permissions..."
find . -type f -exec chmod 644 {} \;
find . -type d -exec chmod 755 {} \;
Expand All @@ -55,6 +56,7 @@ set_permissions() {

argv=$#
#get the number of supplied arguments
username=$USER
app_directory=`pwd`
#sets a default value for the app_directory
if [ $argv -ge 1 ]; then
Expand All @@ -65,10 +67,14 @@ if [ $argv -ge 1 ]; then
fi
app_directory=$1
#if an argument is supplied -- set the value to the argument
if [ $argv -ge 2 ]; then
# we set a different username than the assumed if provided
username=$2
fi
fi
if [ ! $app_directory == "/" ]; then
echo 'Starting WWW-AppSetup script...'
set_permissions $app_directory
set_permissions $app_directory $username
else
echo "You shouldn't run this command from the FileSystem root...Go somewhere else!!"
exit 1
Expand Down

0 comments on commit 1a4a938

Please sign in to comment.