1

I am running a Windows 2022 Standard server with IIS10 for my websites. I have UptimeKuma running without issue and I'm trying to get a script working that automatically updates it every week.

Here is my batch file:

rem echo off
echo.

cd /d D:\WebHosting\uptime-kuma

net stop UptimeKuma

echo Update from git
git fetch --all

echo Get latest tag name
set latesttag=
for /f "delims=" %%a in ('git describe --tags') do @set latesttag=%%a
echo Checking Out %latestTag%
git checkout %latestTag% --force

echo Install dependencies and prebuilt
npm install --omit=dev
echo Downloading distro
npm run download-dist

echo Restarting UptimeKuma
net start UptimeKuma

After the npm install --omit=dev runs, the batch file drops out and doesn't finish the rest of the steps.

Here is the output:

The UptimeKuma service is not started.

D:\WebHosting\uptime-kuma>echo Update from git
Update from git

D:\WebHosting\uptime-kuma>git fetch --all

D:\WebHosting\uptime-kuma>echo Get latest tag name
Get latest tag name

D:\WebHosting\uptime-kuma>set latesttag=

D:\WebHosting\uptime-kuma>for /F "delims=" %a in ('git describe --tags') do @set latesttag=%a

D:\WebHosting\uptime-kuma>echo Checking Out 1.19.6
Checking Out 1.19.6

D:\WebHosting\uptime-kuma>git checkout 1.19.6 --force
HEAD is now at 2b57b3e8 Update to 1.19.6

D:\WebHosting\uptime-kuma>echo Install dependencies and prebuilt
Install dependencies and prebuilt

D:\WebHosting\uptime-kuma>npm install --omit=dev

up to date, audited 522 packages in 2s

68 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

This is the end, nothing occurs after this.

I was following the update procedures from the UptimeKuma website to come up with the above steps.

Any ideas why it's dropping out at this point?

UPDATE

I tried the following and it did the same thing.

start /w /b npm install --omit=dev

ErocM
  • 4,505
  • 24
  • 94
  • 161
  • Do you know what you're actually running when you use `npm` as a shorthand command? It is a batch file! When you run one batch file from another, and wish control to return afterwards, you need to use the `Call` command. Example ```call npm install --omit=dev``` or the proper way, ```Call "P:\athTo\npm.cmd" install --omit=dev```, _(This is a written once script, not an often written interactive command. There's no need for shorthand and relying on the system to search and fill in the omitted data)_. – Compo Feb 08 '23 at 16:56
  • Ah, wasn't aware of that. Next time I will dig a little deeper. Thanks for the pointer! Once I have it working, I'll post the finished script in case anyone else needs it. – ErocM Feb 08 '23 at 20:38

2 Answers2

0

Thanks to @Compo, this was a simple fix. For those needing to update a git app on your windows box, here is the script I used. Just make the appropriate changes to fit your needs.

echo off
echo.

cd /d D:\WebHosting\uptime-kuma

net stop UptimeKuma

echo Update from git
git fetch --all

echo Get latest tag name
set latesttag=
for /f "delims=" %%a in ('git describe --tags') do @set latesttag=%%a
echo Checking Out %latestTag%
git checkout %latestTag% --force

echo Install dependencies and prebuilt
call npm install --omit=dev

echo Downloading distro
call npm run download-dist

echo Restarting UptimeKuma
net start UptimeKuma
ErocM
  • 4,505
  • 24
  • 94
  • 161
  • `echo` on line 1 should be `@echo`. Personally, I would not go anywhere near `net.exe` to `start` and `stop` a service. Windows has, for many years now, hosted `sc.exe` which I'd consider superior. You should at the very least, use the file extensions too, `net.exe|sc.exe`, `git.exe`, `npm.cmd`. _(I'd recommend that you include the full paths to those utilities too)_. Also, please use `set "latesttag="` and `set "latesttag=%%a"`, and preferably change all `%%a`'s to `%%G`. Also use `('git.exe describe --tags 2^>NUL')`, and insert `If Not Defined lasttag GoTo :EOF` on the line below it. – Compo Feb 08 '23 at 23:38
0

I have just tried this script but it keeps downloading the same 1.19.6 version, looks like the latest tag is not being discovered (1.20.0 has been released)

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Feb 17 '23 at 13:18