[英]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.