In the online deployment of Vue project, it's too complicated to package locally, upload to the remote host, decompress and so on. So I wrote a shell script locally to handle it with one click. The functions that have been realized now are local packaging, compression, uploading to remote host, logging on to remote host, and switching to corresponding directory. But the next operations, such as decompressing and deleting the zip package .. It's not going to work.
At first, I wanted to execute all the commands in the local shell script, but after logging in to the remote host and successfully switching to the corresponding directory, the later operations would not be executed. The code is as follows:
npm run build
zip -r 'prestom_frontend.zip' './'
scp prestom_frontend.zip [email protected]:/home/app/presto_monitor_frontend
scp prestom_frontend.zip [email protected]:/home/app
ssh [email protected] -t 'cd /home/app/presto_monitor_frontend; bash --login'
ssh [email protected] -t 'rm -rf index.html favicon.ico static; bash --login'
ssh [email protected] -t 'unzip prestom_frontend.zip; bash --login'
ssh [email protected] -t 'rm -rf prestom_frontend.zip; bash --login'
I think of the second way, which is the deletion and other operations. I create a shell script remotely, and then I execute it remotely, which is OK. But how to execute the remote script in the local script? If you can, you don't have to log in to remote operation, ask the great God for advice