zoukankan      html  css  js  c++  java
  • Linux环境部署web应用按类型修改文件权限

    #!/bin/bash
    # Define a function
    list_dir(){
    # Traversal parameter $1
    for file in $1/*
    do
        # If it is a directory then treat it ,after it's treated traverse it
        if [ -d $file ] ; 
        then 
            echo "$file is directory"
            chmod 750 $file
            echo "Directory $file changed to 750 "
            list_dir $file
        elif [ -f $file ] ; 
        then 
            suffix=`echo -n $file|awk -F. '{print $NF}'` #获取$file文件的后缀
        #下面case语句对文件权限进行修改 
            case $suffix in
                "zip") chmod 750 $file 
                     echo "file $file changed to 750"
                ;;
                "sh") chmod 750 $file 
                     echo "file $file changed to 750"
                ;;
                "jar") chmod 750 $file
                     echo "file $file changed to 750"
                ;;
                "bat") chmod 750 $file
                     echo "file $file changed to 750"
                ;;
                "rpm") chmod 750 $file
                     echo "file $file changed to 750"
                ;;
                "so") chmod 750 $file
                     echo "file $file changed to 750"
                ;;
                "tar") chmod 750 $file
                     echo "file $file changed to 750"
                ;;
                *)chmod 640 $file
                     echo "Regular file $file changed to 640"
                ;;
            esac
               list_dir $file
           fi
    done
    }
    
    # If there is parameter to traverse the specified directory, 
    # otherwise the current directory traversal
    if [ $# -gt 0 ]
    
    then
        list_dir "$1"
    else
        list_dir "."
    fi
    
    
    #edit jre-java permission to 750
    project_path=$(cd $(dirname $0); pwd)
    
    echo "jre-java changed permission to 750"
    find $project_path/jre/bin/ -name "java"|xargs chmod 750 *
    

      

  • 相关阅读:
    linq中的AsEnumerable()方法
    c# 一个匿名对象中包含多个子对象的处理方式
    jenkins的安装与启动
    牛客网-2018年湘潭大学程序设计竞赛-F
    poj-1149(最大流)
    hdu-2255(带权二分图)
    bzoj-1191(二分图最大匹配)
    codevs2822
    hdu 5652(并查集)
    hdu—3861(tarjan+二分图)
  • 原文地址:https://www.cnblogs.com/yaohuimo/p/15459421.html
Copyright © 2011-2022 走看看