32 lines
		
	
	
	
		
			651 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
		
		
			
		
	
	
			32 lines
		
	
	
	
		
			651 B
		
	
	
	
		
			Bash
		
	
	
	
	
	
|   | #!/bin/bash
 | ||
|  | 
 | ||
|  | # This file is part of VM-Experiments. | ||
|  | # Licensed under the GPL-3.0-or-later. See LICENSE for details. | ||
|  | 
 | ||
|  | trap '' SIGINT SIGTERM | ||
|  | 
 | ||
|  | while true; do | ||
|  |     read -p "Enter a username (lowercase letters, digits, underscores and hyphens): " username | ||
|  |     chroot /mnt /bin/bash -c "useradd -m '$username'" | ||
|  | 
 | ||
|  |     if [ $? -eq 0 ]; then | ||
|  |         break | ||
|  |     fi | ||
|  | done | ||
|  | 
 | ||
|  | while true; do | ||
|  |     chroot /mnt /bin/bash -c "passwd '$username'" | ||
|  | 
 | ||
|  |     if [ $? -eq 0 ]; then | ||
|  |         break | ||
|  |     fi | ||
|  | done | ||
|  | 
 | ||
|  | while true; do | ||
|  |     read -p "Enter the hostname: " hostname | ||
|  |     chroot /mnt /bin/bash -c "echo $hostname > /etc/hostname" | ||
|  | 
 | ||
|  |     if [ $? -eq 0 ]; then | ||
|  |         break | ||
|  |     fi | ||
|  | done |