linux deploy script

This commit is contained in:
2023-07-31 21:40:39 +03:00
parent c5d9ae7b93
commit 33aa0ef807
6 changed files with 21 additions and 82 deletions
+2
View File
@@ -380,3 +380,5 @@ package-lock.json
/.template.config/template.json /.template.config/template.json
/MyOffice.Shared/appsettings.shared.Development.json /MyOffice.Shared/appsettings.shared.Development.json
/MyOffice.Shared/appsettings.shared.Production.json /MyOffice.Shared/appsettings.shared.Production.json
/linux_deploy_mybank.bat
/linux_deploy_office.bat
-64
View File
@@ -1,64 +0,0 @@
$params = @{
"publish_folder" = "_Published"
};
$params_file="params.txt"
$linux_run1 = "#!/bin/sh"
$linux_run2 = "cd /var/www/MyOffice/"
$linux_run3 = "dotnet MyOffice.Web.dll"
$linux_run4 = "exit"
function Write2 {
Param ([string[]] $str1)
Write-Output "-----------------------------------------------"
Write-Output $str1
Write-Output "-----------------------------------------------"
}
function ReadParams {
Param ([string] $str1)
Get-Content -Path $str1| ForEach-Object {
$x = $_.split('=');
$params[$x[0]] = $x[1];
}
}
$params_file = if ($args[0] -eq $null) { "params.txt" } else { $args[0] }
$copy = $args | where { $_ -eq "copy" }
$run = $args | where { $_ -eq "run" }
$file = $args | where { ($_ -ne "copy" -and $_ -ne "run") }
if ($file) {
$params_file = $file
}
ReadParams($params_file)
if ((!$copy) -and (!$run)) {
$copy = "copy"
$run = "run"
}
$linux_host = $params["linux_user"] + "@" + $params["linux_host"]
$from = $params["publish_folder"] + "\*"
$to = $linux_host + ":" + $params["linux_folder"]
if ($copy -eq "copy") {
Write2 "Copy files"
scp -r $from $to
}
if ($run -eq "run") {
Write2 "Run"
# create run script
$run_file = $params["linux_folder"] + "/run.sh"""
$cmd = """printf '#/bin/sh\ncd " + $params["linux_folder"] + "\ndotnet MyOffice.Web.dll\nexit' > " + $run_file
ssh $linux_host $cmd
# run and wait
ssh $linux_host bash $run_file
}
+19
View File
@@ -0,0 +1,19 @@
host=$1
servicename=$2
path=$3
clear
echo "-= SERVICE STOP =-"
ssh root@$host ''systemctl is-active $servicename''
ssh root@$host ''systemctl stop $servicename''
ssh root@$host ''systemctl is-active $servicename''
echo "-= COPY FILES =-"
rsync -r --info=progress2 --exclude appsettings*.json _Published/ root@$host:$path
rsync -r --ignore-existing --info=progress2 _Published/appsettings*.json root@$1:$path
echo "-= SERVICE START =-"
ssh root@$host ''systemctl start $servicename''
echo "-= SERVICE STATUS =-"
ssh root@$host ''systemctl status $servicename''
-10
View File
@@ -1,10 +0,0 @@
{
"dependencies": {
"@ngx-loading-bar/router": "^6.0.2",
"angular-feather": "^6.5.0",
"gulp": "^4.0.2",
"ng-apexcharts": "^1.7.4",
"ngx-mask": "^14.2.4",
"ngx-scrollbar": "^11.0.0"
}
}
-4
View File
@@ -1,4 +0,0 @@
publish_folder=_Published
linux_user=root
linux_host=192.168.1.215
linux_folder=/var/www/MyOffice
-4
View File
@@ -1,4 +0,0 @@
publish_folder=_Published
linux_user=root
linux_host=192.168.1.215
linux_folder=/var/www/myoffice_public