Created
August 30, 2020 11:16
-
-
Save kencoba/b7134d1fa3028b7ea92f6bb5f850e0ef to your computer and use it in GitHub Desktop.
(Experimental) adding user to Subversion.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: | |
# $ sudo ruby ./svnadmin.rb #{account} #{password} | |
account=ARGV[0] | |
password=ARGV[1] | |
# create user account. | |
system "sudo adduser --gecos ',,,' --disabled-login --quiet #{account}" | |
puts "result of adduser" | |
system "cat /etc/passwd | grep #{account}" | |
# add user to group. This is for local commit ("file:///"). | |
system "sudo usermod -aG www-data #{account}" | |
puts "result of usermod" | |
system "cat /etc/group | grep www-data" | |
# add password for apache2. | |
system "echo #{password} | sudo htpasswd -i /etc/apache2/dav_svn.passwd #{account}" | |
puts "result of htpasswd" | |
system "cat /etc/apache2/dav_svn.passwd | grep #{account}" | |
# add svn password. | |
# Premise: passwd file is ended with "[users]" | |
passwd_file = File.open('/var/lib/svn/repo/conf/passwd','a') | |
passwd_file.puts "#{account} = #{password}" | |
passwd_file.close | |
puts "result of adding entry into /var/lib/svn/repo/conf/passwd" | |
system "tail /var/lib/svn/repo/conf/passwd" | |
# add authentication for repository. | |
authz_file = File.open('/var/lib/svn/repo/conf/authz','a') | |
authz_file.puts <<EOF | |
[repo:#{account}] | |
#{account} = rw | |
EOF | |
puts "result of adding entry into /var/lib/svn/repo/conf/authz" | |
system "tail /var/lib/svn/repo/conf/authz" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment