繁体   English   中英

如果最新版本不起作用,如何将符号链接更改为旧版本

[英]How to change symlink to old version if latest version is not working

我有一个conf文件产品,它将在启动时启动产品应用程序。

应用程序文件夹结构:

home/
    jamnes/
          product/
                 installation/
                             product1.0
                             product2.0
                 symlinktoproduct/
                                run.sh

product.conf文件:

# Product start file
#
# Starts the Product App and respawns when it quits

description     " Product Application"

start on desktop-session-start
stop on runlevel [!2345]

respawn
exec /home/james/product/symlinktoproduct/run.sh

如果用户升级应用程序,我们将在安装文件夹中放置新版本并更改symlinktoproduct-> latestversion

问题:

如果最新版本不起作用,我如何指向旧版本产品文件。

外壳我在conf文件中有任何检查,天气最新版本是否有效。

有人可以帮我这个忙吗?

操作系统:Ubuntu

您可以在conf文件中添加一个签入:

exec ( basedir="/home/jamnes/product"
  current_product="${basedir}/symlinktoproduct"

  function run_product {
    echo "Running product `ls -l ${current_product}`"
    ${current_product}/run.sh
    return $?
  }

  # run the latest product
  run_product || {

      # if run.sh returns non-zero exit code, then run previous product
      echo "ERROR: running product `ls -l ${current_product}`"

      # get name of previous product by listing previous entry from installation directory.
      # Assume alphabetical sort order.
      prev_version=`ls -1 ${basedir}/installation | tail -2 | head -1`
      echo "Rollback too previous version [$prev_version]";

      # remove previous link
      rm -f ${current_product}

      # relink current product to the previous version
      ln -sf ${basedir}/installation/${prev_version} ${current_product}

      # run product again. Now previous version is executed.
      run_product
  }
)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM