2017-06-28 84 views
0

我正嘗試創建一個腳本來在我的虛擬機上創建虛擬羣集,該羣集是CentOS 7最小的。用於創建虛擬羣集的Bash腳本不起作用

我有一個劇本叫cluster

#!/bin/bash 

function vc 
{ 
    echo 
    echo -n "Enter project name: " 
    read platform_name 

    echo 
    echo -n "web extension: " 
    read web_extension 

    echo 
    echo -e "The following website will be created" 
    echo -e "\e[32m Platform:\e[0m\t${platform_name}" 
    echo -e "\e[32m Extension:\e[0m\t${web_extension}" 
    echo -e "\e[32m Full URL:\e[0m\t http://www.${platform_name}.${web_extension}" 

    echo 
    echo -e "Do you wish to proceed? [Y/n]" 
    read -p "Are you sure? " -n 1 -r 
    echo # (optional) move to a new line 
    if [[ $REPLY =~ ^[Yy]$ ]] 
    then 
     echo 
     echo -e "\e[32m Creating platform \e[0m\t" 
    else 
     echo 
     echo -e "\e[32m Not creating platform \e[0m\t" 

    fi 
} 

if [ -n "$(type -t $FUNCTION_NAME)" ] && [ "$(type -t $FUNCTION_NAME)" = 
function ]; 
then $FUNCTION_NAME $2; else help; fi 

然後,據我瞭解我只是要使其可執行 chmod +x cluster

並在此之後我應該做一個SYSLINK它ln -s cluster /bin/cluster 現在我通常應該能夠在終端中輸入cluster vc,並且它應該執行腳本,但它一直給我「未找到命令集羣」

我在做什麼明顯錯誤?或者我需要使用另一個chmod,所以我可以運行它?

回答

1

符號鏈接目標是相對於符號鏈接位置解析的。在你的情況下,這意味着,如果你運行/bin/cluster它會在/bin/directory中尋找一個名爲cluster(目標)的文件。請提供指向文件的相對路徑或鏈接到絕對路徑:ln -s /path/to/cluster /bin/cluster

還要確保目標位置可以被任何執行符號鏈接的人讀取和執行。

+0

感謝看來我需要改變的一切是確保創建符合絕對路徑的符號鏈接 – killstreet