`
wbj0110
  • 浏览: 1551558 次
  • 性别: Icon_minigender_1
  • 来自: 上海
文章分类
社区版块
存档分类
最新评论

Shell scripts

阅读更多
显示代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
#! /bin/bash
 
shopt -s -o nounset
 
declare -i p=0
SRC=${1:?'Please input src files name'}
DEST=${2:?'Plesae input dest files name'}
 
Total=$(stat -c %s $SRC)
touch $DEST
 
(cp -f $SRC $DEST; sync) &
 
{
while ((p < 100))
do
    Size=$(stat -c %s $DEST)
    p=Size*100/Total
    echo $p
    sleep 1
done
} | dialog --guage "复制进度" 10 50 0
显示代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
host="192.168.99.99 21"
id="user"
pw='mima'
basedir="/var/lib/db"
filename="mybackup.`date +%Y%m%d%H%M`.gz"
cd $basedir
/usr/local/mysql/bin/mysqldump --opt -hlocalhost -uroot -ppswd data | gzip -f>/"$basedir"/"$filename"
ftp -n $host>/dev/null 2>/dev/null < <EOF
user $id    $pw
binary
put $filename
bye
EOF
cd $basedir
rm -rf $filename
 
#!/bin/bash
myday=`date +%F`
mytime=`date +%T --date="-1 hour"`
##PURGE BINARY LOGS BEFORE '2000-02-02 22:22:22';
#echo $myday $mytime
mysql -uroot -p123456 << EOF
 
PURGE BINARY LOGS BEFORE '${myday} ${mytime}';
 
#EOF
 
 
#!/bin/bash
#Disable sshd dns
sed -i 's/#UseDNS.*/UseDNS no/g' /etc/ssh/sshd_config
sed -i 's/^GSSAPIAuthentication.*/GSSAPIAuthentication no/g' /etc/ssh/sshd_config
sed -i 's/^#GSSAPIAuthentication.*/GSSAPIAuthentication no/' /etc/ssh/sshd_config
 
#Sudo log
groupadd admin
echo "%admin ALL=(ALL)  NOPASSWD: ALL" >> /etc/sudoers
echo "Defaults        logfile = \"/var/log/sudo\""  >> /etc/sudoers
echo "local2.debug  /var/log/sudo" >> /etc/syslog.conf
  
#Turn off snmpd log
echo "OPTIONS=\"-LS3d -Lf /dev/null -p /var/run/snmpd.pid\"" >> /etc/sysconfig/snmpd.options
  
#Record sftp log
sed -i '/Subsystem/d' /etc/ssh/sshd_config
echo "Subsystem       sftp    /usr/libexec/openssh/sftp-server -l INFO -f AUTH" >> /etc/ssh/sshd_config
echo "auth,authpriv.*                                          /var/log/sftp" >> /etc/syslog.conf
显示代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
yum install -y vsftpd
yum install -y db4*
rm -rf /etc/vsftpd/vsftpd.conf
cat < < 'EOF' >> /etc/vsftpd/vsftpd.conf
 
listen_port=21
anonymous_enable=NO
local_enable=YES
write_enable=NO
anon_upload_enable=NO
anon_mkdir_write_enable=NO
anon_other_write_enable=NO
chroot_local_user=YES
guest_enable=YES
guest_username=nobody
user_config_dir=/etc/vsftpd/nobody/
ftpd_banner=welcome vsftp!
pam_service_name=vsftpd.vu
#tcp_wrappers=YES
vsftpd_log_file=/var/log/vsftpd.log
listen=YES
dual_log_enable=YES
xferlog_enable=YES
EOF
 
 
cat < < 'EOF' >> /etc/pam.d/vsftpd.vu
auth required /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
account required /lib64/security/pam_userdb.so db=/etc/vsftpd/vsftpd_login
EOF
 
mkdir  /etc/vsftpd/nobody
 
cat < < 'EOF' >> /etc/vsftpd/nobody/ftpadmin
anon_world_readable_only=NO
write_enable=YES
anon_mkdir_write_enable=YES
anon_upload_enable=YES
anon_other_write_enable=YES
anon_umask=022
file_open_mode=0777
local_root=/tmp
EOF
 
cat < < 'EOF' >> /etc/vsftpd/nobody/upload
anon_world_readable_only=NO
write_enable=YES
anon_mkdir_write_enable=YES
anon_upload_enable=YES
local_root=/tmp/up
EOF
 
cat < < 'EOF' >> /etc/vsftpd/nobody/download
anon_world_readable_only=NO
local_root=/tmp/down
EOF
 
echo "ftpadmin"  > /etc/vsftpd/logins.txt
echo "ftpadmin" >> /etc/vsftpd/logins.txt
echo "upload" >> /etc/vsftpd/logins.txt
echo "upload" >> /etc/vsftpd/logins.txt
echo "download" >> /etc/vsftpd/logins.txt
echo "download" >> /etc/vsftpd/logins.txt
 
echo "db_load -T -t hash -f /etc/vsftpd/logins.txt /etc/vsftpd/vsftpd_login.db" >/etc/vsftpd/cmd
 
chmod u+x /etc/vsftpd/cmd
 
sh /etc/vsftpd/cmd
 
chkconfig  --level 3 vsftpd on
service vsftpd start
显示代码
1
2
3
4
5
if [ "`whoami`" != "root" ] ;then
  
        print "This must be run as root."
        exit -1
fi
显示代码
1
2
3
4
5
if [ "`uname -m`" == "x86_64" ] ; then
  
        wget -c http://xxoo.tv/xxoo2-2-2.x86_64.tar.gz
  
fi
显示代码
01
02
03
04
05
06
07
08
09
10
11
if [ ! -d /usr/local/jpeg ]
     then
        tar zxvf jpegsrc.v7.tar.gz
        cd jpeg-7
        ./configure --prefix=/usr/local/jpeg
        make
        make install
        cd ..
        rm -rf jpeg-7
        echo "gpeg install is ok!"
  fi
显示代码
1
2
3
if [ -e "./soft.tar.gz" ] && [ ! -d "./soft" ]; then
    tar -zxvf soft.tar.gz
fi
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics