mirror of
https://github.com/abraunegg/onedrive
synced 2024-06-27 01:40:09 +02:00
* Fix incorrectly nested configDir in X11 systems
This commit is contained in:
parent
53cbc8ff5e
commit
3a4c71d7ee
35
src/main.d
35
src/main.d
|
@ -10,27 +10,32 @@ int main(string[] args)
|
||||||
// Determine the users home directory.
|
// Determine the users home directory.
|
||||||
// Need to avoid using ~ here as expandTilde() below does not interpret correctly when running under init.d or systemd scripts
|
// Need to avoid using ~ here as expandTilde() below does not interpret correctly when running under init.d or systemd scripts
|
||||||
string homePath = "";
|
string homePath = "";
|
||||||
|
|
||||||
|
// Check for HOME environment variable
|
||||||
|
if (environment.get("HOME") != ""){
|
||||||
|
// Use HOME environment variable
|
||||||
|
homePath = environment.get("HOME");
|
||||||
|
} else {
|
||||||
|
if ((environment.get("SHELL") == "") && (environment.get("USER") == "")){
|
||||||
|
// No shell is set or username - observed case when running as systemd service under CentOS 7.x
|
||||||
|
homePath = "/root";
|
||||||
|
} else {
|
||||||
|
// A shell & valid user is set, but no HOME is set, use ~ which can be expanded
|
||||||
|
homePath = "~";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Determine the base directory relative to which user specific configuration files should be stored.
|
||||||
|
string configDirBase = "";
|
||||||
if (environment.get("XDG_CONFIG_HOME") != ""){
|
if (environment.get("XDG_CONFIG_HOME") != ""){
|
||||||
homePath = environment.get("XDG_CONFIG_HOME");
|
configDirBase = environment.get("XDG_CONFIG_HOME");
|
||||||
} else {
|
} else {
|
||||||
// XDG_CONFIG_HOME does not exist on systems where X11 is not present - ie - headless systems / servers
|
// XDG_CONFIG_HOME does not exist on systems where X11 is not present - ie - headless systems / servers
|
||||||
// Check for HOME environment variable
|
configDirBase = homePath ~ "/.config";
|
||||||
if (environment.get("HOME") != ""){
|
|
||||||
// Use HOME environment variable
|
|
||||||
homePath = environment.get("HOME");
|
|
||||||
} else {
|
|
||||||
if ((environment.get("SHELL") == "") && (environment.get("USER") == "")){
|
|
||||||
// No shell is set or username - observed case when running as systemd service under CentOS 7.x
|
|
||||||
homePath = "/root";
|
|
||||||
} else {
|
|
||||||
// A shell & valid user is set, but no XDG_CONFIG_HOME or HOME set
|
|
||||||
homePath = "~";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// configuration directory
|
// configuration directory
|
||||||
string configDirName = homePath ~ "/.config/onedrive";
|
string configDirName = configDirBase ~ "/onedrive";
|
||||||
// only download remote changes
|
// only download remote changes
|
||||||
bool downloadOnly;
|
bool downloadOnly;
|
||||||
// override the sync directory
|
// override the sync directory
|
||||||
|
|
Loading…
Reference in a new issue