一段shell代码可用于git部署代码到服务器的操作

发布时间 2024-01-12 11:19:22作者: tochenwei

整个执行的思路:

1 先放弃服务器本地的修改,把代码从git管理服务器检出,最新的代码。

2 复制配置测试或生产环境配置文件到工程里面。

3 文件夹的权限重新覆盖。

比如把下面这段bash 脚本命名为test_shop.sh,赋予它可执行的权限。chmod a+x test_shop.sh

#!/bin/bash
if (whiptail --title "SHOP_UNI测试版升级" --yesno "确定升级SHOP_UNI测试版吗?" 10 60) then

cd /www/wwwroot/shop_test/tsshop_front_api
git reset --hard
git pull https://账号:密码@codeup.aliyun.com/261a479aecb3221reuisx/shop/shop_front_api.git 


cd /www/wwwroot/shop_test/tsshop_admin_mg
git reset --hard
git pull https://账号:密码@codeup.aliyun.com/261a479aecb556793b040c5we22/shop/shop_admin_mg.git 

/bib/cp -f /www/wwwroot/shop_test/conf/tsshop_front_api_conf/db.php /www/wwwroot/shop_test/tsshop_front_api/ThinkPHP/Conf/db.php 

/bin/cp -f /www/wwwroot/shop_test/conf/tsshop_front_api_conf/setting.php /www/wwwroot/shop_test/tsshop_front_api/ThinkPHP/Conf/setting.php

/bin/cp -f /www/wwwroot/shop_test/conf/tsshop_admin_mg_conf/db.php /www/wwwroot/shop_test/tsshop_admin_mg/ThinkPHP/Conf/db.php

chmod -R +777 /www/wwwroot/shop_test/tsshop_front_api/Runtime

chmod -R +777 /www/wwwroot/shop_test/tsshop_admin_mg/Runtime

echo "shop测试版升级完成........."

else
    echo "shop测试版取消升级........."
fi