Improvements For Storage Space Management (#26)
* Add cleaning commands to DNF. * Clean flatpak as best we can. * Taking advice from TechRepublic about clean commands. * Add prompt for removing freebsd-update folder. * Add trash checking function with cleanup option. * Enhance check-trash to include "trash" such as mail. * Separate the call to mounted filesystems. * Add clean function to clear local trash. * Change underscore version to alias not function. * Fix `clean`. * Reduce journalctl log size to 100M. Also modified names.
This commit is contained in:
@ -115,7 +115,7 @@
|
||||
alias_cp: alias cp='cp -v'
|
||||
alias_mv: alias mv='mv -v'
|
||||
alias_rm: alias rm='echo "Use mv ~/TRASH/ instead!"'
|
||||
alias_clean: alias clean='mv * ~/TRASH/'
|
||||
alias_clean_dir: alias clean-dir='mv * ~/TRASH/'
|
||||
alias_clean_trash: alias clean-trash='sh -c "rm -rfv ~/TRASH/*"'
|
||||
path_additions: export PATH="~/bin:$PATH"
|
||||
function_wttr: |
|
||||
@ -191,6 +191,71 @@
|
||||
alias edit-config-wrk="sudo $EDITOR {{ wrk_file }}"
|
||||
alias edit-config-mnr="sudo $EDITOR {{ mnr_file }}"
|
||||
alias edit-config-srv="sudo $EDITOR {{ srv_file }}"
|
||||
function_check_trash: |
|
||||
function check-trash() {
|
||||
unset OPTIND
|
||||
while (( $# > 0 )); do
|
||||
case $1 in
|
||||
-c | -y | --clean ) clean="Y" ;;
|
||||
-n | -net | --network ) network="Y" ;;
|
||||
* ) echo "
|
||||
ERROR: Option '$1' with value '$2' not recognized.
|
||||
$PROG [-c|-clean|--clean|-y] [-n|-net|--network]
|
||||
"
|
||||
return 1
|
||||
esac
|
||||
shift
|
||||
done
|
||||
echo "clean=$clean"
|
||||
echo "network=$network"
|
||||
echo "Grabbing sudo permissions..."
|
||||
sudo echo "Success! Starting search..."
|
||||
function dirs_to_check {
|
||||
echo "/root"
|
||||
echo "/home"
|
||||
}
|
||||
dirs_to_check | while read dir; do
|
||||
echo "Checking $dir..."
|
||||
sudo find $dir -name TRASH | while read trash; do
|
||||
if [[ "$trash" != "" && `sudo ls $trash` ]]; then
|
||||
echo "Found $trash with contents:"
|
||||
sudo ls -lh $trash
|
||||
if [[ "$clean" == "Y" ]]; then
|
||||
echo "Cleaning trash..."
|
||||
sudo sh -c "rm -rfv $trash/*"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
if [[ "$network" == "Y" ]]; then
|
||||
function network_to_check {
|
||||
find /mnt -maxdepth 1 -mindepth 1
|
||||
}
|
||||
network_to_check | while read dir; do
|
||||
echo "Checking $dir..."
|
||||
sudo find $dir -name TRASH | while read trash; do
|
||||
if [[ "$trash" != "" && `sudo ls $trash` ]]; then
|
||||
echo "Found $trash with contents:"
|
||||
sudo ls -lh $trash
|
||||
if [[ "$clean" == "Y" ]]; then
|
||||
echo "Cleaning trash..."
|
||||
sudo sh -c "rm -rfv $trash/*"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
fi
|
||||
echo "Checking but not cleaning /var/mail..."
|
||||
du -ha /var/mail | sort -h
|
||||
return 0
|
||||
}
|
||||
alias check_trash="check-trash"
|
||||
function_clean: |
|
||||
function clean() {
|
||||
sudo df -h
|
||||
check-trash --clean
|
||||
sudo df -h
|
||||
}
|
||||
|
||||
- name: General | Account Management | Users | Files | Common Variable
|
||||
set_fact:
|
||||
@ -199,7 +264,7 @@
|
||||
{{ alias_cp }}
|
||||
{{ alias_mv }}
|
||||
{{ alias_rm }}
|
||||
{{ alias_clean }}
|
||||
{{ alias_clean_dir }}
|
||||
{{ alias_clean_trash }}
|
||||
{{ function_wttr }}
|
||||
{{ PS1 }}
|
||||
@ -212,6 +277,8 @@
|
||||
{{ metasploit }}
|
||||
{{ show_config }}
|
||||
{{ edit_config }}
|
||||
{{ function_check_trash }}
|
||||
{{ function_clean }}
|
||||
|
||||
- name: General | Account Management | Users | Files | .bashrc
|
||||
blockinfile:
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
## Cron ##
|
||||
|
||||
- name: General | Software | Services | Enable CROND
|
||||
- name: General | Software | Services | CROND | Enable
|
||||
service:
|
||||
name: "{{ crond }}"
|
||||
pattern: "{{ crond_pattern }}"
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
## SSHFS ##
|
||||
|
||||
- name: General | Software | Services | Enable FuseFS (FreeBSD rc.conf)
|
||||
- name: General | Software | Services | SSHFS | Enable FuseFS (FreeBSD rc.conf)
|
||||
lineinfile:
|
||||
path: "{{ rc_conf }}"
|
||||
regexp: 'fusefs_enable='
|
||||
@ -23,7 +23,7 @@
|
||||
backup: yes
|
||||
when: ansible_system == "FreeBSD"
|
||||
|
||||
- name: General | Software | Services | Enable SSHFS (FreeBSD service)
|
||||
- name: General | Software | Services | SSHFS | Enable SSHFS (FreeBSD service)
|
||||
service:
|
||||
name: fusefs
|
||||
pattern: fusefs
|
||||
@ -34,14 +34,14 @@
|
||||
|
||||
## CUPS ##
|
||||
|
||||
- name: General | Software | Services | Disable CUPS Daemon
|
||||
- name: General | Software | Services | CUPS | Disable
|
||||
service:
|
||||
name: "{{ cups }}"
|
||||
pattern: "{{ cups_pattern }}"
|
||||
state: stopped
|
||||
enabled: no
|
||||
|
||||
- name: General | Software | Services | Disable CUPS-Browse Daemon
|
||||
- name: General | Software | Services | CUPS-Browse | Disable
|
||||
service:
|
||||
name: "{{ cups_browse }}"
|
||||
pattern: "{{ cups_browse_pattern }}"
|
||||
@ -51,7 +51,7 @@
|
||||
|
||||
## SSHD ##
|
||||
|
||||
- name: General | Software | Services | Configure SSHD
|
||||
- name: General | Software | Services | SSHD | Configure
|
||||
lineinfile:
|
||||
path: "{{ sshd_config }}"
|
||||
regexp: '{{ item.key }}'
|
||||
@ -75,7 +75,7 @@
|
||||
- { "key": '^[\#]?AllowAgentForwarding', "value": 'AllowAgentForwarding no'}
|
||||
- { "key": '^[\#]?PermitEmptyPasswords', "value": 'PermitEmptyPasswords no'}
|
||||
|
||||
- name: General | Software | Services | Configure SSHD
|
||||
- name: General | Software | Services | SSHD | Configure (PVE)
|
||||
lineinfile:
|
||||
path: "{{ sshd_config }}"
|
||||
regexp: '{{ item.key }}'
|
||||
@ -89,9 +89,17 @@
|
||||
- { "key": '^[\#]?MaxSessions', "value": 'MaxSessions 5'}
|
||||
when: "'pve' in ansible_kernel"
|
||||
|
||||
- name: General | Software | Services | Enable SSHD
|
||||
- name: General | Software | Services | SSHD | Enable
|
||||
service:
|
||||
name: "{{ sshd }}"
|
||||
pattern: "{{ sshd_pattern }}"
|
||||
state: reloaded
|
||||
enabled: yes
|
||||
|
||||
|
||||
## JournalCTL ##
|
||||
|
||||
- name: General | Software | Services | JournalCTL | Reduce Log Size
|
||||
shell: journalctl --vacuum-size=100M
|
||||
when: ansible_system == "Linux"
|
||||
ignore_errors: yes
|
||||
|
Reference in New Issue
Block a user