#!/bin/bash


Host="114.132.124.145"
Username="ubuntu"
Password="@qq20160101"

FILE="dist.tar.gz"
RemotePath="/var/www/html/"
#RemoteFile="$RemotePath/$FILE"

npm run build
tar -czvf $FILE dist/

# 传输文件到远程主机
pscp -batch -pw "$Password" -p $FILE "$Username@$Host:$RemotePath"

if [ $? -eq 0 ]; then
    echo "上传文件成功"
else
    echo "上传文件失败"
    exit 1
fi
rm -rf $FILE
rm -rf dist/

# 远程执行脚本
plink -ssh -batch -pw "$Password" "$Username@$Host" "echo '$Password' | sudo sh admin_update.sh"

if [ $? -eq 0 ]; then
    echo "远程脚本执行成功"
else
    echo "远程脚本执行失败"
    exit 1
fi



