fix
This commit is contained in:
@@ -14,12 +14,13 @@ def getenv(name):
|
|||||||
print(f"[ERROR] Missing environment variable {name}. You should NOT run this script by hand, please use systemd mastodon-kanidm-sync.service.")
|
print(f"[ERROR] Missing environment variable {name}. You should NOT run this script by hand, please use systemd mastodon-kanidm-sync.service.")
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
# Import configuration
|
# Import configuration
|
||||||
KANIDM_URL = getenv("KANIDM_URL")
|
KANIDM_URL = getenv("KANIDM_URL")
|
||||||
KANIDM_TOKEN = read_file(getenv("KANIDM_TOKEN_PATH")).strip()
|
KANIDM_TOKEN = read_file(getenv("KANIDM_TOKEN_PATH")).strip()
|
||||||
OWNER_USERNAME = getenv("OWNER_USERNAME")
|
OWNER_USERNAME = getenv("OWNER_USERNAME")
|
||||||
|
SLEEP_TIME = int(getenv("SLEEP_TIME"))
|
||||||
|
|
||||||
|
def sync_mastodon():
|
||||||
# Fetch kanidm users list from userdata file
|
# Fetch kanidm users list from userdata file
|
||||||
# Userdata file is json list with information about what users are configured by kanidm
|
# Userdata file is json list with information about what users are configured by kanidm
|
||||||
try:
|
try:
|
||||||
@@ -140,3 +141,7 @@ try:
|
|||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print("[INFO] userdata.json file doesn't exist. Creating it")
|
print("[INFO] userdata.json file doesn't exist. Creating it")
|
||||||
write_userdata("x")
|
write_userdata("x")
|
||||||
|
|
||||||
|
while True:
|
||||||
|
sync_mastodon()
|
||||||
|
time.sleep(SLEEP_TIME)
|
||||||
|
14
module.nix
14
module.nix
@@ -91,7 +91,7 @@ in
|
|||||||
enableUnixSocket = false;
|
enableUnixSocket = false;
|
||||||
configureNginx = true;
|
configureNginx = true;
|
||||||
database.createLocally = true;
|
database.createLocally = true;
|
||||||
streamingProcesses = 3;
|
streamingProcesses = 2;
|
||||||
|
|
||||||
smtp = {
|
smtp = {
|
||||||
createLocally = false;
|
createLocally = false;
|
||||||
@@ -105,8 +105,7 @@ in
|
|||||||
port = 465;
|
port = 465;
|
||||||
};
|
};
|
||||||
extraConfig = {
|
extraConfig = {
|
||||||
# "SMTP_ENABLE_STARTTLS" = "never";
|
"SMTP_ENABLE_STARTTLS_AUTO" = "true"; # Simple NixOS MailServer doesn't allow connections without SSL
|
||||||
"SMTP_ENABLE_STARTTLS_AUTO" = "true";
|
|
||||||
"SMTP_ENABLE_STARTTLS" = "always";
|
"SMTP_ENABLE_STARTTLS" = "always";
|
||||||
"SMTP_TLS" = "true";
|
"SMTP_TLS" = "true";
|
||||||
"SMTP_SSL" = "true";
|
"SMTP_SSL" = "true";
|
||||||
@@ -114,14 +113,7 @@ in
|
|||||||
"DISALLOW_UNAUTHENTICATED_API_ACCESS" = lib.boolToString cfg.dissallowUnauthenticatedAPI;
|
"DISALLOW_UNAUTHENTICATED_API_ACCESS" = lib.boolToString cfg.dissallowUnauthenticatedAPI;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
users.users.mastodon.isSystemUser = lib.mkForce false;
|
|
||||||
users.users.mastodon.isNormalUser = lib.mkForce true;
|
|
||||||
|
|
||||||
users.groups."email-users" = {};
|
|
||||||
users.users."noreply.mastodon" = {
|
|
||||||
isSystemUser = true;
|
|
||||||
group = "email-users";
|
|
||||||
};
|
|
||||||
selfprivacy.emails."noreply.mastodon" = {
|
selfprivacy.emails."noreply.mastodon" = {
|
||||||
hashedPasswordFile = secrets.hashedPasswordFile;
|
hashedPasswordFile = secrets.hashedPasswordFile;
|
||||||
systemdTargets = [ "mastodon-email-password-setup.service" ];
|
systemdTargets = [ "mastodon-email-password-setup.service" ];
|
||||||
@@ -155,7 +147,6 @@ in
|
|||||||
|
|
||||||
services.mastodon-kanidm-sync = {
|
services.mastodon-kanidm-sync = {
|
||||||
after = [
|
after = [
|
||||||
# "mastodon.service" # TODO: ??
|
|
||||||
"postgresql.service"
|
"postgresql.service"
|
||||||
"kanidm.service"
|
"kanidm.service"
|
||||||
];
|
];
|
||||||
@@ -173,6 +164,7 @@ in
|
|||||||
POSTGRES_HOST = db.host;
|
POSTGRES_HOST = db.host;
|
||||||
USERDATA_FILE_PATH = "/var/lib/mastodon/.userdata.json";
|
USERDATA_FILE_PATH = "/var/lib/mastodon/.userdata.json";
|
||||||
OWNER_USERNAME = sp.username;
|
OWNER_USERNAME = sp.username;
|
||||||
|
SLEEP_TIME = "30";
|
||||||
};
|
};
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Slice = "mastodon.slice";
|
Slice = "mastodon.slice";
|
||||||
|
Reference in New Issue
Block a user