2016年05月05日

cpコマンドで強制上書きを行う方法

CentOS7でcpに-fオプションをつけても、何故か上書き確認がされてしまう。

cp -rf /home/hoge /home/fuga

ディレクトリを定期的に丸ごとコピーしたいのにと思ってたら、エイリアスで「cp -i」に置き換えられているとのこと。
最初にバックスラッシュをつけたら、確かにコピーができた。

\cp -rf /home/hoge /home/fuga
参考
タグ:CentOS
posted by MINE at 01:52 | Comment(0) | TrackBack(0) | Linux | このブログの読者になる | 更新情報をチェックする | edit

CentOS7にSphinx1.4.1をpython3でインストールする

ネットを見ていたら、やはりpython2.7で使っているケースが多かったが、インストールしたのがPython3.4なので、この環境でSphinxをインストールする。

結果論からいうと、特に困ったことは無かったけど。

Sphinxをインストール

/usr/local/python-3.4/bin/pip install sphinx

pythonコマンド以外パス通していなかったので、直接pip実行してインストール。

パスを通す

ln -s /usr/local/python-3.4/bin/sphinx-build /usr/local/bin/sphinx-build

sphinx-buildへのパスが通っていないので、そのまま実行するとmakeでコケる。
なのでパスを通す。

動作確認

sphinx-quickstartでプロジェクトを作成する。

# /usr/local/python-3.4/bin/sphinx-quickstart                                                                                       
Welcome to the Sphinx 1.4.1 quickstart utility.

Please enter values for the following settings (just press Enter to
accept a default value, if one is given in brackets).

Enter the root path for documentation.
> Root path for the documentation [.]: 
# ↑ドキュメントのルートパス省略時は今の場所

You have two options for placing the build directory for Sphinx output.
Either, you use a directory "_build" within the root path, or you separate
"source" and "build" directories within the root path.
> Separate source and build directories (y/n) [n]: 
# ↑ソースと、ビルド結果のフォルダを完全に分けるかどうか。
# デフォルトはソースのフォルダ内に_buildディレクトリができる。

Inside the root directory, two more directories will be created; "_templates"
for custom HTML templates and "_static" for custom stylesheets and other static
files. You can enter another prefix (such as ".") to replace the underscore.
> Name prefix for templates and static dir [_]: 
# ↑Sphinxの作るシステムディレクトリの名前の先頭に付く接頭辞。デフォルトは'_'

The project name will occur in several places in the built documentation.
> Project name: Hogehoge Project
> Author name(s): fuga
# ↑プロジェクト名と著者名。入力必須。

Sphinx has the notion of a "version" and a "release" for the
software. Each version can have multiple releases. For example, for
Python the version is something like 2.5 or 3.0, while the release is
something like 2.5.1 or 3.0a1.  If you don't need this dual structure,
just set both to the same value.
> Project version: 1.0.0.0
> Project release [1.0.0.0]: 
# ↑プロジェクトのバージョン。versionは荒く、releaseは細かい。
# versionは必須だけど、releaseはデフォルトでversionと同じものが入る。

If the documents are to be written in a language other than English,
you can select a language here by its language code. Sphinx will then
translate text that it generates into that language.

For a list of supported codes, see
http://sphinx-doc.org/config.html#confval-language.
> Project language [en]: ja
# ↑プロジェクトのサポート文字コード。後でPDF作るためにjaと入力した。

The file name suffix for source files. Commonly, this is either ".txt"
or ".rst".  Only files with this suffix are considered documents.
> Source file suffix [.rst]: 
# ↑ソースファイルのデフォルトの拡張子。デフォルトは.rst。

One document is special in that it is considered the top node of the
"contents tree", that is, it is the root of the hierarchical structure
of the documents. Normally, this is "index", but if your "index"
document is a custom template, you can also set this to another filename.
> Name of your master document (without suffix) [index]: 
# ↑ドキュメントのトップページ(マスター)のファイル名(拡張子なし)。デフォルトは'index'

Sphinx can also add configuration for epub output:
> Do you want to use the epub builder (y/n) [n]: y
# ↑EPUB用の設定ファイルを追加するか?後で試すのでyesにする。

Please indicate if you want to use one of the following Sphinx extensions:
> autodoc: automatically insert docstrings from modules (y/n) [n]: 
> doctest: automatically test code snippets in doctest blocks (y/n) [n]: 
> intersphinx: link between Sphinx documentation of different projects (y/n) [n]: 
> todo: write "todo" entries that can be shown or hidden on build (y/n) [n]: 
> coverage: checks for documentation coverage (y/n) [n]: 
> imgmath: include math, rendered as PNG or SVG images (y/n) [n]: 
> mathjax: include math, rendered in the browser by MathJax (y/n) [n]: 
> ifconfig: conditional inclusion of content based on config values (y/n) [n]: 
> viewcode: include links to the source code of documented Python objects (y/n) [n]: 
> githubpages: create .nojekyll file to publish the document on GitHub pages (y/n) [n]: 
# ↑各種拡張機能をインストールするかどうか。必要なら後で追加できる。

