forked from mxdpeep/linux-bash-scripts
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsvn-create.sh
More file actions
executable file
·70 lines (58 loc) · 1.49 KB
/
svn-create.sh
File metadata and controls
executable file
·70 lines (58 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/bin/bash
# Written by Filip Oščádal <filip@mxd.cz> <http://mxd.cz/>
# Distributed under license GPLv3+ GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY. YOU USE AT YOUR OWN RISK. THE AUTHOR
# WILL NOT BE LIABLE FOR DATA LOSS, DAMAGES, LOSS OF PROFITS OR ANY
# OTHER KIND OF LOSS WHILE USING OR MISUSING THIS SOFTWARE.
# See the GNU General Public License for more details.
# CHANGE THIS TO MATCH YOUR SVN REPOSITORIES LOCATION!
P='/home/svn'
# check syntax
if [ -z "$1" ]
then
echo -e "\nCreates new Subversion repository.\n\nSyntax: $(basename $0) <name>\n"
exit 1
fi
# check for install app
which svnadmin >/dev/null 2>&1
if [ $? -eq 1 ]
then
echo "Installing subversion package..."
sudo apt-get install subversion
fi
which svnadmin >/dev/null 2>&1
if [ $? -eq 1 ]
then
echo -e "Subversion is not installed!\n"
exit 1
fi
# check the path and create folder
if [ -d "$P/$1" ]
then
echo -e "Folder $P/$1 already exists!\n"
exit 1
fi
if [ -d "$P" ]
then
sudo mkdir "$P/$1"
else
echo -e "Invalid folder: $P\n"
exit 1
fi
# setup svn repository
sudo svnadmin create "$P/$1"
sudo chown -R www-data:subversion "$P/$1"
if [ $? -eq 1 ]
then
echo -e "Warning: ownership change failed!\n"
fi
sudo chmod -R g+rws "$P/$1"
# restart Apache
sudo /etc/init.d/apache2 force-reload 2>/dev/null
if [ $? -eq 1 ]
then
echo -e "Warning: is Apache 2 installed?\n"
fi
echo -e "\nDone.\n"
exit 0