2015-12-07 9 views
0

У меня есть файл conf 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-> ПоследняяВерсия

Проблема:

Как я могу указать на старый файл версии продукта, если последняя версия не работает.

оболочка у меня есть какие-либо проверки в конфиде, погода последней версии работает или нет.

Может кто-нибудь помочь мне в этом.

ОС: Ubuntu

ответ

0

Вы можете добавить проверку в конф файле:

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 
    } 
) 
+0

Спасибо за ответ. Это решило мою проблему. – Jeggu