Press "Enter" to skip to content

Month: July 2014

批量下载Linux Kernel版本,并对本地的Kernel进行比较

自己写的一个批量下载Kernel.org版本,并对本地的Kernel进行比较的脚本。记录一下吧。

自己部门6年前维护的一个kernel版本,只知道是基于kernel 2.6版本,却不知道是基于2.6.x版的。于是乎,写了这么个脚本,批量把2.6.x的所有版本全部下载回来,使用diff一一进行比对(导出到conclusion/diff-2.6.x-and-k2.txt文件中),并将所有版本的diff结果进行分析,再将分析数据导出到conclusion/all.txt中。

在conclusion/all.txt中,第一列是diff时官方的版本号,第二列是diff结果(conclusion/diff-2.6.x-and-k2.txt)的行数。重点在于第二列,这些数字中最小的那一个所对应的版本号,应该就是我部门维护的kernel的详细版本号了。

#!/bin/bash
for i in `seq 0 39`
do
    echo donwloading https://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.$i.tar.bz2
    wget https://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.$i.tar.bz2
    for a in `seq 1 57`
    do
        echo downloading https://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.$i.$a.tar.bz2
        wget https://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.$i.$a.tar.bz2
    done
done

if [ ! -d conclusion ]; then
    mkdir conclusion
fi

for file in `ls linux-2.6.*.tar.bz2`
do
    dirname=${file%.tar*}
    version=${dirname##*-}
    echo $dirname
    echo $version
    tar -jxvf $file
    diff -r $dirname k2_os-kernel-2.6.28.10 > conclusion/diff-$version-and-k2.txt
    rm -rf $dirname

    stat=`cat conclusion/diff-$version-and-k2.txt | wc -l`
    echo $version '        ' $stat >> conclusion/all.txt
done

count=`awk -F ' ' '{print $2}' conclusion/all.txt | sort -n | head -1`
version=`cat conclusion/all.txt | grep $count$ | awk -F ' ' '{print $1}' $line`
echo '' >> conclusion/all.txt
echo The shortest diff is $count, which kernel version is $version >> conclusion/all.txt
Leave a Comment

Nginx配置索引(目录浏览),美化索引页面,配置目录密码保护

本文演示了为Nginx配置索引(目录浏览),美化索引页面,配置目录密码保护的全部过程,全部完成以后的效果如http://soft.vpser.net/所示。

1,安装Nginx,并加入FancyIndex插件
FancyIndex是一个美化插件,可以引入自定义HTML内容用于美化索引页面。如果仅仅需要开启目录浏览而不需要美化,可以不引入此插件。

$ yum install gcc gcc-c++ make openssl openssl-devel

$ wget http://sourceforge.net/projects/pcre/files/pcre/8.33/pcre-8.33.tar.gz
$ tar -zxvf pcre-8.33.tar.gz
$ cd pcre-8.33
$ ./configure
$ make && make install
$ cd ../

$ groupadd www
$ useradd -s /sbin/nologin -g www www
$ git clone https://github.com/aperezdc/ngx-fancyindex.git ngx-fancyindex

$ wget http://nginx.org/download/nginx-1.6.0.tar.gz
$ tar zxvf nginx-1.6.0.tar.gz
$ cd nginx-1.6.0/
$ ./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --add-module=../ngx-fancyindex
$ make && make install
$ ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx

$ git clone https://github.com/ixbear/nginx
$ mv nginx/nginx.conf /usr/local/nginx/conf/
$ mv nginx/init.d.nginx /etc/init.d/nginx
$ chmod +x /etc/init.d/nginx
$ chkconfig --level 345 nginx on
$ /etc/init.d/nginx start
1 Comment

CentOS6配置rsync服务

rsync是linux下的文件同步服务,本文演示了在CentOS 6系统上配置rsync的过程。

1,服务端配置

网上有很多教程在配置rsync服务端的时候,都先配置了xinetd服务,事实上这是不必要的,rsync也能脱离xinetd以独立进程的方式运行,所以本文未配置xinetd。

$ yum install rsync -y

$ mkdir /etc/rsyncd
$ touch /etc/rsyncd/rsyncd.conf    #主配置文件
$ touch /etc/rsyncd/rsyncd.secrets #客户端连接时使用的用户和密码
$ touch /etc/rsyncd/rsyncd.motd    #服务端提示信息文件
$ chmod 600 /etc/rsyncd/rsyncd.secrets
$ chown root:root /etc/rsyncd/rsyncd.secrets
Leave a Comment