mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Add basic-space-cleanup command
This commit is contained in:
parent
aab80f9ecc
commit
b920b82f4e
2 changed files with 34 additions and 0 deletions
|
@ -1739,6 +1739,10 @@ tools:
|
|||
help: python command to execute
|
||||
full: --command
|
||||
|
||||
### tools_basic_space_cleanup()
|
||||
basic-space-cleanup:
|
||||
action_help: Basic space cleanup (apt, journalctl, logs, ...)
|
||||
|
||||
### tools_shutdown()
|
||||
shutdown:
|
||||
action_help: Shutdown the server
|
||||
|
|
30
src/tools.py
30
src/tools.py
|
@ -623,6 +623,36 @@ def tools_shell(command=None):
|
|||
shell = code.InteractiveConsole(vars)
|
||||
shell.interact()
|
||||
|
||||
def tools_basic_space_cleanup():
|
||||
"""
|
||||
Basic space cleanup.
|
||||
|
||||
apt autoremove
|
||||
apt clean
|
||||
archived logs removal
|
||||
journalctl vacuum (leaves 50M of logs)
|
||||
"""
|
||||
subprocess.run(
|
||||
[
|
||||
"/bin/bash",
|
||||
"-c",
|
||||
"apt autoremove && apt autoclean",
|
||||
]
|
||||
)
|
||||
subprocess.run(
|
||||
[
|
||||
"/bin/bash",
|
||||
"-c",
|
||||
"journalctl --vacuum-size=50M",
|
||||
]
|
||||
)
|
||||
subprocess.run(
|
||||
[
|
||||
"/bin/bash",
|
||||
"-c",
|
||||
"rm /var/log/*.gz && rm /var/log/*/*.gz && rm /var/log/*.? && rm /var/log/*/*.?",
|
||||
]
|
||||
)
|
||||
|
||||
# ############################################ #
|
||||
# #
|
||||
|
|
Loading…
Add table
Reference in a new issue