Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash rpm-U删除符号链接,除非我使用--force_Bash_Rpm_Rpm Spec - Fatal编程技术网

Bash rpm-U删除符号链接,除非我使用--force

Bash rpm-U删除符号链接,除非我使用--force,bash,rpm,rpm-spec,Bash,Rpm,Rpm Spec,我尝试在我的规范文件中使用以下代码,我将我的应用程序作为一个独立的tomcat实例安装 # Symlink $CATALINA_BASE/logs to /var/log/$SERVICE_NAME. # If it's already there, we'll get rid of it and make a new symlink. if [ -h "$RPM_INSTALL_PREFIX/logs" ]; then # It's a symlink, so just remove

我尝试在我的规范文件中使用以下代码,我将我的应用程序作为一个独立的tomcat实例安装

# Symlink $CATALINA_BASE/logs to /var/log/$SERVICE_NAME.
# If it's already there, we'll get rid of it and make a new symlink.
if [ -h "$RPM_INSTALL_PREFIX/logs" ]; then
    # It's a symlink, so just remove it.
    rm -f $RPM_INSTALL_PREFIX/logs
fi
# If it's still there, and it's a directory, see if we can rmdir it.
if [ -d "$RPM_INSTALL_PREFIX/logs" ]; then
    rmdir $RPM_INSTALL_PREFIX/logs >/dev/null 2>&1 || :
fi
if [ -e "$RPM_INSTALL_PREFIX/logs" ]; then
    # It's probably either a file or a dir, so we'll move it.
    mv $RPM_INSTALL_PREFIX/logs $RPM_INSTALL_PREFIX/logs.rpmsave || :
fi
ln -s /var/log/$SERVICE_NAME $RPM_INSTALL_PREFIX/logs || :
当此代码与
-i
一起运行时,它将创建并保留符号链接

当我使用
-U
运行新版本的rpm时,它将执行此代码并正确创建符号链接,但当rpm命令退出时,符号链接将被删除

如果我再次运行
-U--force
,符号链接将保持不变


我如何让
-U
不必使用
--force

你想做什么?您是保留还是删除符号链接

如果要删除它,请尝试以下操作:

rm -f -i $RPM_INSTALL_PREFIX/logs # File
rmdir -f $RPM_INSTALL_PREFIX/logs >/dev/null 2>&1 || : # Directory

通过在中添加一个名为logs的文件作为RPM更新文件列表的一部分来解决此问题,它停止自动删除符号链接,因为它现在认为符号链接一直在那里。

我添加了
bash
标记,以便语法突出显示代码段