Bash 创建虚拟集群的脚本不工作

Bash script to create virtual clusters isn't working

我正在尝试创建一个脚本来在我的最小 CentOS 7 虚拟机上创建虚拟集群。

我得到了一个名为 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 ; else help; fi

据我所知,我只需要让它可执行 chmod +x cluster

然后我应该为它创建一个系统链接 ln -s cluster /bin/cluster 现在我通常应该能够在终端中输入 cluster vc 并且它应该执行脚本但它一直给我 "command cluster not found"

我做错了什么吗?或者我需要在上面使用另一个 chmod 才能 运行 这个吗?

符号 link 目标是相对于 symlink 位置解析的。在您的情况下,这意味着,如果您 运行 /bin/cluster 它会在 /bin/directory 中查找名为 cluster(目标)的文件。提供指向您的文件的相对路径或 link 指向绝对路径:ln -s /path/to/cluster /bin/cluster.

还要确保目标位置对于执行 symlink 的任何人都是可读和可执行的。