Move documentation from README to individual scripts
This commit is contained in:
parent
1eadc49cf0
commit
ee81994947
24
README.md
24
README.md
|
@ -1,26 +1,2 @@
|
|||
# Scripts
|
||||
Scripts for managing Arch Linux servers
|
||||
|
||||
## Overview
|
||||
|
||||
### User management
|
||||
|
||||
The `adduser`, `deluser`, and `moduser` scripts are convenience wrappers around `ldapadd`, `ldapdel`, and `ldapvi`.
|
||||
|
||||
### upgrade
|
||||
Upgrades the system, all AUR packages, and Nextcloud.
|
||||
|
||||
### backup
|
||||
Creates an incremental system backup using `bup`.
|
||||
|
||||
### setid
|
||||
Sets up the `/etc/subuid` and `/etc/subgid` files for [rootless Podman](https://wiki.archlinux.org/title/Podman#Set_subuid_and_subgid).
|
||||
|
||||
### sysusers
|
||||
A script that compares the `/usr/lib/sysusers.d` directory and output of `getent passwd` to find unneeded users.
|
||||
|
||||
### synapse-rm
|
||||
A command-line wrapper around [synadm](https://github.com/JOJ0/synadm) to quickly delete multiple Matrix rooms.
|
||||
|
||||
### pacplot
|
||||
Graphs the number of installed packages over time by parsing `/var/log/pacman.log`.
|
||||
|
|
8
adduser
8
adduser
|
@ -1,7 +1,9 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# A wrapper script over ldapadd
|
||||
|
||||
from sys import argv
|
||||
from os import remove, environ
|
||||
from os import remove
|
||||
from subprocess import run, call, check_output
|
||||
from crypt import crypt
|
||||
|
||||
|
@ -57,8 +59,8 @@ gidNumber: {uid}'''
|
|||
f.write(ldif)
|
||||
|
||||
# Add user
|
||||
ret = call(['ldapadd', '-D', 'cn=Manager,dc=exozy,dc=me',
|
||||
'-w', open('/etc/exozyme.conf', 'r').read().split()[0], '-f', filename])
|
||||
ret = call(['ldapadd', '-D', 'cn=Manager,dc=exozy,dc=me', '-w',
|
||||
open('/etc/ldappass', 'r').read(), '-f', filename])
|
||||
remove(filename)
|
||||
if ret != 0:
|
||||
return
|
||||
|
|
8
backup
8
backup
|
@ -1,18 +1,20 @@
|
|||
#!/usr/bin/fish
|
||||
|
||||
# Create an incremental system backup using bup
|
||||
# Useful resources:
|
||||
# https://gist.github.com/bradfa/a710a4e4b83b07b7a8be77cae86ff56b
|
||||
# https://gist.github.com/jasontbradshaw/6a69d7c9ae0c73f54200
|
||||
|
||||
name=(date -u +'%Y-%m-%d')
|
||||
repository=/mnt/drive/bup/
|
||||
repository=/mnt/drive/bup
|
||||
|
||||
# Set the `bup` directory here so it affects all the `bup` commands.
|
||||
export BUP_DIR=$repository
|
||||
|
||||
# Create the backup repository if it doesn't exist.
|
||||
if test -d $repository
|
||||
bup init
|
||||
chmod 700 $repository
|
||||
bup init
|
||||
chmod 700 $repository
|
||||
end
|
||||
|
||||
# Do the backup as non-intrusively as possible.
|
||||
|
|
6
deluser
6
deluser
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# A wrapper script over ldapdelete
|
||||
|
||||
from sys import argv
|
||||
from subprocess import run
|
||||
|
||||
|
@ -8,8 +10,8 @@ def deluser(username):
|
|||
"""Delete a user"""
|
||||
|
||||
# Delete from LDAP server
|
||||
ldappass = open('/etc/exozyme.conf', 'r').read().split()[0]
|
||||
run(f'ldapdelete -w {ldappass} -D -cn=Manager,dc=exozy,dc=me uid={username},ou=People,dc=exozy,dc=me cn={username},ou=Group,dc=exozy,dc=me'.split())
|
||||
run(['ldapdelete', '-w', open('/etc/ldappass', 'r').read(), '-D', 'cn=Manager,dc=exozy,dc=me',
|
||||
'uid=' + username + ',ou=People,dc=exozy,dc=me', 'cn=' + username + ',ou=Group,dc=exozy,dc=me'])
|
||||
|
||||
# Cleanup
|
||||
run(['sudo', 'rm', '-rf', '/home/' + username])
|
||||
|
|
5
moduser
5
moduser
|
@ -1,5 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# A wrapper script over ldapvi
|
||||
# Requires http://www.lichteblau.com/ldapvi/
|
||||
|
||||
from sys import argv
|
||||
from subprocess import run
|
||||
from ldappass import ldappass
|
||||
|
@ -9,7 +12,7 @@ def moduser(username):
|
|||
"""Modify an existing user"""
|
||||
|
||||
if username == 'Manager':
|
||||
run(['ldapvi', '-w', open('/etc/exozyme.conf', 'r').read().split()[0], '--user', 'cn=Manager,dc=exozy,dc=me'])
|
||||
run(['ldapvi', '-w', open('/etc/ldappass', 'r').read(), '--user', 'cn=Manager,dc=exozy,dc=me'])
|
||||
else:
|
||||
run(['ldapvi', '--user', 'uid=' + username + ',ou=People,dc=exozy,dc=me'])
|
||||
|
||||
|
|
2
pacplot
2
pacplot
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# Graphs the number of installed packages over time by parsing /var/log/pacman.log
|
||||
|
||||
from datetime import datetime
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
|
|
5
setid
5
setid
|
@ -1,13 +1,16 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
# Set up rootless Podman
|
||||
# Set up subuid and subgid for rootless Podman
|
||||
# https://wiki.archlinux.org/title/Podman#Set_subuid_and_subgid
|
||||
|
||||
|
||||
ids = ''
|
||||
for uid in range(1000, 2000):
|
||||
start = uid * 10**5
|
||||
num = 65536 # Allocate 65536 UIDs
|
||||
ids += str(uid) + ':' + str(start) + ':' + str(num) + '\n'
|
||||
|
||||
|
||||
# Save to system files
|
||||
with open('/etc/subuid', 'w') as f:
|
||||
f.write(ids)
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
#!/usr/bin/fish
|
||||
|
||||
# Quickly delete multiple Matrix rooms using synadm
|
||||
# Requires https://github.com/JOJ0/synadm
|
||||
|
||||
for i in $argv
|
||||
echo y | synadm room delete $i
|
||||
end
|
||||
|
|
2
sysusers
2
sysusers
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/fish
|
||||
|
||||
# Compare /usr/lib/sysusers.d and getent passwd to find unneeded users
|
||||
|
||||
for i in (getent passwd | cut -d: -f1)
|
||||
echo -n "$i "; grep -or $i /usr/lib/sysusers.d | wc -l
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue