set_common.sh

cat setup_common.sh    
#!/bin/sh

id ads
if [ $? -ne 0 ];then
    sudo /usr/sbin/groupadd -g 1685 ads
    sudo /usr/sbin/useradd -u 1685 -g ads -d /home/ads ads
fi

id admin
if [ $? -ne 0 ];then
    sudo /usr/sbin/groupadd -g 500 admin
    sudo /usr/sbin/useradd -u 500 -g admin -d /home/admin admin
fi

if [ `cat /etc/redhat-release 2>/dev/null|grep 'release 4'|wc -l` -eq 1 ];then
    #ask password when cron to run with 'sudo '
    sudo sed -i -e 's/^Defaults\s*requiretty/#Defaults    requiretty/' /etc/sudoers
    sudo sed -i 's/SELINUX=.*$/SELINUX=disabled/' /etc/selinux/config
    sudo setenforce 0
fi

sudo sed -i -e 's/^Protocol 2.*$/Protocol 2,1/' /etc/ssh/sshd_config
sudo service sshd restart

scp -p 【hostname】:/home/zgq/cron1.ads.tgz ./ && sudo tar zxvf ./cron1.ads.tgz -C /

cat /etc/security/limits.conf|grep -v '^#'|grep core|grep unlimited || echo "
* - core unlimited
"|sudo tee -a /etc/security/limits.conf

cat /etc/security/limits.conf|grep -v '^#'|grep nofile || echo "
root    soft    nofile  65535
root    hard    nofile  65535
admin   soft    nofile  65535
admin   hard    nofile  65535
ads soft    nofile  65535
ads hard    nofile  65535
*   soft    nofile  16384
*   hard    nofile  357782
"|sudo tee -a /etc/security/limits.conf

echo '10 0 * * * root find /var/tmp -name "*-[0-9]*-[0-9]*.core" -mtime 7 -exec rm -f {} \; >/dev/null 2>&1 '|sudo tee /etc/cron.d/delete_corefile
if [ grep '^kernel.core_pattern' /etc/sysctl.conf >/dev/null 2>&1 ];then
    sudo sed -i -e 's;^kernel.core_pattern\s*=.*;kernel.core_pattern = /var/tmp/%e-%p-%t.core;' /etc/sysctl.conf
else
    echo "kernel.core_pattern = /var/tmp/%e-%p-%t.core" |sudo tee -a /etc/sysctl.conf
fi

hostname|egrep -e '^p[0-9]+.*.mm.cnz.alimama.com' && echo "#for webserver
net.ipv4.tcp_fin_timeout = 10
net.ipv4.ip_local_port_range = 1024 61000
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_max_syn_backlog = 16384
net.core.somaxconn = 16384
net.core.netdev_max_backlog = 8192
#net.ipv4.tcp_congestion_control = cubic
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
"|sudo tee -a /etc/sysctl.conf

if [ `echo $HOSTNAME|egrep 'p[0-9]'|wc -l ` -ge 1 ];then
    #web server
echo "#to disable lv vip loop.ip apr:
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
"|sudo tee -a /etc/sysctl.conf
fi

sudo sysctl -p
sudo service crond reload

#scp -p [hostname]~zgq/clone_config/p.ads.ssh.tgz ./
#sudo tar zxvf ~/p.ads.ssh.tgz -C /home/ads

#ntp sometime don't work
#sudo service ntpd stop
#sudo /usr/sbin/ntpdate ntp2.ops.cnz.alimama.com
#sudo service ntpd start

wget http://yum.corp.taobao.com/yum/yum-config && chmod +x yum-config && sudo ./yum-config
#scp -p [hostname]:~zgq/tools/walle ./

你可能感兴趣的:(service,cron,login)