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 *
    

      

  • 相关阅读:
    [POI2014]KUR-Couriers
    [题解向] Luogu4092 [HEOI2016/TJOI2016]树
    [探究] OI中各种初级数论算法相关
    [SCOI2005]骑士精神
    [intoj#7]最短距离
    数列分块入门
    动态规划问题基础
    Luogu P1967 货车运输
    Luogu P3379 【模板】最近公共祖先(LCA)
    Luogu P3378 【模板】堆
  • 原文地址:https://www.cnblogs.com/yaohuimo/p/15459421.html
Copyright © 2011-2022 走看看