<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Why is my installation script running Splunk as root instead of the new &amp;quot;splunk&amp;quot; user I created? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160538#M32549</link>
    <description>&lt;P&gt;You are doing this on a new machine, right?&lt;/P&gt;

&lt;P&gt;I've done the above steps many times, and it works like a charm. Just don't start splunk while the directory is not yet owned by the splunk user and don't start it as root. Actually, I've always used &lt;CODE&gt;su splunk&lt;/CODE&gt; for that, never that command (but it is mentioned in the docs so it should work - but see the notice about what the command assumes in the first link above).&lt;/P&gt;</description>
    <pubDate>Wed, 05 Aug 2015 14:05:43 GMT</pubDate>
    <dc:creator>jeffland</dc:creator>
    <dc:date>2015-08-05T14:05:43Z</dc:date>
    <item>
      <title>Why is my installation script running Splunk as root instead of the new "splunk" user I created?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160530#M32541</link>
      <description>&lt;P&gt;Hi everyone, &lt;/P&gt;

&lt;P&gt;I created a script to install the splunkforwarder on the clients.&lt;BR /&gt;
The script is called on the main indexer and manages all the clients, but I'm logged in using ssh as root, so:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;root@x.x.x.x
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;During the execution of the script, I'm creating a new user "splunk": &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;adduser splunk
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and I assign the owner permissions of Splunk at the user:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;chown -hR splunk /opt/splunk
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Next I stop splunk and I do:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sudo -i -u splunk 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;To access as the new user and I restart Splunk.&lt;BR /&gt;
Executing the command &lt;CODE&gt;whoami&lt;/CODE&gt;, I'm still running Splunk as root. I have tried to execute all the same commands manually, from the terminal, and they were correctly working. &lt;BR /&gt;
I think is there some trouble changing the user, so in the last comment above. &lt;BR /&gt;
What can I do? &lt;BR /&gt;
Let me know, thank you&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2015 13:04:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160530#M32541</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-08-04T13:04:44Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my installation script running Splunk as root instead of the new "splunk" user I created?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160531#M32542</link>
      <description>&lt;P&gt;The command &lt;CODE&gt;whoami&lt;/CODE&gt; does not do what you think it does.  It just says "what user identity am I using right now", not "what user is the process running".  You need to do this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;ps -ef | grep splunkd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You should see something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;splunk    17145     1  1 Jul29 ?        01:21:01 splunkd -p 8089 restart
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But if that is not the problem...&lt;/P&gt;

