自動化建立使用者

2021-10-14 01:33:31 字數 3030 閱讀 2777

首先建立shell指令碼 create_sharefile.sh

如下是shell指令碼的內容,可以在超級管理員賬戶建立

./create*.sh 名字 學位 入學時間

傳入了三個引數 名字、學位和入學時間

$1,$2,$3

該指令碼包含如下部分

#./create*.sh username degree year

#./create*.sh lus phd 2020

user_count=

`cat /etc/passwd |

grep ^$1: -c`

user_name=

$1degree=

$2years=

$3if

[$user_count -ne 1 ]

then

useradd -g public -s /bin/bash -d /data/users/$ -m $user_name

echo

$user_name

:$207 | chpasswd

echo

"user $user_name added!"

else

echo

'user exits'

fi# setting of conda

echo'''

export cuda_visible_devices=0

# <<< conda init <<<

chgrp public /data/students/$degree/$years/$user_name -r

chgrp public /data/users/$user_name/myproject -r

# rwx

chmod -r u=rwx,g=r,o=r /data/students/$degree/$years/$user_name

chmod -r u=rwx,g=r,o=r /data/users/$user_name/myproject

export cuda_visible_devices=0

# <<< conda init <<<

# >>> conda initialize >>>

# !! contents within this block are managed by 'conda init' !!

__conda_setup="$(

'/data/anaconda3/bin/conda'

'shell.bash'

'hook' 2> /dev/null)

"if [ $? -eq 0 ]; then

eval "$__conda_setup"

else

if [ -f "/data/anaconda3/etc/profile.d/conda.sh" ]; then

. "/data/anaconda3/etc/profile.d/conda.sh"

else

export path="/data/anaconda3/bin:$path"

fifiunset __conda_setup

# <<< conda initialize <<<'''

>> /data/users/$user_name/.bashrc

#link data to myproject

mkdir -p /data/students/$degree/$years/$user_name

ln -s /data/students/$degree/$years/$user_name /data/users/$user_name/myproject

#modify users

chown -r $user_name /data/students/$degree/$years/$user_name

chown -r $user_name /data/users/$user_name/myproject

#modify group

chgrp public /data/students/$degree/$years/$user_name -r

chgrp public /data/users/$user_name/myproject -r

# rwx

chmod -r u=rwx,g=r,o=r /data/students/$degree/$years/$user_name

chmod -r u=rwx,g=r,o=r /data/users/$user_name/myproject

第二步、為每個使用者建立共享檔案

#./create*.sh username degree year

#./create*.sh lus phd 2020

user_name=

$1#degree=$2

#years=$3

#link data to share_file

sudo

ln -s /data/students/share_files /data/users/$user_name/share_files

#modify users

sudo

chown -r public /data/students/share_files

sudo

chown

$user_name /data/users/$user_name/share_files

#modify group

sudo

chgrp public /data/students/share_files -r

sudo

chgrp public /data/users/$user_name/share_files -r

# rwx

sudo

chmod -r u=rwx,g=rwx,o=--- /data/students/share_files

sudo

chmod u=rwx,g=rx,o=--- /data/users/$user_name/share_files

Puppet 使用者自動化管理

三 使用者和組 使用者資源 user 該資源型別用於管理系統使用者 所以缺少一些特性來管理普通使用者。利用 符合posix api 標準的puppet 自帶的私有工具來進行使用者和組管理 puppet 不會直接修改 etc passwd 檔案。引數 allowdupe 是否允許存在同樣的使用者 可以...

利用jmeter 自動化建立資料

這個版本有個需求,是需要乙個申請列表的,但乙個人只能申請一次,所以測到具有多條 20條 申請列表該如何是好,難道真的要登陸20個賬號來乙個個申請嗎?當然不用,咱們的jmeter工具可以搞定!1 準備20個未註冊過的賬號 就算有已經註冊過的也能通過跑jmeter指令碼也能篩選出來 寫到csv檔案,如 ...

自動化建立OSS NAS資料卷

資料卷的基本介紹參考 阿里雲oss資料卷介紹 阿里雲nas資料卷介紹 控制台建立資料卷參考 openapi 通過api建立集群後,獲得集群id 參考 openapi 通過集群id獲取集群資訊,從中獲取集群的接入點url master url 參考 openapi 通過集群id獲取證書,參考 實現下面...