You are not logged in.

#1 2014-07-02 12:25:24

hauntedybyshadow
Member
Registered: 2014-07-02
Posts: 3
Website

Script issue.

So I have an interesting one here.  So I am making an installation script for WP and I is working well so far however one small detail.  Since this is being created from root in this script I have to chown the entire created directory to the user.  So my current code is as follows.

echo 'What domain do you want this installed on?'

read domain

mkdir $domain

chown -R $name:$name $domain

cd $domain

Whats odd is using the -R flag in a stand alone command works as it should, as is the variable through out the rest of the script.  Is there something i'm missing since it's a script and not a stand alone bash command?

Offline

#2 2014-07-02 12:30:47

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Script issue.

What do you expect the value of "$name" to be, in that script?

Also, quoting.

Offline

#3 2014-07-02 12:34:36

hauntedybyshadow
Member
Registered: 2014-07-02
Posts: 3
Website

Re: Script issue.

Sorry I didn't clarify that in my initial reply.  This is just clip of the script.  There is a assignment of $name earlier in the script that creates $name as the user name for the database/user name.  So that is working too because after I run it I get this.

[root@luigi vhosts]# stat halpmysite.com/

Access: (0755/drwxr-xr-x)  Uid: (  509/halpmysite)   Gid: (  509/halpmysite)

So it is chown'ing the actual directory it's creating but it's not doing it recursively as it should be :-\

Offline

#4 2014-07-02 12:44:19

WorMzy
Administrator
From: Scotland
Registered: 2010-06-16
Posts: 13,737
Website

Re: Script issue.

What do you mean? You just created the directory with mkdir, there's nothing in it to be recursively chowned.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#5 2014-07-02 12:45:04

hauntedybyshadow
Member
Registered: 2014-07-02
Posts: 3
Website

Re: Script issue.

Wow, nevermind Faconindy and WorMzy, thanks for the interest but I just realized my mistake was a derp on my end.  I was doing the chown to early.  I was creating the directory but I need to put the chown after the install or else there is nothing to recursively chown.  Just moved it down past the install and it's good now.  whoops big_smile

Offline

#6 2014-07-02 13:57:59

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,571
Website

Re: Script issue.

Please remember to mark your thread as [SOLVED] if it is fully resolved.

Also, while it will not affect functionality, there is no need for an "echo" followed by "read" as long as you are using bash - just use a prompt for read:

read -p 'What domain do you want this installed on? ' domain

But if you need full /bin/sh compatibility, the separate commands may be better.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

Board footer

Powered by FluxBB