Visit Our UNIX and Linux User Community


Activate all Linux services script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Activate all Linux services script
# 1  
Old 07-28-2009
MySQL Activate all Linux services script

Now i'm up to making a script from which you could activate all Linux services without being an expert. It's gonna be a powerful tool, I'll look forward to make it able to change the port which the service is assigned to. But I need some help, post some script to activate services and I'll fusion them and (if able) upgrade them. I'll try to google some too and see if I can find any.

It's gonna be useful, support!.Smilie
# 2  
Old 07-29-2009
Hate to tell you this but GNU/Linux already provides a mechanism for doing this.
# 3  
Old 07-29-2009
But I need to do a script for it, I've seen some scripts for activating, disabling and restarting services like SMB and I wanna put them together in one only script. I just don't wanna look for them all, maybe you could post some and then i'll work on fusing them. It's gonna be a nice scripting practice.

Already got HTTP one for enabling, disabling and restarting.

Missing:
SMB, NFS, telnet, SSH, FTP, TFTP, Samba (Again I'm newbie so cannot assure I can successfully make it though I wanna try).
# 4  
Old 07-29-2009
No, really. It already does. And most distributions even include a fancy graphical interface for managing services too.

On my system, starting sshd is as simple as /etc/init.d/sshd start. And apache is /etc/init.d/apache2 start. and dnsmasq is /etc/init.d/dnsmasq start. want to stop them? try /etc/init.d/apache2 stop. want to restart? /etc/init.d/apache2 restart. Want to reboot a bunch of them? for S in apache2 dnsmqsq sshd ; do /etc/init.d/$S restart ; done This may not seem easy to you, but is much easier than handwriting millions of tiny custom scripts for every machine in the world.

Last edited by Corona688; 07-29-2009 at 03:06 PM..
# 5  
Old 07-29-2009
Quote:
Originally Posted by Corona688
No, really. It already does. And most distributions even include a fancy graphical interface for managing services too.

On my system, starting sshd is as simple as /etc/init.d/sshd start. And apache is /etc/init.d/apache2 start. and dnsmasq is /etc/init.d/dnsmasq start. want to stop them? try /etc/init.d/apache2 stop. want to restart? /etc/init.d/apache2 restart. Want to reboot a bunch of them? for S in apache2 dnsmqsq sshd ; do /etc/init.d/$S restart ; done This may not seem easy to you, but is much easier than handwriting millions of tiny custom scripts for every machine in the world.
lol, yeah, I kinda knew some of that, but thanks anywaysSmilie. The thing is my teacher wants a script for it, I guess I'll just gather around some more scripts, fusion them and post it since no one got nothing similar to guide me. See you on 96 hours (deadline).Smilie
# 6  
Old 07-30-2009
I have written such a script for my slackware box. You will probably have to modify it for your needs. This forum has a special section for homework questions.
Code:
#!/bin/bash

LOCATION=/etc/rc.d/

if [[ $1 != "" ]]
then
/etc/rc.d/rc.${1} $2
else
echo "USAGE: $0 <service> <action>"
echo
echo "VALID SERVICES ARE:"
echo
for SERVICE in `ls /etc/rc.d`
do
if [ ! -h ${LOCATION}${SERVICE} ]
then
        if [ ! -d ${LOCATION}${SERVICE} ]
        then
                if [[ `echo $SERVICE | egrep '\..$'` == "" ]]
                then
                        if [ -x ${LOCATION}${SERVICE} ]
                        then
                        echo "$SERVICE" | sed 's@rc.@@g'
                        fi
                fi
        fi
fi
done
fi


Last edited by ilikecows; 07-30-2009 at 02:23 AM..
# 7  
Old 07-30-2009
Quote:
Originally Posted by ilikecows
I have written such a script for my slackware box. You will probably have to modify it for your needs. This forum has a special section for homework questions.
Code:
#!/bin/bash

LOCATION=/etc/rc.d/

if [[ $1 != "" ]]
then
/etc/rc.d/rc.${1} $2
else
echo "USAGE: $0 <service> <action>"
echo
echo "VALID SERVICES ARE:"
echo
for SERVICE in `ls /etc/rc.d`
do
if [ ! -h ${LOCATION}${SERVICE} ]
then
        if [ ! -d ${LOCATION}${SERVICE} ]
        then
                if [[ `echo $SERVICE | egrep '\..$'` == "" ]]
                then
                        if [ -x ${LOCATION}${SERVICE} ]
                        then
                        echo "$SERVICE" | sed 's@rc.@@g'
                        fi
                fi
        fi
fi
done
fi

Wow man, thanks. Saved me a lot of time, now I just have to figure out how it works, thanks a lot. About the homework question forum, I totally forgot Smilieits the 2nd time it happens, I hope I don't get banned.

Previous Thread | Next Thread
Test Your Knowledge in Computers #692
Difficulty: Medium
In 1995, the Santa Cruz Operation (SCO) acquired UnixWare from Novell.
True or False?

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to Start services based on dependent services on other AIX machine

Hi, I just started working on a script. After my research, i found a command which can help me: AIM: To build a script which starts the services (Services 1) on server 1 automatically whenever its down. And it has a dependency on other service (Service 2) on Server 2. So my script has to... (4 Replies)
Discussion started by: draghun9
4 Replies

2. Red Hat

Restart of services if port no is changed in /etc/services in RHEL

I had a doubt if any services need to be restarted if port no in /etc/services in an RHEL setup is changed. For eg, the port no of 443 for SSL may need to be changed. I hope my query is clear whether any services need to be restarted if port no in /etc/services is changed. Please revert with... (10 Replies)
Discussion started by: RHCE
10 Replies

3. Red Hat

Unix services for windows & Linux\Red Hat

I am not too familiar with linux, so please keep that in mind while reading this post. We have a few linux servers joined to the domain, and linux services for windows running. I have a user that can connect to one linux server, but not another. I ran the cat /etc/passwrd and noticed the user... (0 Replies)
Discussion started by: dcatcha
0 Replies

4. Shell Programming and Scripting

Activate and deactivate function within a ksh script

Hi, I have written a function which will blink a text "Scanning...". Now in the main script when I am doing the scan in the server I want to call this function so that user will see a blinking text on the screen and at the same time script will proceed will the scan function. Once scan is... (2 Replies)
Discussion started by: suhasingale
2 Replies

5. UNIX for Dummies Questions & Answers

services in linux

hi, what is the command for checking the particular services and how can we find whether that service is up or down. Consider http service. how to check whether its up or down Edit: Question continued here. (0 Replies)
Discussion started by: satheeshkr_cse
0 Replies

6. AIX

Startup script and services

Guy's What the exact steps to mention for example this script /usr/start/start.sh to be as start up script , I want it to be automatically started when I reboot the server . (8 Replies)
Discussion started by: ITHelper
8 Replies

7. Solaris

Solaris 8 how do I enable and disable services? (equivalent of chkconfig on Linux)

I've successfully installed syslog-ng and chkconfig using the packages from the OpenCSW project, these packages install under /opt/csw. I now need to disable the default syslog daemon and enable the new service created by the OpenCSW package (/etc/init.d/cswsyslog_ng). Is there any good way to... (3 Replies)
Discussion started by: aussieos
3 Replies

8. Shell Programming and Scripting

need script for activate and deactivated databases in server

Hi all, i am using below command to find the running datases, bases this command i need a (shell/korn)script for which databases are running and which databases are not running in one file. i need out put below format. Kindly help to me. its very critical issue for me. i dont have script... (3 Replies)
Discussion started by: krishna176
3 Replies

9. UNIX for Dummies Questions & Answers

how do i activate php on linux....

i have activated mysql, and apache on my redhat 9 box, i went to mr BASH and wrote a php script, and it wouldn't execute. any help????????????????????????????????????? is there something that i need to activate??????? i have RUBY on there too,does it matter or no??? ... (2 Replies)
Discussion started by: mbabeli
2 Replies

Featured Tech Videos