Skip to content

Commit c0f802a

Browse files
Hope-IT-WorksCopilot
andcommitted
Fixed service configs
Co-authored-by: Copilot <copilot@github.com>
1 parent 13adeed commit c0f802a

1 file changed

Lines changed: 38 additions & 6 deletions

File tree

src/Invoke-WCMPSetup.ps1

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ if($WCMP.IsUpdate){
586586
<name>WCMP Caddy</name>
587587
<description>This service runs the WCMP Caddy server.</description>
588588
<workingdirectory>$($WCMP.Config.Path)\caddy</workingdirectory>
589-
<executable>caddy</executable>
589+
<executable>$($WCMP.Config.Path)\caddy\caddy.exe</executable>
590590
<arguments>run --watch</arguments>
591591
<delayedAutoStart>true</delayedAutoStart>
592592
</service>
@@ -595,6 +595,10 @@ if($WCMP.IsUpdate){
595595
$WCMP.Fatal('Caddy service config could not be written.')
596596
}
597597
Copy-Item -Path $WinSW_DestinationFilePath -Destination $WinSW_Service_CaddyExePath -Force
598+
if(Get-Service -Name 'WCMP_Caddy' -ErrorAction SilentlyContinue){
599+
Stop-Service -Name 'WCMP_Caddy' -Force -ErrorAction SilentlyContinue
600+
& $WinSW_Service_CaddyExePath uninstall
601+
}
598602
& $WinSW_Service_CaddyExePath install
599603
if($LASTEXITCODE -ne 0){ $WCMP.Fatal('Caddy service could not be installed.') }
600604
$WCMP.Info('Caddy service registered.')
@@ -607,7 +611,7 @@ if($WCMP.IsUpdate){
607611
<name>WCMP PHP</name>
608612
<description>This service runs the WCMP PHP server.</description>
609613
<workingdirectory>$($WCMP.Config.Path)\php</workingdirectory>
610-
<executable>php-cgi</executable>
614+
<executable>$($WCMP.Config.Path)\php\php-cgi.exe</executable>
611615
<arguments>-b 127.0.0.1:$($WCMP.Config.PHPPort)</arguments>
612616
<delayedAutoStart>true</delayedAutoStart>
613617
</service>
@@ -616,6 +620,10 @@ if($WCMP.IsUpdate){
616620
$WCMP.Fatal('PHP service config could not be written.')
617621
}
618622
Copy-Item -Path $WinSW_DestinationFilePath -Destination $WinSW_Service_PHPExePath -Force
623+
if(Get-Service -Name 'WCMP_PHP' -ErrorAction SilentlyContinue){
624+
Stop-Service -Name 'WCMP_PHP' -Force -ErrorAction SilentlyContinue
625+
& $WinSW_Service_PHPExePath uninstall
626+
}
619627
& $WinSW_Service_PHPExePath install
620628
if($LASTEXITCODE -ne 0){ $WCMP.Fatal('PHP service could not be installed.') }
621629
$WCMP.Info('PHP service registered.')
@@ -629,7 +637,7 @@ if($WCMP.IsUpdate){
629637
<name>WCMP MariaDB</name>
630638
<description>This service runs the WCMP MariaDB server.</description>
631639
<workingdirectory>$($WCMP.Config.Path)\mariadb\bin</workingdirectory>
632-
<executable>mariadbd</executable>
640+
<executable>$($WCMP.Config.Path)\mariadb\bin\mariadbd.exe</executable>
633641
<arguments>--datadir=$($WCMP.Config.Path)\mariadb\data --port=$($WCMP.Config.MariaDBPort)</arguments>
634642
<delayedAutoStart>true</delayedAutoStart>
635643
</service>
@@ -638,6 +646,10 @@ if($WCMP.IsUpdate){
638646
$WCMP.Fatal('MariaDB service config could not be written.')
639647
}
640648
Copy-Item -Path $WinSW_DestinationFilePath -Destination $WinSW_Service_MariaDBExePath -Force
649+
if(Get-Service -Name 'WCMP_MariaDB' -ErrorAction SilentlyContinue){
650+
Stop-Service -Name 'WCMP_MariaDB' -Force -ErrorAction SilentlyContinue
651+
& $WinSW_Service_MariaDBExePath uninstall
652+
}
641653
& $WinSW_Service_MariaDBExePath install
642654
if($LASTEXITCODE -ne 0){ $WCMP.Fatal('MariaDB service could not be installed.') }
643655
$WCMP.Info('MariaDB service registered.')
@@ -952,7 +964,7 @@ if($WCMP.IncludeWinSW){
952964
<name>WCMP Caddy</name>
953965
<description>This service runs the WCMP Caddy server.</description>
954966
<workingdirectory>$($WCMP.Config.Path)\caddy</workingdirectory>
955-
<executable>caddy</executable>
967+
<executable>$($WCMP.Config.Path)\caddy\caddy.exe</executable>
956968
<arguments>run --watch</arguments>
957969
<delayedAutoStart>true</delayedAutoStart>
958970
</service>
@@ -963,6 +975,10 @@ if($WCMP.IncludeWinSW){
963975
$WCMP.Info('Caddy service config is available at: "'+$WinSW_Service_CaddyFilePath+'"')
964976
$WCMP.Info('Installing Caddy service (this may trigger a UAC prompt, please accept)...')
965977
Copy-Item -Path $WinSW_DestinationFilePath -Destination $WinSW_Service_CaddyExePath -Force
978+
if(Get-Service -Name 'WCMP_Caddy' -ErrorAction SilentlyContinue){
979+
Stop-Service -Name 'WCMP_Caddy' -Force -ErrorAction SilentlyContinue
980+
& $WinSW_Service_CaddyExePath uninstall
981+
}
966982
& $WinSW_Service_CaddyExePath install
967983
if($LASTEXITCODE -ne 0){
968984
$WCMP.Fatal('Caddy service could not be installed. (have you accepted the UAC prompt? try running the script as administrator)')
@@ -978,7 +994,7 @@ if($WCMP.IncludeWinSW){
978994
<name>WCMP PHP</name>
979995
<description>This service runs the WCMP PHP server.</description>
980996
<workingdirectory>$($WCMP.Config.Path)\php</workingdirectory>
981-
<executable>php-cgi</executable>
997+
<executable>$($WCMP.Config.Path)\php\php-cgi.exe</executable>
982998
<arguments>-b 127.0.0.1:$($WCMP.Config.PHPPort)</arguments>
983999
<delayedAutoStart>true</delayedAutoStart>
9841000
</service>
@@ -989,6 +1005,10 @@ if($WCMP.IncludeWinSW){
9891005
$WCMP.Info('PHP service config is available at: "'+$WinSW_Service_PHPFilePath+'"')
9901006
$WCMP.Info('Installing PHP service (this may trigger a UAC prompt, please accept)...')
9911007
Copy-Item -Path $WinSW_DestinationFilePath -Destination $WinSW_Service_PHPExePath -Force
1008+
if(Get-Service -Name 'WCMP_PHP' -ErrorAction SilentlyContinue){
1009+
Stop-Service -Name 'WCMP_PHP' -Force -ErrorAction SilentlyContinue
1010+
& $WinSW_Service_PHPExePath uninstall
1011+
}
9921012
& $WinSW_Service_PHPExePath install
9931013
if($LASTEXITCODE -ne 0){
9941014
$WCMP.Fatal('PHP service could not be installed. (have you accepted the UAC prompt? try running the script as administrator)')
@@ -1005,7 +1025,7 @@ if($WCMP.IncludeWinSW){
10051025
<name>WCMP MariaDB</name>
10061026
<description>This service runs the WCMP MariaDB server.</description>
10071027
<workingdirectory>$($WCMP.Config.Path)\mariadb\bin</workingdirectory>
1008-
<executable>mariadbd</executable>
1028+
<executable>$($WCMP.Config.Path)\mariadb\bin\mariadbd.exe</executable>
10091029
<arguments>--datadir=$($WCMP.Config.Path)\mariadb\data --port=$($WCMP.Config.MariaDBPort)</arguments>
10101030
<delayedAutoStart>true</delayedAutoStart>
10111031
</service>
@@ -1016,6 +1036,10 @@ if($WCMP.IncludeWinSW){
10161036
$WCMP.Info('MariaDB service config is available at: "'+$WinSW_Service_MariaDBFilePath+'"')
10171037
$WCMP.Info('Installing MariaDB service (this may trigger a UAC prompt, please accept)...')
10181038
Copy-Item -Path $WinSW_DestinationFilePath -Destination $WinSW_Service_MariaDBExePath -Force
1039+
if(Get-Service -Name 'WCMP_MariaDB' -ErrorAction SilentlyContinue){
1040+
Stop-Service -Name 'WCMP_MariaDB' -Force -ErrorAction SilentlyContinue
1041+
& $WinSW_Service_MariaDBExePath uninstall
1042+
}
10191043
& $WinSW_Service_MariaDBExePath install
10201044
if($LASTEXITCODE -ne 0){
10211045
$WCMP.Fatal('MariaDB service could not be installed. (have you accepted the UAC prompt? try running the script as administrator)')
@@ -1062,6 +1086,14 @@ try {
10621086
$WCMP.Error('WCMP download cache directory could not be removed.')
10631087
}
10641088

1089+
if($WCMP.IncludeWinSW){
1090+
$WCMP.Info('Starting services...')
1091+
Start-Service -Name 'WCMP_Caddy' -ErrorAction SilentlyContinue
1092+
if($WCMP.IncludePHP){ Start-Service -Name 'WCMP_PHP' -ErrorAction SilentlyContinue }
1093+
if($WCMP.IncludeMariaDB){ Start-Service -Name 'WCMP_MariaDB' -ErrorAction SilentlyContinue }
1094+
$WCMP.Info('Services started.')
1095+
}
1096+
10651097
$WCMP.Info('---------------------------')
10661098
$WCMP.Info('WCMP installation finished!')
10671099
$WCMP.Info('---------------------------')

0 commit comments

Comments
 (0)