Exam users uid always changes, therefore their home directory must be deleted
This commit is contained in:
		
							parent
							
								
									3ff31771f7
								
							
						
					
					
						commit
						99d7bd64db
					
				
					 3 changed files with 30 additions and 0 deletions
				
			
		
							
								
								
									
										6
									
								
								roles/lmn_localhome/files/rmexam.service
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								roles/lmn_localhome/files/rmexam.service
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,6 @@
 | 
			
		|||
[Unit]
 | 
			
		||||
Description=Remove -exam homes older than 12h
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
Type=simple
 | 
			
		||||
ExecStart=find /home/ -maxdepth 1 -mindepth 1 -name '*-exam' -type d -cmin +720 -exec rm -rf {} \;
 | 
			
		||||
							
								
								
									
										8
									
								
								roles/lmn_localhome/files/rmexam.timer
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								roles/lmn_localhome/files/rmexam.timer
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
				
			
			@ -0,0 +1,8 @@
 | 
			
		|||
[Unit]
 | 
			
		||||
Description=Run rmexam after boot
 | 
			
		||||
 | 
			
		||||
[Timer]
 | 
			
		||||
OnBootSec=0min
 | 
			
		||||
 | 
			
		||||
[Install]
 | 
			
		||||
WantedBy=timers.target
 | 
			
		||||
| 
						 | 
				
			
			@ -33,3 +33,19 @@
 | 
			
		|||
    dest: /etc/profile.d/lmn-logout.sh
 | 
			
		||||
    content: |
 | 
			
		||||
      [[ "${UID}" -gt 10000 ]] && ! findmnt "/lmn/media/${USER}/home" > /dev/null && exit 0
 | 
			
		||||
 | 
			
		||||
- name: Provide rmexam services and timers for some scripts
 | 
			
		||||
  copy:
 | 
			
		||||
    src: "{{ item }}"
 | 
			
		||||
    dest: "/etc/systemd/system/{{ item }}"
 | 
			
		||||
    mode: 0644
 | 
			
		||||
  loop:
 | 
			
		||||
    - rmexam.service
 | 
			
		||||
    - rmexam.timer
 | 
			
		||||
  when: "'teacherlaptop' not in group_names"
 | 
			
		||||
 | 
			
		||||
- name: Enable rmexam.timer
 | 
			
		||||
  systemd:
 | 
			
		||||
    name: rmexam.timer
 | 
			
		||||
    enabled: true
 | 
			
		||||
  when: "'teacherlaptop' not in group_names"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue