1.搭建ssh服务器
sudo apt-get install openssh-server
安装完成即可使用
2.搭建samba
安装samba:
sudo apt-get install samba
配置:
修改/etc/smb.conf
在smb.conf的最后添加新用户即可:
[hello]
comment = samba
path = /home/hello/work/share
browseable = yes
guest ok = no
writeable = yes
其中,[hello]是用户名,
path是samba服务器共享目录。
browseable = yes和writeable = yes表明可写可浏览。
添加用户,设置密码:
sudo smbpasswd -a hello
设置完成后启动samba服务器即可。
测试
在windows中的文件浏览器中输入\server\即可看到hello用户,点击输入用户名和密码即可完成访问:
samba服务器的操作
启动samba服务器:
/etc/init.d/samba start
重启:
/etc/init.d/samba restart
查询状态
/etc/init.d/samba status
停止:
/etc/init.d/samba stop
配置为开机自启动
第一步:
在/etc/init.d新建samba.sh脚本
内容如下:
#!/bin/sh
### BEGIN INIT INFO
# Provides: samba.sh
# Required-start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the svnd.sh daemon
# Description: starts svnd.sh using start-stop-daemon
### END INIT INFO
/etc/init.d/samba start
第二步:
执行update-rc.d samba.sh defaults
取消svn开机自启动
执行:update-rc.d -f samba.sh remove
3.搭建svn服务器
安装subversion
sudo apt-get install subversion
创建svn仓库
svnadmin create /xxx/xxxx
第二步:配置
配置三个文件:
1.svnserve.conf
打开所示四项注释,并将anon-access = read改为anon-access = none 。
[general]
### The anon-access and auth-access options control access to the
### repository for unauthenticated (a.k.a. anonymous) users and
### authenticated users, respectively.
### Valid values are "write", "read", and "none".
### Setting the value to "none" prohibits both reading and writing;
### "read" allows read-only access, and "write" allows complete
### read/write access to the repository.
### The sample settings below are the defaults and specify that anonymous
### users have read-only access to the repository, while authenticated
### users have read and write access to the repository.
anon-access = none
auth-access = write
### The password-db option controls the location of the password
### database file. Unless you specify a path starting with a /,
### the file's location is relative to the directory containing
### this configuration file.
### If SASL is enabled (see below), this file will NOT be used.
### Uncomment the line below to use the default password file.
password-db = passwd
### The authz-db option controls the location of the authorization
### rules for path-based access control. Unless you specify a path
### starting with a /, the file's location is relative to the
### directory containing this file. The specified path may be a
### repository relative URL (^/) or an absolute file:// URL to a text
### file in a Subversion repository. If you don't specify an authz-db,
### no path-based access control is done.
### Uncomment the line below to use the default authorization file.
authz-db = authz
2.passwd
在user后增加“姓名 = 密码”即可
### This file is an example password file for svnserve.
### Its format is similar to that of svnserve.conf. As shown in the
### example below it contains one section labelled [users].
### The name and password for each user follow, one account per line.
[users]
# harry = harryssecret
# sally = sallyssecret
aaa = 11223344
bbb = 123456
3.authz
在[groups]下添加分组信息,然后在[/]目录下添加用户和组的访问权限即可:
如:
[groups]
# harry_and_sally = harry,sally
# harry_sally_and_joe = harry,sally,&joe
admin = aaa,bbb
[/]
@admin = rw
组前面必须加@符号。
启动svn 服务器:
svnserve -d -r /xxx
测试
ubuntu下执行:
svn co svn://svnserver/repo
比如:
svn co svn://192.168.1.100/
完整举例:
首先创建目录:
cd /
mkdir svn
cd svn
mkdir repo1
mkdir reop2
其次,创建仓库
svnadmin create /svn/repo1
svnadmin create /svn/repo2
然后分别按照前面所述,配置repo1和repo2的conf/passwd.conf/authz,conf/svnservse.conf三个文件。
然后启动svn服务器:
执行
svnserve -d -r /svn
注意是/svn,而不是/svn/repo1。。。
最后测试:
执行svn co svn://192.168.1.100/repo1
windows下可安装tortoiseSVN来访问svn服务器。
制作开机自启动脚本
第一步:
在/etc/init.d下新建svnd.sh脚本,内容如下:
#!/bin/sh
### BEGIN INIT INFO
# Provides: svnd.sh
# Required-start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the svnd.sh daemon
# Description: starts svnd.sh using start-stop-daemon
### END INIT INFO
svnserve -d -r /svn
第二步:
执行update-rc.d svnd.sh defaults
重启即可
取消svn开机自启动
执行:update-rc.d -f svnd.sh remove
出现的问题
问题一
svn add 还是 svn st 均查看不到想要提交的 .so .o等文件,这是因为svn服务器的配置中把.so .o等文件给屏蔽了。
修改步骤如下:
1.打开.subversion/config
2.用###注释掉以下语句,保存原始记录,方便以后查看
# global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo
# *.rej *~ #*# .#* .*.swp .DS_Store
即改为
### global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo
### *.rej *~ #*# .#* .*.swp .DS_Store
3.在上面注释掉语句下行增加:
global-ignores = .*.swp .DS_Store
4.保存config即可。
这样就可以提交so等文件了。
问题二
build/core/base_rules.mk:130: * libcore: MODULE.TARGET.ETC.target-cacert-d16a5865.0.svn-base already defined by libcore。 停止。
svn 版本太低,升级svn。
解决办法,升级svn
1. 在/etc/apt/sources.list添加ppa的源,可以在末尾添加如下内容:
1.7.*版本使用如下
deb http://ppa.launchpad.net/svn/ppa/ubuntu precise main
1.8.* 使用如下
deb http://ppa.launchpad.net/dominik-stadler/subversion-1.8/ubuntu/ precise main
更新仓库
sudo apt-get update
【更新时出错】W: GPG error: http://ppa.launchpad.net precise Release: The following signatures couldn’t be verified because the public key is not available: NO_PUBKEY xxxxxxxxxxxxxxxx
【解决办法】
sudo apt-key adv –keyserver keyserver.ubuntu.com –recv-keys xxxxxxxxxxxxxxxx
sudo apt-get update安装svn
sudo apt-get install subversion subversion-tools查看svn版本,ubuntu 默认版本是1.6
svn –version
svn, version 1.8.*
问题三
不能打开文件“/svn/repos/doc/db/txn-current-lock”: 权限不够
解决办法:
chmod -R o+rw /home/svn
(权限问题,加上权限就可以啦)
之后再重启:
先停止svn服务器:
sudo killall svnserve
然后再重启
svnserve -d -r /svn