我是一所小型艺术学校的新摄影技术员,负责一个小型 Mac 实验室。不幸的是,我们的 IT 部门。不提供对 mac 的直接支持(仅网络),所以我必须卷起袖子,边走边学。
该实验室多年来一直作为所有机器上的单一托管登录(无密码)运行,这造成了很多困难,但我正在努力将其更改为接受 Active Directory 凭据的模型,创建一个新用户在飞行中。注销时,该用户帐户将被销毁,以使每个会话之间的用户环境正常化。
缺点是对于少数在特定站点重复工作的学生来说,他们创建的任何文件当然都会被销毁。作为一种解决方法,我想创建一个登录脚本,为他们创建一个安全的地方来将他们的文件保存在分区驱动器上,并将该目录的权限设置为仅对除管理员之外的所有其他用户写入。
我已经把大部分内容拼凑在一起了——但我真的很喜欢我的上司的一般反馈(我在这里做的任何事情都是不明智的)以及关于如何设置权限的指导,因为我在这里所拥有的似乎不起作用,坦率地说,我对 UNIX 权限的来龙去脉只是大致了解。
我已将其设置为具有执行权限的 .command 文件以对其进行测试 - 文件夹和别名按预期创建,但所有者/组设置未采用。- 所有者是我的管理员帐户,该组仍然是“员工”。我还设置了一个“测试”用户和一个学生组。
非常感谢您的想法。
#!/bin/bash
# Create a safe place for users to save their files
# We will destroy this directory if it's empty on log out
# Using sudo for the time being for testing, wont have to when it's run at login by root
# Dont run if user is admin
if [ `whoami` == "comdesadmin" ]; then
exit 1
fi
if [ `whoami` != "comdesadmin" ]; then
#User name
USERNAME="test";
#USERNAME=`whoami` ;
# Group name
USERGROUP=student;
#Set direcory path
USERSAFEFOLDER=/Volumes/nest/$USERNAME
# Create the directory for the user if it isn't there
# user names shouldn't have any spaces so this should be ok
mkdir -p $USERSAFEFOLDER;
# Set the ownership to the current users (as this be being run by root)
sudo chown -R guest $USERSAFEFOLDER;
# Set the group
sudo chgrp $USERGROUP $USERSAFEFOLDER;
# Set write only to everyone else
chmod 700 $USERSAFEFOLDER;
# Make alias on the desktop for them
osascript <<END_SCRIPT
tell application "Finder"
make new alias to folder (posix file "$USERSAFEFOLDER") at desktop
end tell
END_SCRIPT
echo "Sucess";
fi
exit 0