Skip to content

Instantly share code, notes, and snippets.

@jacobsalmela
Created March 3, 2015 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobsalmela/6a35aed20667c718f336 to your computer and use it in GitHub Desktop.
Save jacobsalmela/6a35aed20667c718f336 to your computer and use it in GitHub Desktop.
Create users via the JSS based on the computer name.
#!/usr/bin/python
#----------AUTHOR------------
# Jacob Salmela
# 20 February 2014
# Updated: 2014-12-11
#-----------IMPORTS----------
from os import system
from subprocess import call
from socket import gethostname
from time import sleep
#----------VARIABLES---------
computer_name = gethostname().split('-')
# [Username, Real Name, Password]
student_user = ["student", "student", "password"]
testing_user = ["testing", "testing", "password"]
user_graphics = ["graphics", "graphics", "password"]
user_music_one = ["hmusic", "music", "password"]
user_vid_one = ["video", "video", "password"]
#----------FUNCTIONS---------
#######################
def create_user(user):
call(["/usr/sbin/jamf", "createAccount", "-username", user[0], "-realname", user[1], "-password", user[2]])
########################
def create_base_users():
# This user will always get created
create_user(student_user)
########################
def no_user_needed():
print "**No additional users required"
####################################
def create_all_users():
create_base_users()
if (computer_name[2] == "S200"):
create_user(user_vid_one)
elif (computer_name[2] == "W202"):
create_user(user_graphics)
elif (computer_name[2] == "W114"):
create_user(user_graphics)
elif (computer_name[2] == "E123"):
create_user(user_music_one)
create_user(testing_user)
else:
no_user_needed()
#------------------------------
#-------BEGIN SCRIPT-----------
#------------------------------
create_all_users()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment