37 lines
		
	
	
		
			656 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
			
		
		
	
	
			37 lines
		
	
	
		
			656 B
		
	
	
	
		
			Bash
		
	
	
		
			Executable File
		
	
	
#!/bin/bash
 | 
						|
 | 
						|
if [ $# -ne 2 ] ; then
 | 
						|
    echo "Usage: sudo mem_add <name> <uid>"
 | 
						|
    echo " Create the AlternC account <name> having uid number <uid>"
 | 
						|
    exit 1
 | 
						|
fi
 | 
						|
 | 
						|
name="$1"
 | 
						|
uid="$2"
 | 
						|
 | 
						|
if [[ ! "$name" =~ ^([a-z0-9]+)$ ]] ; then
 | 
						|
  echo "Account name is incorrect."
 | 
						|
  exit 2
 | 
						|
fi
 | 
						|
 | 
						|
 | 
						|
if [[ ! "$uid" =~ ^([0-9]+)$ ]] ; then
 | 
						|
  echo "uid is incorrect."
 | 
						|
  exit 3
 | 
						|
fi
 | 
						|
 | 
						|
if [[ ! "$(id -u)" == "0" ]] ; then
 | 
						|
  echo "please launch mem_add as root (or using sudo)"
 | 
						|
  exit 4
 | 
						|
fi
 | 
						|
 | 
						|
# Get the vars and some functions
 | 
						|
source /usr/lib/alternc/functions.sh
 | 
						|
target="$(get_html_path_by_name "$name")"
 | 
						|
 | 
						|
mkdir -p "$target"
 | 
						|
chmod 2770 "$target"
 | 
						|
/usr/lib/alternc/fixperms.sh -u "$uid"
 | 
						|
 | 
						|
 |