Skip to content

Commit 27f14bb

Browse files
committed
ServiceUpdater WIP
1 parent 27cc503 commit 27f14bb

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

app/updater/ServiceUpdater.scala

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
11
package updater
22

3+
import better.files.File
4+
5+
import scala.language.postfixOps
36
import scala.sys.process._
47

58
sealed trait ServiceUpdater {
6-
def restartAndReplace(): Unit
9+
def restartAndReplace(dirWithUpdate: File): Unit
710
}
811

912
class WindowsServiceUpdater extends ServiceUpdater {
10-
override def restartAndReplace(): Unit = ???
13+
override def restartAndReplace(dirWithUpdate: File): Unit = {
14+
"%COMPSPEC% /C /D \"scripts\\restart_replace.cmd\" Arg1 Arg2 Arg3" !
15+
}
1116
}
1217

1318
class LinuxServiceUpdater extends ServiceUpdater {
14-
override def restartAndReplace(): Unit = {
15-
"touch /tmp/update.txt" !
19+
override def restartAndReplace(dirWithUpdate: File): Unit = {
20+
"/bin/bash -c \"restart_replace.sh\"" !
1621
}
1722
}

app/updater/Updater.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class Updater @Inject()(connector: GithubConnector, serviceUpdater: ServiceUpdat
4545
val dirWithUpdate = file.unzipTo(File(s"update-${release.tagName}"))
4646
logger.debug(s"Updater unzipped the update to $dirWithUpdate")
4747

48-
serviceUpdater.restartAndReplace()
48+
serviceUpdater.restartAndReplace(dirWithUpdate)
4949
}
5050
}
5151

scripts/restart_replace.cmd

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
net stop rbackup-client &&
2+
move conf conf.old &&
3+
move lib lib.old &&
4+
move public public.old &&
5+
move %1\conf conf &&
6+
move %1\lib lib &&
7+
move %1\public public &&
8+
net start rbackup-client

scripts/restart_replace.sh

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/bash
2+
3+
lu

0 commit comments

Comments
 (0)