Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion debian/postinst
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
#!/bin/sh
set -e

# Hide root warning for pip
export PIP_ROOT_USER_ACTION=ignore
export PIP_BREAK_SYSTEM_PACKAGES=1

case "$1" in
install|configure)
echo "No work to do..."
echo "Install Python requirements"

/usr/bin/python3 -m pip install pwinput

exit 0
;;
upgrade|abort-upgrade)
Expand Down
24 changes: 11 additions & 13 deletions usr/bin/linuxmuster-fileserver
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ import subprocess
import socket
import os.path
import os
import sys

from pwinput import pwinput
from subprocess import PIPE


def __execute(command) -> subprocess.CompletedProcess:
"""
Execute a command and return a subprocess.CompletedProcess object
Expand Down Expand Up @@ -88,8 +91,7 @@ def setup(domain, username, password, school) -> str:
if os.path.exists("/etc/krb5.conf"):
print("✅")
else:
print("❌")
exit(1)
sys.exit("❌")

print("Copy template for new nsswitch.conf... ", end="")
with open("/var/lib/linuxmuster-fileserver/nsswitch.conf.example", "r") as f:
Expand All @@ -99,8 +101,7 @@ def setup(domain, username, password, school) -> str:
if os.path.exists("/etc/nsswitch.conf"):
print("✅")
else:
print("❌")
exit(1)
sys.exit("❌")

print("Copy template for new smb.conf... ", end="")
with open("/var/lib/linuxmuster-fileserver/smb.conf.example", "r") as f:
Expand All @@ -113,16 +114,14 @@ def setup(domain, username, password, school) -> str:
if os.path.exists("/etc/samba/smb.conf"):
print("✅")
else:
print("❌")
exit(1)
sys.exit("❌")

print("Try to join domain with given data... ", end="")
__execute(["/usr/bin/net", "ads", "join", "-U", username + "%" + password])
output = __execute(["/usr/bin/net", "ads", "join", "-U", username + "%" + password])
if "Join is OK" in __execute(["/usr/bin/net", "ads", "testjoin"]).stdout.decode():
print("✅")
else:
print("❌")
exit(1)
sys.exit(f"❌ \n\033[91m{output.stdout.decode()}\033[0m")

print("Create share for school on this fileserver... ", end="")
path = "/srv/samba/schools/" + school
Expand All @@ -139,8 +138,7 @@ def setup(domain, username, password, school) -> str:
if school in __execute(["/usr/bin/net", "conf", "list"]).stdout.decode():
print("✅")
else:
print("❌")
exit(1)
sys.exit("❌")

print("Restart service smbd.... ", end="")
__execute(["/usr/bin/systemctl", "restart", "smbd"])
Expand Down Expand Up @@ -189,7 +187,7 @@ def main():

if args.command == "setup":
if not args.password:
password = input("Please enter password for %s@%s: " % (args.username, args.domain.upper()))
password = pwinput("Please enter password for %s@%s: " % (args.username, args.domain.upper()))
else:
password = args.password
print(setup(args.domain.upper(), args.username, password, args.school.lower()))
Expand All @@ -201,4 +199,4 @@ def main():


if __name__ == "__main__":
main()
main()