perforceをubuntu serverにinstall
思う処あってubuntu serverにperforceをinstallして暫く運用してみようと思ったのでメモ。
PerforceのサイトからServer用のp4dとp4をdownload(Ubuntu Server 14.04.1 LTSは64bit onlyなので64bit版の物を選択)する。
downloadしたp4d, p4をサーバへアップロード(scpなりなんなり使って)。ホームディレクトリにコピーしたとして、これを$PATHの通ったパスへ移動させ実行権限をつける。
$ sudo mv ~/p4 /usr/local/bin/ $ sudo mv ~/p4d /usr/local/bin/ $ chmod +x /usr/local/bin/p4 /usr/local/bin/p4d
そしてperforce用にユーザとグループを作成。
$ adduser perforce $ addgroup p4admin
ちなみに、 apt-getでもperforceをinstallできる。
$ wget http://package.perforce.com/perforce.pubkey
$ sudo apt-key add perforce.pubkey
$ sudo touch /etc/apt/sources.list.d/perforce.sources.list
/etc/apt/sources.list.d/perforce.sources.list に以下の一行を追加
deb http://package.perforce.com/apt/ubuntu precise release
$ sudo apt-get update $ sudo apt-get install perforce-server
ここまでで、user perforce, group perforceが設定されている.
設定
$ sudo visudo
で
perforce ALL=(ALL:ALL) ALL
とし、perforceユーザをリストに追加する。
sshd_configにperforceユーザをAllowUsersに加える。
$ sudo mkdir /var/log/perforce $ sudo mkdir /perforce_depot # apt-getからinstallした場合 perforceグループが作られるのでそちらを使った方が良いかも $ sudo chown perforce:p4admin /var/log/perforce $ sudo chown perforce:p4admin /perforce_depot
/etc/profile に以下の設定を追記
export P4JOURNAL=/var/log/perforce/journal export P4LOG=/var/log/perforce/p4err export P4PORT=localhost:1666 export P4ROOT=/perforce_depot export P4USER=perforce
追記したら読み込みなおす。
$ source /etc/profile
そして
$ sudo p4d -d -p $P4PORT -r $P4ROOT
でperforce serverが起動する.
このままだと全ユーザが自由にperforceへアクセスできるので、
$ sudo p4 protect
でユーザ権限の設定を行う。
参考
追記
apt-getでinstallした場合はもっと楽だった。
$ sudo /opt/perforce/sbin/configure-perforce-server.sh servername -p 1666 -r /p4/p4-main -u perforce --unicode
とすると、
Server servername not found. Creating... Please provide the following details about your desired Perforce environment: Perforce Server root (P4ROOT) [/p4/p4-main]: Create directory? (Y/n) [Y]: Perforce Server address (P4PORT) [1666]: Perforce super-user login [perforce]: Perforce super-user password: Perforce db files in '/p4/p4-main' will be created if missing... Server switched to Unicode mode. Started servername p4d. Started 1 servers. Creating super-user account... User perforce not changed. Initializing protections table... Protections saved. Setting security level to 3 (high)... Counter security set. Setting password... Enter new password: Re-enter new password: Password updated. Your Perforce server is now configured. You can connect to it using p4 -p 1666 <cmd> For help, run: p4 -p 1666 help
という感じにintractiveに設定できる。 --unicodeを付けるとunicodeモードとしてperforce serverが動く。
usageは以下。
Synopsis: # # configure-perforce-server.sh <name> [options] # # Where options are: # # -p <P4PORT> - Set Perforce Server's address # -r <P4ROOT> - Set Perforce Server's root directory # -u <username> - Perforce super-user login name # -P <password> - Perforce super-user password # --unicode - Enable unicode mode on server # # Password is only needed on initial configuration when the super-user # account is created. If reconfiguring an existing Perforce Server, the # super-user name and password are left alone. # # Unicode mode is disabled by default. Specify --unicode if you # want it. This will change in a future release
追記の追記
ちなみに、apt-getでinstallした場合、perforceユーザのpasswordが設定されていないため、p4 protectが実行できない。そのため、まずはperforceユーザにpasswordを設定する必要がある。その後、p4 protectをperforceユーザとして実行する事で、ユーザのアクセス制御などができるようになる。