2017-06-28 50 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