المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : سكربت شيل اعجبني !!! nginx



walid
11-02-2013, بتوقيت غرينيتش 02:09 AM
بسم الله الرحمن الرحيم

http://bash.cyberciti.biz/wp-content/uploads/2014/12/nginx.rc_.png




رمز PHP:

<code style="white-space:nowrap"> <code> #!/bin/bash
# Name : nginx.rc
# ----------------------------------------------------------------------------

# jail location - must be up, see how to setup nginx using chroot

_newroot="/nginxjail"

# RHEL nginx and other binary paths
_nginx="/usr/sbin/nginx"
_chroot="/usr/sbin/chroot"
_killall="/usr/bin/killall"

# 0 turn off or # 1 turn on
_securetmp=0
_securetmproot="/path/to/images/nginx_jail_tmp.bin"


&#91; ! -d "$_newroot" &#93; &# mount /tmp securely inside $_newroot

mounttmp(){
if &#91; $_securetmp -eq 1 &#93;
then
mount | grep -q $_securetmproot
if &#91; $? -eq 0 &#93;
then
echo "*** Secure root enabled and mounted ***"
else
echo "*** Turning on secure /tmp..."
&#91; ! -f "$_securetmproot" &#93; &mount -o loop,noexec,nosuid,rw "$_securetmproot" "$_newroot/tmp"
chmod 1777 "$_newroot/tmp"
rm -rf "$_newroot/var/tmp"
ln -s ../tmp "$_newroot/var/tmp"
fi
fi
}

start(){
echo -en "Starting nginx...\t\t\t"
$_chroot $_newroot $_nginx && echo -en "&#91; OK &#93;" || echo "&#91; Failed &#93;"
}

stop(){
echo -en "Stoping nginx...\t\t\t"
$_killall "${_nginx##*/}" && echo -en "&#91; OK &#93;" || echo "&#91; Failed &#93;"
}

reload(){
echo -en "Reloading nginx...\t\t\t"
$_chroot $_newroot $_nginx -s reload && echo -en "&#91; OK &#93;" || echo "&#91; Failed &#93;"
}

## Fancy status
status(){
echo "*** PID ***"
#pgrep -u ${_nginx##*/} ${_nginx##*/}
ps aux | grep "${_nginx##*/}" | grep -v grep
echo

echo "FD stats:"
for p in $(pidof ${_nginx##*/}); do echo "PID # $p has $(lsof -n -a -p $p|wc -l) fd opened."; done
echo

echo "Jail dir location:"
pwdx $(pgrep -u "root" "${_nginx##*/}") | grep --color "$_newroot"
echo

echo "*** ${_nginx##*/} TCP PORT ***"
netstat -tulpn | egrep --color ':80|:443'
}

## Make sure /tmp is securely mounted inside jail ##
mounttmp

## main ##
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
reload)
reload
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
;;
esac

# just send \n
echo
</code> </code>

طريقة التركيب install

رمز PHP:

<code style="white-space:nowrap"> <code> # cd /tmp
# wget http://bash.blueapplesoft.com/dl/593.sh.zip
# unzip 593.sh.zip
# mv 593.sh /etc/rc.d/nginx.jail.rc
# chmod +x /etc/rc.d/nginx.jail.rc
</code> </code>

طريقة الاستخدام

رمز PHP:

<code style="white-space:nowrap"> <code> # /etc/rc.d/nginx.jail.rc start
# /etc/rc.d/nginx.jail.rc stop
# /etc/rc.d/nginx.jail.rc restart
# /etc/rc.d/nginx.jail.rc status
</code> </code>

طيب الله اوقاتكم




https://fbcdn-sphotos-d-a.akamaihd.net/hphotos-ak-ash4/482113_236967293114455_1193518507_n.png (http://www.dzbatna.com)
©المشاركات المنشورة تعبر عن وجهة نظر صاحبها فقط، ولا تُعبّر بأي شكل من الأشكال عن وجهة نظر إدارة المنتدى (http://www.dzbatna.com)©

استعمل مربع البحث في الاسفل لمزيد من المواضيع


سريع للبحث عن مواضيع في المنتدى