mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 02:20:39 +00:00
Make config path configurable
This commit is contained in:
parent
506bc5df13
commit
0130585355
4 changed files with 19 additions and 7 deletions
|
@ -7,7 +7,7 @@ After=network.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=dbus
|
Type=dbus
|
||||||
ExecStart=%dir%/bin/textsecure-cli -u %I daemon --system
|
ExecStart=%dir%/bin/textsecure-cli -u %I --config /var/lib/textsecure-cli daemon --system
|
||||||
User=textsecure-cli
|
User=textsecure-cli
|
||||||
BusName=org.asamk.TextSecure
|
BusName=org.asamk.TextSecure
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ Description=Send secure messages to TextSecure/Signal clients
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=dbus
|
Type=dbus
|
||||||
ExecStart=%dir%/bin/textsecure-cli -u %number% daemon --system
|
ExecStart=%dir%/bin/textsecure-cli -u %number% --config /var/lib/textsecure-cli daemon --system
|
||||||
User=textsecure-cli
|
User=textsecure-cli
|
||||||
BusName=org.asamk.TextSecure
|
BusName=org.asamk.TextSecure
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import net.sourceforge.argparse4j.ArgumentParsers;
|
||||||
import net.sourceforge.argparse4j.impl.Arguments;
|
import net.sourceforge.argparse4j.impl.Arguments;
|
||||||
import net.sourceforge.argparse4j.inf.*;
|
import net.sourceforge.argparse4j.inf.*;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.apache.http.util.TextUtils;
|
||||||
import org.asamk.TextSecure;
|
import org.asamk.TextSecure;
|
||||||
import org.freedesktop.dbus.DBusConnection;
|
import org.freedesktop.dbus.DBusConnection;
|
||||||
import org.freedesktop.dbus.exceptions.DBusException;
|
import org.freedesktop.dbus.exceptions.DBusException;
|
||||||
|
@ -79,7 +80,12 @@ public class Main {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m = new Manager(username);
|
String settingsPath = ns.getString("config");
|
||||||
|
if (TextUtils.isEmpty(settingsPath)) {
|
||||||
|
settingsPath = System.getProperty("user.home") + "/.config/textsecure";
|
||||||
|
}
|
||||||
|
|
||||||
|
m = new Manager(username, settingsPath);
|
||||||
ts = m;
|
ts = m;
|
||||||
if (m.userExists()) {
|
if (m.userExists()) {
|
||||||
try {
|
try {
|
||||||
|
@ -355,6 +361,8 @@ public class Main {
|
||||||
parser.addArgument("-v", "--version")
|
parser.addArgument("-v", "--version")
|
||||||
.help("Show package version.")
|
.help("Show package version.")
|
||||||
.action(Arguments.version());
|
.action(Arguments.version());
|
||||||
|
parser.addArgument("--config")
|
||||||
|
.help("Set the path, where to store the config (Default: $HOME/.config/textsecure-cli).");
|
||||||
|
|
||||||
MutuallyExclusiveGroup mut = parser.addMutuallyExclusiveGroup();
|
MutuallyExclusiveGroup mut = parser.addMutuallyExclusiveGroup();
|
||||||
mut.addArgument("-u", "--username")
|
mut.addArgument("-u", "--username")
|
||||||
|
|
|
@ -59,9 +59,9 @@ class Manager implements TextSecure {
|
||||||
public final static String PROJECT_VERSION = Manager.class.getPackage().getImplementationVersion();
|
public final static String PROJECT_VERSION = Manager.class.getPackage().getImplementationVersion();
|
||||||
private final static String USER_AGENT = PROJECT_NAME + " " + PROJECT_VERSION;
|
private final static String USER_AGENT = PROJECT_NAME + " " + PROJECT_VERSION;
|
||||||
|
|
||||||
private final static String settingsPath = System.getProperty("user.home") + "/.config/textsecure";
|
private final String settingsPath;
|
||||||
private final static String dataPath = settingsPath + "/data";
|
private final String dataPath;
|
||||||
private final static String attachmentsPath = settingsPath + "/attachments";
|
private final String attachmentsPath;
|
||||||
|
|
||||||
private final ObjectMapper jsonProcessot = new ObjectMapper();
|
private final ObjectMapper jsonProcessot = new ObjectMapper();
|
||||||
private String username;
|
private String username;
|
||||||
|
@ -76,8 +76,12 @@ class Manager implements TextSecure {
|
||||||
private TextSecureAccountManager accountManager;
|
private TextSecureAccountManager accountManager;
|
||||||
private JsonGroupStore groupStore;
|
private JsonGroupStore groupStore;
|
||||||
|
|
||||||
public Manager(String username) {
|
public Manager(String username, String settingsPath) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
|
this.settingsPath = settingsPath;
|
||||||
|
this.dataPath = this.settingsPath + "/data";
|
||||||
|
this.attachmentsPath = this.settingsPath + "/attachments";
|
||||||
|
|
||||||
jsonProcessot.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); // disable autodetect
|
jsonProcessot.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE); // disable autodetect
|
||||||
jsonProcessot.enable(SerializationFeature.INDENT_OUTPUT); // for pretty print, you can disable it.
|
jsonProcessot.enable(SerializationFeature.INDENT_OUTPUT); // for pretty print, you can disable it.
|
||||||
jsonProcessot.enable(SerializationFeature.WRITE_NULL_MAP_VALUES);
|
jsonProcessot.enable(SerializationFeature.WRITE_NULL_MAP_VALUES);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue