zoukankan      html  css  js  c++  java
  • 一个替代手工合并文件的shell脚本

    #!/bin/sh
    CURET_DIR=$(pwd)
    src_path="$CURET_DIR/rootfs-src-tmp"
    dst_path="$CURET_DIR/rootfs-dst-tmp"
    
    help() {
        echo ""
        echo "eg: auto-build-rootfs src.ext2 dst.ext2"
    }
    
    #check src rootfs.ext2
    if [ ! -f $CURET_DIR/$1 ]; then
            echo "no file $CURET_DIR/$1"
            help
            exit
    fi
    #check dst rootfs.ext2
    if [ ! -f $CURET_DIR/$2 ]; then
            echo "no file $CURET_DIR/$2"
            help
            exit
    fi
    
    
    #check src mount path 
    if [ ! -d $src_path ]; then
        echo "no dir: $src_path, we will create it!"
        mkdir -p  $src_path
    else
        echo "exist dir: $src_path, pl check it,  exit"
        exit
    fi
    #check dst mount path
    if [ ! -d $dst_path ]; then
            echo "no dir: $dst_path, we will create it!"
            mkdir -p $dst_path
    else
            echo "exist dir: $dst_path, pl check it,  exit"
            exit
    fi
    
    # mount
    echo ""
    echo "mount $1 to  $src_path ..."
    mount $1 $src_path
    echo "mount $2 to  $dst_path ..."
    mount $2 $dst_path
    
    #modify file
    cp $src_path/etc/default/lxc $dst_path/etc/default/lxc
    cp $src_path/etc/fstab $dst_path/etc/fstab
    cp $src_path/etc/init.d/rcS $dst_path/etc/init.d/rcS
    cp $src_path/etc/profile $dst_path/etc/profile
    
    #cp file
    cp $src_path/usr/lib/liblxc.so $dst_path/usr/lib/liblxc.so
    cp $src_path/usr/lib/liblxc.so.1 $dst_path/usr/lib/liblxc.so.1
    cp $src_path/usr/lib/liblxc.so.1.6.0 $dst_path/usr/lib/liblxc.so.1.6.0
    
    cp $src_path/usr/lib32/liblxc.so $dst_path/usr/lib32/liblxc.so
    cp $src_path/usr/lib32/liblxc.so.1 $dst_path/usr/lib32/liblxc.so.1
    cp $src_path/usr/lib32/liblxc.so.1.6.0 $dst_path/usr/lib32/liblxc.so.1.6.0
    
    cp $src_path/usr/libexec/lxc/lxc-net $dst_path/usr/libexec/lxc/lxc-net
    #cp $src_path/usr/share/lxc/templates/lxc-busybox $dst_path/usr/usr/share/lxc/templates/lxc-busybox
    
    cp $src_path/etc/default/lxc-net $dst_path/etc/default/lxc-net
    cp $src_path/etc/resolv.conf $dst_path/etc/
    
    #cp dir
    cp -rf $src_path/usr/local $dst_path/usr/local
    cp -rf $src_path/var/lib/lxc/lxc-busybox $dst_path/var/lib/lxc/lxc-busybox
    
    
    #umount
    umount $src_path
    umount $dst_path
    
    rm -r $src_path
    rm -r $dst_path
  • 相关阅读:
    anaconda版本与python版本对应关系查询网址
    非官方windows二进制Python拓展包
    vscode每次打开文件,出现git弹窗,login i revparse showtoplevel,打印revparse:no such file or directory
    Python 官方文档
    转:Oracle EBS借贷关系
    中文分词的简要实现
    Thinkpad为什么是Thinkpad
    中文分词的应用——网站热点分析
    Blog工具:Zoundry blog writer and GreatNews RSS reader
    SpringBoot校验请求Json参数
  • 原文地址:https://www.cnblogs.com/mic-chen/p/13492839.html
Copyright © 2011-2022 走看看