我不是一个服务器大师(不幸),但有一个体面的知识的Linux和BSD。 我试图符号链接HLDS(游戏服务器)的多个实例,但需要排除某些文件夹和configuration文件,以实现这一点。 我需要这样做,因为HLDS会自动加载多个mod,并且禁用mod的exception不适用于所有这些mod。
所以基本上我想要:
/ home / user / hlds-install(基本安装)
/家庭/用户/服务器1
/家庭/用户/服务器2
等等…
然后可以手动将任何configuration/修改排除在服务器目录中,以便每个服务器都可以单独configuration。
任何人都可以告诉我如何做到这一点,也许某种forms的bash脚本,以便我可以改变目标来运行它,每次我想创build一个新的。 我有相当多的人做这样做手动整个事情绝对不是一个选项,即时通讯工作更聪明,而不是更难!
谢谢 :)
我假设你的意思是“符号链接文件夹内的所有东西”…
从概念上讲,你需要像这样的东西:
for each file in base folder not in exclude list create symlink in target folder pointing back to base folder done
bash逻辑来达到这个目标就像
#! /bin/bash exclude=( "foo.conf" "bar.conf" ) for file in *; do for (( index = 0; index < ${#exclude[@]}; index++ )); do if [[ ${file} != ${exclude[${index}]} ]]; then ln -s ${file} ${target}/${file} fi done done
假设你还不知道, 高级Bash脚本指南应该给你足够的工作,你想要什么(可能find
),以及如何将其转换为函数(也许是一个recursion的)。
你可以(ab)使用xstow 。 该程序旨在填充符号链接的森林,这是接近你想要的。 它没有排除某些文件的选项,但是可以破解它。 对于每个服务器:
cd ... / targets / server1 碰碰 for x in files to exclude ; 做mkdir -p“$(dirname”$ x“)”; 不包括“$ x”; DONE xstow -d ... / sources -t。 具体server1的 - - 文件 xstow -f -d ... / sources -t。 底座安装 find-samefile .exclude -exec rm {} +