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 *
    

      

  • 相关阅读:
    系统维护-安全-测试等方面的开源项目
    linux命令学习
    Rancher + k8s + docker 部署资料
    个人java框架 技术分析
    java十年,需要学会的Java开发体系
    IdentityServer4 经典文章
    .net core 资料网站 和 开源项目
    Java 学习资料网站集合
    spring cloud资料汇总
    秦九韶公式 【多项式】
  • 原文地址:https://www.cnblogs.com/yaohuimo/p/15459421.html
Copyright © 2011-2022 走看看