1
0
Fork 0
mirror of https://codeberg.org/Mo8it/AdvLabDB.git synced 2024-11-12 21:40:41 +00:00
AdvLabDB/advlabdb/scripts/setup/logged_server_setup.py

44 lines
1 KiB
Python
Raw Normal View History

2022-07-03 16:26:15 +00:00
"""
No relative imports allowed in this file to be able to run server_setup.py without packages.
"""
2022-05-17 09:58:19 +00:00
import sys
2022-05-08 15:29:45 +00:00
from pathlib import Path
2022-05-17 10:09:54 +00:00
sys.path.insert(0, str(Path(__file__).parent.parent.absolute()))
2022-05-17 09:58:19 +00:00
from terminal_utils import run, step
2022-05-08 15:29:45 +00:00
def main():
step("Update system packages")
run("sudo apt update")
run("sudo apt dist-upgrade")
step("Remove unused packages")
run("sudo apt autoremove")
step("Install needed system packages")
2022-05-30 15:32:21 +00:00
run("sudo apt install python3 python3-pip python3-venv ufw nginx systemd -y")
2022-05-08 15:29:45 +00:00
step("Install optional system packages")
2022-06-01 23:35:57 +00:00
run("sudo apt install htop rsync sqlite3")
2022-05-08 15:29:45 +00:00
step("Setup firewall")
run("sudo ufw default allow outgoing")
run("sudo ufw default deny incoming")
run("sudo ufw allow ssh")
run("sudo ufw allow http/tcp")
run("sudo ufw allow https/tcp")
run("sudo ufw enable")
run("sudo ufw status")
step("Deactivate the 'root' user")
run("sudo passwd -l root")
step("Reboot")
2022-06-14 23:42:32 +00:00
run("sudo systemctl reboot")
2022-05-08 15:29:45 +00:00
if __name__ == "__main__":
main()