【问题标题】:How to change symlink to old version if latest version is not working如果最新版本不起作用,如何将符号链接更改为旧版本
【发布时间】:2015-12-07 11:07:49
【问题描述】:

我有一个 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

问题:

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

shell 我在 conf 文件中检查了最新版本是否正常工作。

谁能帮我解决这个问题。

操作系统: Ubuntu

【问题讨论】:

    标签: qt ubuntu configuration configuration-files upstart


    【解决方案1】:

    您可以在 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
      }
    )
    

    【讨论】:

      猜你喜欢
      • 2021-12-01
      • 2017-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-04
      相关资源
      最近更新 更多