A Makefile and a Windows command file can be generated for you so that you
only have to run e.g. `make html' instead of invoking sphinx-build
directly.
> Create Makefile? (y/n) [y]: 
> Create Windows command file? (y/n) [y]: 
# ↑ビルド用のMakefileとバッチファイルを作るかどうか。デフォルトは作成する。

Creating file ./conf.py.
Creating file ./index.rst.
Creating file ./Makefile.
Creating file ./make.bat.

Finished: An initial directory structure has been created.

You should now populate your master file ./index.rst and create other documentation
source files. Use the Makefile to build the docs, like so:
   make builder
where "builder" is one of the supported builders, e.g. html, latex or linkcheck.

HTMLを生成して正しく動くか確認する。

make html

_build\html\の下にhtmlが生成される。
PDFやePubはまた別記事にする。

関連する記事

  • CentOS7にPython3.4をインストールする[記事]
  • pipを最新版にする [記事]
参考
タグ:CentOS Python Sphinx
posted by MINE at 01:42 | Comment(0) | TrackBack(0) | Python | このブログの読者になる | 更新情報をチェックする | edit

2016年05月04日

pipを最新版にする

以前ソースコードからコンパイルしてインストールしたpipが7.1.1で古かったのでアップデートする。
前回は/usr/local/python-3.4/にインストールしたので、その下にあるpipを叩いてアップデートを行う。

/usr/local/python-3.4/bin/pip install --upgrade pip

関連する記事

  • CentOS7にPython3.4をインストールする[記事]
タグ:CentOS Python
posted by MINE at 01:44 | Comment(0) | TrackBack(0) | Python | このブログの読者になる | 更新情報をチェックする | edit

MattermostをDocker使わずにインストールする

Mattermostをちゃんと動かそうと思って、セットアップしてみる。
やり方は公式ページに書いてあるけど、CentOS7.2とPostgreSQL9.5.2の環境でインストールしてみる。

データベースのインストールと設定

PostgreSQLのリポジトリを設定。

yum install http://yum.postgresql.org/9.5/redhat/rhel-7.2-x86_64/pgdg-redhat95-9.5-2.noarch.rpm

PostgreSQLをインストール

yum install postgresql95-server postgresql95-contrib

初期設定を行う

/usr/pgsql-9.5/bin/postgresql95-setup initdb

自動起動設定と起動を行う。

systemctl enable postgresql-9.5.service
systemctl start postgresql-9.4.service

データベース作成とユーザー作成を行う。

sudo -i -u postgres
psql
postgres=# CREATE DATABASE mattermost;
postgres=# CREATE USER mmuser WITH PASSWORD 'mmuser_password';
postgres=# GRANT ALL PRIVILEGES ON DATABASE mattermost to mmuser;
postgres=# \q
exit

viで設定ファイルを開き、

vi /var/lib/pgsql/9.4/data/postgresql.conf

listen_addressesのコメントアウトを解除して、localhostを*に変更する。

listen_addresses = 'localhost'

続いて、viで設定ファイルを開き、

vi /var/lib/pgsql/9.5/data/pg_hba.conf

同じサーバーにMattermostやPostgreSQLを立てようとするなら、Peer認証をtrustに変えておく。あと、同一サーバーからアクセスるために127.0.0.1をmd5認証に変える。
Peer認証はUNIXのユーザー名と一致していないとログインできない。まぁ、セキュリティ考えたら一致させておいたほうが良いと思うが、テスト用なのでとりあえず。

# "local" is for Unix domain socket connections only
local   all             mmuser                                     trust
host   all             all              127.0.0.1/32                       md5

別サーバーに立てる時は、IPv4 local connectionsの所でホストのIPアドレスを記載する。

host    all             all             10.10.10.10/32            md5

サービスの再起動。

systemctl reload postgresql-9.5.service

うまく設定できたか確認をする。

psql --host=10.10.10.1 --dbname=mattermost --username=mmuser --password
mattermost=> \q

Mattermost Serverのインストールと設定

Mattermostをダウンロードする。

wget https://github.com/mattermost/platform/releases/download/v2.1.0/mattermost.tar.gz

ダウンロードしたファイルを/optに配置する。

tar -xvzf mattermost.tar.gz
mv mattermost /opt

ファイルの保存ディレクトリを作成して、権限を付与する。

mkdir -p /opt/mattermost/data
useradd -r mattermost -U
chown -R mattermost:mattermost /opt/mattermost
chmod -R g+w /opt/mattermost

/opt/mattermost/config/config.jsonをviで開き、以下を変更する。

  • "DriverName"の値の箇所をmysqlからpostgresに変更する
  • "DataSource"の箇所のを書き換える。
DriverName": "postgres"
"DataSource": "postgres://mmuser:password@127.0.0.1:5432/mattermost?sslmode=disable&connect_timeout=10",

無事起動すると下記のように8065のポートでlistenが始まるので、Ctrl-Cで終了させる。

Server is listening on :8065

systemdのサービスを作成する。

touch /etc/systemd/system/mattermost.service
vi /etc/systemd/system/mattermost.service

以下を記述する。

[Unit]
Description=Mattermost
After=syslog.target network.target postgresql-9.5.service

[Service]
Type=simple
WorkingDirectory=/opt/mattermost/bin
User=mattermost
ExecStart=/opt/mattermost/bin/platform
PIDFile=/var/spool/mattermost/pid/master.pid

[Install]
WantedBy=multi-user.target

後はsystemdで再読み込みして、起動&自動起動設定。

systemctl daemon-reload
systemctl start mattermost.service
systemctl enable mattermost.service

http://<サーバーのIPアドレス>:8065/でアクセス。
Webサーバーとの連携は、また別の記事で。

参考
タグ:CentOS Mattermost
posted by MINE at 00:26 | Comment(0) | TrackBack(0) | サーバー技術 | このブログの読者になる | 更新情報をチェックする | edit