Hot answers tagged

14

Running sudo su user01 in a script does not mean the following commands are sent to the resultant shell. In fact, it likely means a new shell is spawned as user01, which never exits! Two things: You can execute a command as another user either by passing the -c 'command...' argument to su, like su user01 -c '/etc/init.d/script start'. Starting a service ...


14

You probably have a carriage return (^M) at the end of your #! line. The format of the #! line is very strict, and carriage return is not allowed there, unless your interpreter is actually called /bin/bash^M There will never be carriage returns in a file created with a proper unix editor, unless you go out of your way to add them. When editing an existing ...


9

You need IF EXIST instead of just IF for batch programming. e.g. IF NOT EXIST "C:\Program Files\Microsoft Security Client" ( :: Install product )


6

You might want to look at achieving this via two separate methods, i.e. one to set FF as default, the other to launch it at login. That said, in case you want to know, default browser setting is stored in the registry under HKEY_CURRENT_USER\Software\Classes\http\shell\open\command Use your preferred method for setting registry entries (with your ...


6

Put the command in /etc/rc.local.


6

In PowerShell: Import-Module ActiveDirectory Get-ADUser MDMarra -Properties scriptpath | Select scriptpath In cmd: dsquery user -samID MDMarra | dsget user -loscr This will return the path of the logon script set in the Profile tab of ADUC. or Just install ADUC on your workstation and look at the Profile tab for the user in question. You don't need ...


6

Your understanding is correct. When your company gets to the size that you need to bring in a dedicated Windows sysadmin they're going to be unhappy that you did this. I can't imagine that your logic is so complex that it couldn't be solved by the built-in functionality in Group Policy. Security Group filtering, WMI filtering (which is ...


5

You could put something in /etc/crontab and run it @reboot @reboot username /etc/init.d/script start


5

Group Policy Filtering: You're doing it wrong (or at the very least you're doing it the hard way). Create a Security group for the computers that you DO want the policy to apply to. Add the appropriate computer accounts to the group. On the Scope tab of the GPO, in the Security Filtering section, remove all entities and add the Security group you created ...


4

If your service already has an init script, you can add it to the default runlevel by running: # rc-update add apache2 default If not, depends on which services system you're using, add your scripts to the /etc/conf.d/local.start or /etc/local.d/baselayout1.start, something like this: cd /path/to/your/app && thin start


4

I do what you're looking at doing all the time. When you say "I then set permissions on the GPO to deny access to that group" it's not clear what you're doing. Here's my workflow for denying a group the rights to apply a GPO: Create Global Security Group "Computers exempt from printer deletion" Open Group Policy Management, locate the GPO to delete ...


4

Sorry for not answering (my own question) sooner. So, this is how I finally settled my problem. On Startup, the Startup Script creates an at job. Since Startup Scripts run as SYSTEM, the at job will similarly run under SYSTEM privileges. The at job is configured to run 2 minutes after creation. The command in the at job is the actual workload script. ...


4

Since you're running AD, why don't you try distributing these products via MSI and GPO?


4

I suppose the shell TERMs it when it exits, which would be immediately, due to the '&'. Maybe you want to use start-stop-daemon? E.g: start-stop-daemon --start -b -x /usr/bin/Xvfb :1 I suppose if you want the help of the startx wrapper, you may want to run your shellscript instead.


4

You can use my init script. It's based on /etc/init.d/skeleton and seems to work well: #! /bin/sh ### BEGIN INIT INFO # Provides: Xvfb # Required-Start: $remote_fs $syslog # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Start Xvfb. # Description: Start the X virtual ...


4

As drive letters are ephemeral, it would be best to use UNC paths instead of drive letters. If the service is unable to handle UNC paths, consider creating a symlink to the destination like mklink c:\remotenetdir \\server\remote\netdir and use the local path (c:\remotenetdir) in the service configuration. Obviously, the service account would need to have ...


3

How can I get the script to run even if I didn't previously logoff? A Logon script, by definition, runs at Logon. If you don't log off then the script isn't going to run again. It doesn't run on a disconnect/reconnect to an already logged on session.


3

The services on a CentOS operating system are managed using chkconfig. Use chkconfig --list to review the currently managed services. You can mark a service to automatically start at a defined runlevel by issuing: # chkconfig someservice on Read the chkconfig(8) manpage for the details.


3

rc startup order is determined by rcorder, as you've already determined. This process for determining startup order is automatic, and the man page for rcorder is relatively self-explanatory, but you may will want to spend some time reviewing Practical rc.d scripting, and the rc man page before making any changes. In your particular case, you can tell ...


3

Since, you're running Ubuntu, you can wrap memcache tasks into an Upstart configuration. The "hook" to invoke a script after memcached starts would be in the post-start section of the Upstart configuration. Your config will then look something like: # memcached - in-memory cache # description "memcached" start on (local-filesystems and started ...


3

Modify /etc/init.d/boot.local to add what you want.


3

On the CentOS machine, create a file in your home directory named .bashrc and set your environmental variables in there. For example, the contents of the file can be: export VARIABLE=foo Here's some discussion of this: http://tldp.org/LDP/Bash-Beginners-Guide/html/sect_03_01.html [edit] Thanks for the clarification. You can use the SendEnv and ...


3

There is already a start-up script for running local commands in /etc/rc.d/local. You can add a line there which executes your program. If your script requires startup/shutdown/restart capabilities, you can add your own script to /etc/init.d. Start by looking at the existing scripts to figure out how to specify dependencies. Once you've created your script, ...


3

Assuming startup script is a batch file: The CALL statement was introduced in MS-DOS 3.3 It is used to call other batch files within a batch file, without aborting the execution of the calling batch file, and using the same environment for both batch files. http://www.robvanderwoude.com/call.php


3

You need to transition this to a logon script, or use the built in application deployment options. The problem you are running into is that during the start up script phase the effective user is not the logged in user - since these scripts are run even before the user logon prompt is presented - but it is running as the SYSTEM user. Personally I would ...


3

You should grab a copy of psexec and run psexec -s path\to\script.bat. That will run it as System. That's a more accurate manual test than running it as the logged in user, since startup scripts run as SYSTEM.


2

I'm making an assumption that you are also using a newer model of Active Directory but you could easily create a GPO to do software deployment and then use item-level targeting on it to ensure the software is only deployed to users of a specific group or however you want to deploy them.


2

To add apache2 at boot time: $ rc-update add apache2 default To start the script manually $ /etc/init.d/apache2 start Also a really useful command is rc-update -v show which will show all the available init scripts and list at which runlevels they will execute.


2

Maybe you should try and use chkconfig package apt-get install chkconfig once done, chkconfig mysql on chkconfig apache2 on if for some reason doesn't work you can add echo "/etc/init.d/mysql start" >> /etc/rc.local echo "/etc/init.d/apache2 start" >> /etc/rc.local restart and test



Only top voted, non community-wiki answers of a minimum length are eligible