Commit 2df59160 authored by Julian Kranz's avatar Julian Kranz

Initial commit

parents
#!/usr/bin/rdmd
import std.stdio;
import std.regex;
import std.process;
int main(string[] args) {
if(args.length != 2) {
writeln("Usage: update-gitlab.d url_to_debian_package");
return -1;
}
auto url = args[1];
auto url_parts = split(url, regex(r"/"));
auto file = url_parts[url_parts.length - 1];
writefln("+++[update-gitlab] Downloading file %s from %s...", file, url);
auto r = wait(spawnProcess(["wget", url]));
if (r != 0) {
writeln("---[update-gitlab] Failed to download the file.");
return 1;
}
writefln("+++[update-gitlab] Creating gitlab backup...");
r = wait(spawnProcess(["/opt/gitlab/bin/gitlab-rake", "gitlab:backup:create"]));
if(r != 0) {
writeln("---[update-gitlab] Failed to create backup.");
return 2;
}
writefln("+++[update-gitlab] Installing package...");
r = wait(spawnProcess(["dpkg", "--install", file]));
if(r != 0) {
writeln("---[update-gitlab] Failed to install package.");
return 3;
}
writefln("+++[update-gitlab] Reconfiguring gitlab...");
r = wait(spawnProcess(["gitlab-ctl", "reconfigure"]));
if(r != 0) {
writeln("---[update-gitlab] Failed to reconfigure gitlab.");
return 4;
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment