forked from syntaxerrormmm/paperms
Support files/scripts created. This has to be integrated with server-config and client-pull-installation.
This commit is contained in:
parent
103e7b3032
commit
6621560b56
1
cronjob
Normal file
1
cronjob
Normal file
@ -0,0 +1 @@
|
|||||||
|
@reboot root /var/lib/{{ ansible_local.domain.domainfull }}/bin/paperms.sh &>> /var/log/paperms.log
|
7
logrotate
Normal file
7
logrotate
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
/var/log/paperms.log {
|
||||||
|
rotate 7
|
||||||
|
daily
|
||||||
|
compress
|
||||||
|
missingok
|
||||||
|
notifempty
|
||||||
|
}
|
34
paperms.sh
Normal file
34
paperms.sh
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Fixing base variables
|
||||||
|
basedir=/var/lib/{{ ansible_local.domain.domainfull }}
|
||||||
|
|
||||||
|
# Making sure destination folder exists.
|
||||||
|
/usr/bin/install -d -o root -g users ${basedir}/bin
|
||||||
|
|
||||||
|
# Update this script itself
|
||||||
|
/usr/bin/wget -q http://{{ ansible_local.domain.serverfqdn }}/ks/preseed/paperms/paperms.sh -O ${basedir}/bin/paperms.sh
|
||||||
|
/bin/chown root:users ${basedir}/bin/paperms.sh
|
||||||
|
/bin/chmod a+x ${basedir}/bin/paperms.sh
|
||||||
|
|
||||||
|
# Updating cronjob
|
||||||
|
/usr/bin/wget -q http://{{ ansible_local.domain.serverfqdn }}/ks/preseed/paperms/cronjob -O /etc/cron.d/paperms
|
||||||
|
/bin/chown root:root /etc/cron.d/paperms
|
||||||
|
/bin/chmod 0644 /etc/cron.d/paperms
|
||||||
|
|
||||||
|
# Removing old versions of the cronjob
|
||||||
|
rm -f /etc/cron.d/pulseaudio-perms
|
||||||
|
|
||||||
|
# Updating logrotate
|
||||||
|
/usr/bin/wget -q http://{{ ansible_local.domain.serverfqdn }}/ks/preseed/paperms/logrotate -O /etc/logrotate.d/paperms
|
||||||
|
/bin/chown root:root /etc/logrotate.d/paperms
|
||||||
|
/bin/chmod 0644 /etc/logrotate.d/paperms
|
||||||
|
|
||||||
|
# Updating updategrp.py
|
||||||
|
/usr/bin/wget -q http://{{ ansible_local.domain.serverfqdn }}/ks/preseed/paperms/updategrp.py -O ${basedir}/bin/updategrp.py
|
||||||
|
/bin/chown root:users ${basedir}/bin/updategrp.py
|
||||||
|
/bin/chmod a+x ${basedir}/bin/updategrp.py
|
||||||
|
|
||||||
|
# Main part: run updategrp.py
|
||||||
|
/usr/bin/python2 ${basedir}/bin/updategrp.py "domain users" "pulse"
|
||||||
|
/usr/bin/python2 ${basedir}/bin/updategrp.py "domain users" "pulse-access"
|
@ -1,5 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python2
|
||||||
|
|
||||||
|
from __future__ import print_function
|
||||||
import grp
|
import grp
|
||||||
import re
|
import re
|
||||||
from subprocess import check_output
|
from subprocess import check_output
|
||||||
@ -30,12 +31,12 @@ class UpdateGrp:
|
|||||||
# If to_add is not empty, add each element to group
|
# If to_add is not empty, add each element to group
|
||||||
if len(self.to_add) > 0:
|
if len(self.to_add) > 0:
|
||||||
for user in self.to_add:
|
for user in self.to_add:
|
||||||
print(check_output(["gpasswd", "-a", user, self.rightname]))
|
print(check_output(["gpasswd", "-a", user, self.rightname]), end='')
|
||||||
|
|
||||||
# If to_remove is not empty, remove each element to group
|
# If to_remove is not empty, remove each element to group
|
||||||
if len(self.to_remove) > 0:
|
if len(self.to_remove) > 0:
|
||||||
for user in self.to_remove:
|
for user in self.to_remove:
|
||||||
print(check_output(["gpasswd", "-d", user, self.rightname]))
|
print(check_output(["gpasswd", "-d", user, self.rightname]), end='')
|
||||||
|
|
||||||
def update_lhs(self):
|
def update_lhs(self):
|
||||||
"""Updates the LHS group members to be equal to the RHS group members."""
|
"""Updates the LHS group members to be equal to the RHS group members."""
|
||||||
@ -46,26 +47,27 @@ class UpdateGrp:
|
|||||||
# If to_remove is not empty, add each element to group
|
# If to_remove is not empty, add each element to group
|
||||||
if len(self.to_remove) > 0:
|
if len(self.to_remove) > 0:
|
||||||
for user in self.to_remove:
|
for user in self.to_remove:
|
||||||
print(check_output(["gpasswd", "-a", user, self.leftname]))
|
print(check_output(["gpasswd", "-a", user, self.leftname]), end='')
|
||||||
|
|
||||||
# If to_add is not empty, remove each element to group
|
# If to_add is not empty, remove each element to group
|
||||||
if len(self.to_add) > 0:
|
if len(self.to_add) > 0:
|
||||||
for user in self.to_add:
|
for user in self.to_add:
|
||||||
print(check_output(["gpasswd", "-d", user, self.leftname]))
|
print(check_output(["gpasswd", "-d", user, self.leftname]), end='')
|
||||||
|
|
||||||
|
|
||||||
def modprint(self):
|
def modprint(self):
|
||||||
"""Debug function to print only modifications."""
|
"""Debug function to print only modifications."""
|
||||||
print("To add:")
|
print("To add: ", end='')
|
||||||
print(self.to_add)
|
print(self.to_add)
|
||||||
print("To remove:")
|
print("To remove: ", end='')
|
||||||
print(self.to_remove)
|
print(self.to_remove)
|
||||||
|
|
||||||
# When run interactively
|
# When run interactively
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
# If the first argument is '--help' or '-h', or number of arguments less than 1 and more than 2, print help.
|
# If the first argument is '--help' or '-h', or number of arguments less than 1 and more than 2, print help.
|
||||||
if len(argv) < 2 or len(argv) > 3 or argv[1] == '--help' or argv[1] == '-h':
|
if len(argv) < 2 or len(argv) > 3 or argv[1] == '--help' or argv[1] == '-h':
|
||||||
print("Usage: %s <group1> <group2>" % argv[0])
|
print("Usage: %s <LHSgroup> <RHSgroup>" % argv[0])
|
||||||
|
print("Aligns RHS group members as LHS.")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
updgrp = UpdateGrp(argv[1], argv[2])
|
updgrp = UpdateGrp(argv[1], argv[2])
|
Loading…
x
Reference in New Issue
Block a user