描述:之前的svn系统是(svn+trac)每个项目有单独的auth文件,迁移到USVN是共用一个auth文件
操作流程:
1.获取请求信息(参看USVN批量添加用户组)
2.提取清洗svn+trac每个项目auth文件的所有用户
3.python脚本实现批量提交
#1.获取请求信息(参看USVN批量添加用户组)
略
#2.提取清洗svn+trac每个项目auth文件的所有用户
[root@110]# pwd
/db/svn
[root@110]# cat */conf/authz |sed '/^@/d'|sed '/^\[/d'|sed 's# ##g'|sed 's#,#\n#g'|sed '/^#/d'|sed '/=$/d'|sed 's#^[a-Z]*=##g'|sed 's#=.*##g'|sed '/^[ ]*$/d'|sort |uniq|grep -P '\.'
#3.python脚本实现批量提交
import requests
import time
headers={
"Host":"svn.xurikeji.net:8087",
"Referer":"http://svn.xurikeji.net:8087/admin/user/new",
"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0",
"Content-Type":"application/x-www-form-urlencoded",
"Cookie":"experimentation_subject_id=IjBiNDgxZTMzL12d1dwad32fsdf2qfcqe3f3vfrg3g3RjY2NkMzFkZTI5YiI%3D--29bff0b0d99f157wf32rd1fdsf32f1df21cbf0; PHPSESSID=r0u3f3qde2f2d1du4jrh8hu"
}
#response=requests.get(url,headers=headers,cookies=cookie_dict)
#print(response)
with open(r'D:\xia.haha\桌面\user1.txt','r+') as file:
for line in file:
payload={"users_login":line.strip("\n"),"users_password":line.strip("\n"),"users_password2":line.strip("\n"),"users_lastname":"","users_firstname":"","users_email":"","users_is_admin":"0","submit":"提交"}
response=requests.post("http://svn.xurikeji.net:8087/admin/user/create",data=payload,headers=headers)
print("%s 用户已被成功添加!" % line.strip("\n"))
print("============================================================================================")
time.sleep(3)
print("所有用户添加完成!")