Info Zone

Hiking On The Web For Technology

Init Script For Alfresco

December 10th, 2007 by Henry Addo

One of the challenges posted on the Faneshi mailing list was for someone to write a startup script for Alfresco. I took the challenge to write it, not because its so trivial to write such a script but a way to kill time and shut down all IM activities. It took me a few minutes to write a clean code. I posted my code back to the list for comments and testing and it turns out to work perfectly. Few comments were posted about setting java home with the init script but Edem, a member of the group commented that is not necessary and won’t make the script generic but better that is done with /etc/profile file. So my code after all didn’t suffer from any modification. Here is the code ( for debain based distros ).


1 #!/bin/bash

2

3 # $Id: $

4

5 # /etc/init.d/alfresco: start alfresco and stop alfresco

6 set -e

7

8 #include init functions so we can use functions like

9 # log_daemon_msg to output messages instead of echo

10 . /lib/lsb/init-functions

11

12 # start method

13 start_alfresco() {

14 log_daemon_msg Starting alfresco…

15

16 /opt/alfresco/alfresco.sh start

17 return

18 }

19

20 #stop method

21 stop_alfresco() {

22 log_daemon_msg Stopping alfresco…

23

24 /opt/alfresco/alfresco.sh stop

25 return

26 }

27

28 # now let run the functions

29 case $1 in

30 start)

31 start_alfresco

32 ;;

33 stop)

34 stop_alfresco

35 ;;

36 *)

37 log_daemon_msg Usage:{start|stop}

38 exit 1

39 ;;

40 esac

41 exit 0

Below is for RedHat based distros as posted by Edem.

1 #!/bin/bash

2

3 # chkconfig: 35 99 01

4 #include init functions so we can use functions like

5 . /etc/rc.d/init.d/functions

6

7 # start method

8 start_alfresco() {

9 log_daemon_msg Starting alfresco…

10 /opt/alfresco/alfresco.sh start

11 return

12 }

13

14 #stop method

15 stop_alfresco() {

16 log_daemon_msg Stopping alfresco…

17 /opt/alfresco/alfresco.sh stop

18 return

19 }

20 # now let run the functions

21 case $1 in

22 start)

23 start_alfresco

24 ;;

25 stop)

26 stop_alfresco

27 ;;

28 *)

29 log_daemon_msg Usage:{start|stop}

30 exit 1

31 ;;

32 esac

33 exit 0

Posted in , , |

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.