&lt;P&gt;This all looks correct and, as you say, it works when you run it manually.  So the problem has to be in your script (duh!).  Are you checking all error codes after each step ($?)?  Are you using the full path name for each command (eg. &lt;CODE&gt;/usr/sbin/useradd&lt;/CODE&gt;, not just &lt;CODE&gt;useradd&lt;/CODE&gt;)?  Are you certain that your update script is being run as user root (you can check this as the first thing the script does)?&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2015 14:04:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160531#M32542</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-04T14:04:36Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my installation script running Splunk as root instead of the new "splunk" user I created?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160532#M32543</link>
      <description>&lt;P&gt;I try the command and splunk is actually running as root : ( &lt;BR /&gt;
I'm typing  adduser splunk nothing else, and I'm executing only one step:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  root@x.x.x.x "command list"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;where in command list there are:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;useradd splunk
chown -hR splunk /opt/splunk
/opt/splunk/bin stop
sudo -i -u splunk
/opt/splunk/bin start
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So I dunno what's wrong, and thank you for the help&lt;/P&gt;</description>
      <pubDate>Tue, 04 Aug 2015 15:22:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160532#M32543</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-08-04T15:22:57Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my installation script running Splunk as root instead of the new "splunk" user I created?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160533#M32544</link>
      <description>&lt;P&gt;Your last 2 commands should be this instead:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sudo -u splunk /opt/splunk/bin/splunk start
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 04 Aug 2015 15:32:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160533#M32544</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-04T15:32:38Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my installation script running Splunk as root instead of the new "splunk" user I created?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160534#M32545</link>
      <description>&lt;P&gt;I tried to use this last command but when I use &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  ps -ef | grep splunkd
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It's running under root again..&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 08:53:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160534#M32545</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-08-05T08:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my installation script running Splunk as root instead of the new "splunk" user I created?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160535#M32546</link>
      <description>&lt;P&gt;Ideally, you would make your script untar the package, create a user (or the other way round), &lt;CODE&gt;chown&lt;/CODE&gt; the new directory to the user before starting splunk for the first time, start splunk as the new user with something like the already mentioned &lt;CODE&gt;sudo -H -u splunk $SPLUNK_HOME/bin/splunk start --accept-license&lt;/CODE&gt;, and set the autostart to use that user as well with &lt;CODE&gt;$SPLUNK_HOME/bin/splunk enable boot-start -user splunk&lt;/CODE&gt; - see &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.4/installation/RunSplunkasadifferentornon-rootuser"&gt;here&lt;/A&gt; and &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.4/Admin/ConfigureSplunktostartatboottime"&gt;here&lt;/A&gt; for docs.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 11:23:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160535#M32546</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-08-05T11:23:07Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my installation script running Splunk as root instead of the new "splunk" user I created?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160536#M32547</link>
      <description>&lt;P&gt;sudo -H -u splunk is not working : ( &lt;/P&gt;

&lt;P&gt;I've already added &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; $SPLUNK_HOME/bin/splunk enable boot-start -user splunk
  $SPLUNK_HOME/bin/splunk start --accept-license
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But seems like it's not changing user &lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 13:06:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160536#M32547</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-08-05T13:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my installation script running Splunk as root instead of the new "splunk" user I created?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160537#M32548</link>
      <description>&lt;P&gt;Run the &lt;CODE&gt;ps -ef&lt;/CODE&gt; command after you do the &lt;CODE&gt;stop&lt;/CODE&gt; command; maybe the stop command is failing.  Are you checking return codes after each step?&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 13:12:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160537#M32548</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-05T13:12:59Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my installation script running Splunk as root instead of the new "splunk" user I created?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160538#M32549</link>
      <description>&lt;P&gt;You are doing this on a new machine, right?&lt;/P&gt;

&lt;P&gt;I've done the above steps many times, and it works like a charm. Just don't start splunk while the directory is not yet owned by the splunk user and don't start it as root. Actually, I've always used &lt;CODE&gt;su splunk&lt;/CODE&gt; for that, never that command (but it is mentioned in the docs so it should work - but see the notice about what the command assumes in the first link above).&lt;/P&gt;</description>
      <pubDate>Wed, 05 Aug 2015 14:05:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160538#M32549</guid>
      <dc:creator>jeffland</dc:creator>
      <dc:date>2015-08-05T14:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my installation script running Splunk as root instead of the new "splunk" user I created?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160539#M32550</link>
      <description>&lt;P&gt;Ok, so your system is working fine if I'm not using ssh, If I log using ssh it's not changing user.&lt;BR /&gt;
I have another question, during the installation I have this error:&lt;BR /&gt;
Can't create directory "/root/.splunk": Permission denied&lt;/P&gt;

&lt;P&gt;I think it's still related to the user, do you have any ideas why?&lt;/P&gt;

&lt;P&gt;Thank you so much for your help : ) &lt;/P&gt;</description>
      <pubDate>Fri, 07 Aug 2015 10:29:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160539#M32550</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-08-07T10:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my installation script running Splunk as root instead of the new "splunk" user I created?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160540#M32551</link>
      <description>&lt;P&gt;What do you mean by "installation"?  Are you using a tarball? What is your installation command?  Why are we being so vague?  Just list out &lt;EM&gt;exactly&lt;/EM&gt; what is in your script, line-by-line and maybe we can get somewhere.&lt;/P&gt;</description>
      <pubDate>Sat, 08 Aug 2015 15:12:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160540#M32551</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-08-08T15:12:12Z</dc:date>
    </item>
    <item>
      <title>Re: Why is my installation script running Splunk as root instead of the new "splunk" user I created?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160541#M32552</link>
      <description>&lt;P&gt;Yes, sorry, this is the script:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  #!/bin/sh
  INSTALL_FILE="splunkforwarder-6.2.3-264376-Linux-x86_64.tgz"
  #The script doesn't require the creation of a public pair ssh key
  # After installation, the forwarder will become a deployment client the passed argument $1
  # Specify the host and management (not web) port of the deployment server
  # that will be managing these forwarder instances.
 DEPLOY_SERVER="$1"
  #outputs.conf
  OUTPUTS='[tcpout]\n
  defaultGroup= default-autolb-group\n\n

 [tcpout:default-autolb-group]\n\n
 server = $DEPLOY_SERVER:9997\n\n

 [tcpout-server://$DEPLOY_SERVER:9997]'
 #Input to monitor needs to be changed
 INPUTS='[monitor:///var/log/*]\n
 sourcetype=syslog\n
host_segment=3\n
index=test\n\n
 [monitor:///var/log/messages]\n
 sourcetype=syslog\n
 host_segment=3\n
 index=test\n\n
 [monitor:///var/log/lastlog]\n
 sourcetype=syslog\n
 host_segment=3\n
 index=test\n\n'

 echo 'checking network...'
 if wget -q 'http://www.splunk.com/bin/splunk/DownloadActivityServlet?       architecture=x86_64&amp;amp;platform=Linux&amp;amp;version=6.2.3&amp;amp;product=universalforwarder&amp;amp;filename=spl      unkforwarder-6.2.3-264376-Linux-x86_64.tgz&amp;amp;wget=true' &amp;gt; /dev/null; 
  then wget -O splunkforwarder-6.2.3-264376-Linux-x86_64.tgz        'http://www.splunk.com/bin/splunk/DownloadActivityServlet? architecture=x86_64&amp;amp;platform=Linux&amp;amp;version=6.2.3&amp;amp;product=universalforwarder&amp;amp;filename=spl unkforwarder-6.2.3-264376-Linux-x86_64.tgz&amp;amp;wget=true'&amp;gt; /dev/null; 
  tar xvzf splunkforwarder-6.2.3-264376-Linux-x86_64.tgz -C /opt
  useradd splunk 
  chown -R splunk /opt
 chown -hR splunk /var 
 /opt/splunkforwarder/bin/splunk enable boot-start -user splunk --no-prompt --accept-license --     answer-yes 
 sudo -u splunk /opt/splunkforwarder/bin/splunk start --accept-license --answer-yes --auto- ports --no-prompt --accept-license --answer-yes 
 /opt/splunkforwarder/bin/splunk set deploy-poll \"$DEPLOY_SERVER:8089\" --accept-license --     answer-yes --auto-ports --no-prompt  -auth admin:changeme
  cd /opt/splunkforwarder/etc/system/local/ touch inputs.conf
  cd /opt/splunkforwarder/etc/system/local/ touch outputs.conf
 echo -e $OUTPUTS &amp;gt; outputs.conf
 echo -e $INPUTS &amp;gt; inputs.conf
 /opt/splunkforwarder/bin/splunk restart
 else echo 'Seems that your machine is not connected with internet, before to procede be sure     that the installation file is on your machine'; fi

 echo "---------------------------"
echo "Done"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 10 Aug 2015 08:28:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Why-is-my-installation-script-running-Splunk-as-root-instead-of/m-p/160541#M32552</guid>
      <dc:creator>Federica_92</dc:creator>
      <dc:date>2015-08-10T08:28:28Z</dc:date>
    </item>
  </channel>
</rss>

