Search This Blog

Monday, September 21, 2009

איך לקנפג עליה אוטומטית של לאמפ בלינוקס

1. ניצור בתור root סקריפט ב
/etc/init.d
שישרת עליה והורדה (כלומר שיקבל פרמטר של start או של stop).
(כללנו גם כמה פרמטרים אחרים למען הנוחות. )

זה הסקריפט :

#!/bin/bash
# See how we were called.
case "$1" in
    start)
        /opt/lampp/lampp start
        RETVAL=$?
        ;;
    stop)
        /opt/lampp/lampp stop
         RETVAL=$?
        ;;
    status)
        /opt/lampp/lampp status
         RETVAL=$?
        ;;
    restart)
        /opt/lampp/lampp restart
         RETVAL=$?
        ;;
    reload)
        /opt/lampp/lampp reload
         RETVAL=$?
        ;;
    *)
        echo $"Usage: $0 {start|stop|status|restart|reload}"
        RETVAL=1
        ;;
esac
exit $RETVAL

2. כשאנחנו שומרים אותו, נקרא לו lampp למען הנוחות. 

3. נשנה את ההרשאות ל755 - 
chmod 755 ./lampp

4. ניצור לינקים בספריות -
/etc/rc.d/rc5.d
  (לעלייה)
/etc/rc.d/rc0.d
  (להורדה)

למשל:
cd /etc/rc.d/rc0.d
ln -s /etc/init.d/lampp K99lampp

cd /etc/rc.d/rc5.d
ln -s /etc/init.d/lampp S99lampp

ועכשיו הזמן לבדוק שהכל אכן עובד....
(תזכורת: אם מדובר במכונה שמשרתת משתמשים אחרים, זה לא רעיון טוב לעשות reboot באמצע היום רק כדי לוודא את זה. מצד שני, אם מדובר במכונת פרודקשיון, זה לא רעיון טוב לעשות את התהליך הזה ולא לבדוק אף פעם אם הוא אכן עובד, עד לאותו יום שבו איזושהיא קריסה תסתיים בזה שהמערכת לא תהיה זמינה גם אחרי העלייה. קונפיגורציה מהסוג הזה מחייבת קביעת זמן מתאים מבחינת העולם שמסביב לבדיקה ולניסוי. זה קצת משעמם אולי, אבל זה חלק הכרחי ממלאכתו של אדמין).

Saturday, September 19, 2009

forwarding your email from unix

this is a quick and dirty post, as I'm trying to document an issue which should always be taken care of, but as it is not an issue that requires a lot of maintenance, it is also easily forgotten. so now there will be a documentation, of sorts, for the future: 

introduction: the why
When creating a backup routine for a unix/linux machine it is important to remember to check the logs. If we used crontab, the results of any problematic run will be emailed to the cron-run-owner/root account (respectively).

Therefore, if we are talking about a server/another machine whose root email is not methodically inspected (horrible practice, but i've encountered it in too many occasions), a simple solution is to forward the email to another account (which catches two birds in one strike, also solving the importance of reviewing root's email1) 

how do we forward ? 
for any user that is not root, create at the user home directory a file called .forward, and inside type the email to which the mail address should be forward. 

in many systems this solution will also work for root. in others, the mail configuration (permissions, etc) shall prevent the .forward file in root's home directory to be read by the mail services. in that case, the solution is simple: 
1. add to /etc/aliases an alias for root, in the format of: 
root: email@emailservice.com
2. and then run newaliases for root 

further reading 




[last update:31/12/2013]