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!.:b:

Hate to tell you this but GNU/Linux already provides a mechanism for doing this.

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).

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 anyways:). 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).:smiley:

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.

#!/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 :confused:its the 2nd time it happens, I hope I don't get banned.

There's no way I can get this work man. I've tried everything to fix the following:

Line 22: unexpected EOF while looking for matching ��'
Line 29: syntax error: unexpected end of file

I'm on Slackware and I re-wrote it without spaces between lines. Any suggestions?

You have broken it in your reformating attempt, I suggest recopying it and study the how's and why's of it BEFORE modifying it.

Without seeing your current code it is tough to point out the errors of your ways.

I am in NO WAY a guru at scripts, even less (Zero) about bash, however this worked as expected the first time.

-Enjoy
fh : )_~