Naptify Server 1.1.6  (linux / x86_64)
======================================================================

日本語の説明のあとに、英語の説明があります。
English follows the Japanese text.


■ 概要

Naptify Server（naptify-server）は、OpenNap 互換のファイル共有サーバーです。
実行ファイル 1 つで動作し、画面を持たないデーモンとして systemd から起動します。初回起動時に設定・データベース・ログ用のフォルダーを自動で作成します。
管理は、ブラウザーで表示する管理画面で行います。


■ 主な機能

・FaceNap からの移行: FaceNap の設定・登録ユーザー・BAN・チャンネル等を取り込み。移行後もクライアント設定の変更不要。
・リンク: FaceNap・SlavaNap を含む既存ネットワークに参加。登録ユーザー・BAN・ポイントを完全同期。
・ギルド: 運用者が異なるサーバー間で会話・検索・転送を中継。運用ルールは各サーバーで個別管理。
・Web 管理画面: 設定・オンラインユーザー・登録ユーザー・BAN を管理。9 言語対応。既定は localhost のみ公開。
・外部接続確認: UPnP でポート開放。D-DNS.JP で外部からの到達確認、外向き IP アドレスを取得。
・バックアップ: 定期バックアップ、世代管理。管理画面から復元。PC 移行時の取り込みに対応。
・利用承諾: ログイン時に利用規約を提示し、IM の返信で承諾を確認。承諾まで検索・参照・ダウンロードを制限。
・ポイント: 検索・ダウンロード等に応じてポイントを増減。サーバーごとに設定。
・リダイレクトポート: 接続窓口を一元化し、空きのあるサーバーへ自動で振り分け。
・マルチログイン: 同じ登録ユーザーで複数の端末から同時にログイン（既定は無効）。サーバーからの通知は全端末に配信。


■ 版と対象

版: 1.1.6
OS・アーキテクチャ: linux / x86_64
（x86_64 は x64 版、aarch64 は ARM64 版です）


■ 動作環境

Linux（x86_64・ARM64）、glibc 2.17 以降、systemd
お使いの環境に合った tar.gz ファイルを使ってください。


■ インストールの手順（root で実行します）

1. tar.gz ファイルを展開し、展開したフォルダーへ移ります。
     tar -xzf naptify-server-1.1.6-linux-x86_64.tar.gz
     cd naptify-server-1.1.6-linux-x86_64
2. サーバー専用のユーザー naptify を作ります。
     useradd --system --user-group --no-create-home --shell /usr/sbin/nologin naptify
3. 実行ファイルを置きます。
     install -m 0755 naptify-server /usr/local/bin/naptify-server
4. データの置き場 /var/lib/naptify-server を作り、言語ファイルを写します。
     install -d -o naptify -g naptify -m 0700 /var/lib/naptify-server /var/lib/naptify-server/languages
     install -o naptify -g naptify -m 0600 languages/*.lng /var/lib/naptify-server/languages/
   ユニットの StateDirectory= は systemd 235 以降でだけ働きます（CentOS・RHEL 7 の 219 では置き場が作られず、起動できません）。新しい systemd では、ここで作った置き場を確かめるだけです。
5. systemd のユニットの見本を置き、有効にして起動します。
     install -m 0644 naptify-server.service /etc/systemd/system/naptify-server.service
     systemctl daemon-reload
     systemctl enable --now naptify-server


■ 更新の手順（root で実行します）

新しい版の tar.gz ファイルを展開し、展開したフォルダーで実行します。データ（/var/lib/naptify-server）はそのまま使います。
     systemctl stop naptify-server
     install -m 0755 naptify-server /usr/local/bin/naptify-server
     install -o naptify -g naptify -m 0600 languages/*.lng /var/lib/naptify-server/languages/
     systemctl start naptify-server


■ 管理画面

既定では、サーバーの機械の中（127.0.0.1:38080）からのみ表示できます。
手元の PC からは、SSH のポート転送を使います。
     ssh -L 38080:127.0.0.1:38080 <ユーザー名>@<サーバーの名前>
接続したまま、手元のブラウザーで http://127.0.0.1:38080/ を開きます。


■ 起動・停止とログ

  systemctl start naptify-server       起動
  systemctl stop naptify-server        停止（接続中のユーザーは切断されます）
  systemctl status naptify-server      状態
  journalctl -u naptify-server         サーバーの出力（起動・停止・エラー）
  /var/lib/naptify-server/logs/        ログファイル

チャットの >server restart では、サーバーが終了コード 75 で終わり、systemd が起動し直します（ユニットの RestartForceExitStatus=75）。
>server reboot（OS の再起動）は、サーバーが root の権限を持たないため実行されません。

1024 未満のポートで待ち受けるときは、/etc/systemd/system/naptify-server.service の「#AmbientCapabilities=CAP_NET_BIND_SERVICE」の先頭の # を外し、systemctl daemon-reload のあとに起動し直します（AmbientCapabilities= は systemd 229 以降）。


■ 管理画面のパスワードを忘れたとき

サーバーを止めてから、naptify のユーザーで実行します（データの置き場の持ち主と違うユーザーで実行すると断ります）。
     systemctl stop naptify-server
     sudo -u naptify /usr/local/bin/naptify-server reset-admin-password
     systemctl start naptify-server
管理画面のユーザー名とパスワードが消え、管理画面へのアクセスが「この PC のみ・パスワード無し」に戻ります。


■ 同梱ファイル

naptify-server-1.1.6-linux-x86_64/
  naptify-server
      サーバー本体
  languages/
      日本語・英語以外の言語ファイル（de, es, fr, ko, pt-BR, uk, zh-CN）
  naptify-server.service
      systemd のユニットの見本
  README.txt
      このファイル

日本語と英語はサーバーに組み込まれています。/var/lib/naptify-server/languages に置いた言語ファイル（.lng）の言語は、管理画面の言語の一覧に表示されます。


■ データの置き場

データは /var/lib/naptify-server に保存されます（serve の --data-root で変えられます）。初回起動時に次のものが作成されます。

  main.sqlite   設定・ユーザー・監査記録・統計などのデータベース
  logs/         ログファイル
  backups/      データベース（main.sqlite）のバックアップ
  state/        復元・取り込みの作業用

このほか、作業用のファイル（.naptify.lock、main.sqlite-wal など）が作成されます。作成されるファイルは、サーバーのユーザーだけが読み書きできます。
データの置き場がほかのユーザーの持ち物のとき、またはグループ・ほかのユーザーに権限があるときは、起動を断ります（直し方は journalctl -u naptify-server に表示されます。例: chmod 700 /var/lib/naptify-server）。
ログイン中のユーザーの共有ファイル情報は /var/tmp/naptify-server（systemd の PrivateTmp により、このサービス専用の場所）に置かれ、正常に終了すると削除されます。
systemd を使わずに動かすときは、ほかのユーザーが動かして残した /var/tmp/naptify-server を削除してから動かしてください（持ち主の違うフォルダーは使わず、共有ファイル情報と検索が使えなくなります）。
FaceNap から取り込むときは、取り込み元のフォルダーを naptify のユーザーが読めるようにしてください。取り込み元は /tmp・/var/tmp 以外に置いてください（PrivateTmp のため、サービスからは見えません）。


■ 更新の確認

新しいバージョンが公開されているかを確かめるため、定期的に配布サイト（https://naptify.net/）へ問い合わせます。
送信するのは製品名・バージョン・OS・CPU の 4 項目だけです。ホスト名・表示名、ユーザー数、共有ファイル数は送信しません。
新しいバージョンがあるときは、管理画面でお知らせします。ダウンロードと入れ替えは自動では行いません。

確認を止めるときは、管理画面の「設定」→「運用」→「更新の確認」で「新しいバージョンを自動で確認する」のチェックを外し、「保存」を押します。


■ アンインストール（root で実行します）

1. サーバーを止め、登録を解除します。
     systemctl disable --now naptify-server
     rm /etc/systemd/system/naptify-server.service /usr/local/bin/naptify-server
     systemctl daemon-reload
2. データも削除するときは、/var/lib/naptify-server を削除し、ユーザー naptify を削除します（userdel naptify）。
   残したいデータは、先に別の場所へコピーしてください。


■ 関連ページ

ダウンロード: https://naptify.net/server/download/
利用規約: https://naptify.net/terms/
サポート（不具合報告・機能要望）: https://naptify.net/support/


■ 開発者

MASA AMIYA
連絡先: info@naptify.net


======================================================================

■ Overview

Naptify Server (naptify-server) is an OpenNap-compatible file-sharing server.
It runs as a single executable, as a daemon without a GUI started by systemd, and creates its settings, database and log folders automatically on first launch.
You manage it from the admin page in your web browser.


■ Main features

- Migration from FaceNap: Imports FaceNap settings, registered users, bans, channels, and more. After migration, users can connect with their existing client settings.
- Link: Joins existing networks, including FaceNap and SlavaNap servers. Registered users, bans, and points are fully synchronized.
- Guild: Relays chat, search, and transfers between servers run by different operators. Each server keeps its own operating rules.
- Web admin page: Manages settings, online users, registered users, and bans. Available in 9 languages. Accessible from localhost only by default.
- External connection check: Opens ports with UPnP. Checks reachability from outside and obtains the external IP address through D-DNS.JP.
- Backup: Scheduled backups with multiple generations. Restore from the admin page, or import your data when moving to another PC.
- Terms acceptance: Shows your terms of use at login and confirms acceptance through an IM reply. Search, browsing, and downloads are restricted until the user accepts.
- Points: Points increase or decrease with searches, downloads, and other actions. Configured per server.
- Redirect ports: A single entry point for connections, with automatic distribution to servers that have capacity.
- Multi-login: The same registered user can log in from several devices at once (off by default). Server notices are delivered to every device.


■ Version and platform

Version: 1.1.6
OS / architecture: linux / x86_64
(x86_64 is the x64 build, and aarch64 is the ARM64 build.)


■ System requirements

Linux (x86_64, ARM64) with glibc 2.17 or later, and systemd
Use the tar.gz file that matches your system.


■ Installing (run as root)

1. Extract the tar.gz file and change to the extracted folder.
     tar -xzf naptify-server-1.1.6-linux-x86_64.tar.gz
     cd naptify-server-1.1.6-linux-x86_64
2. Create the dedicated user naptify for the server.
     useradd --system --user-group --no-create-home --shell /usr/sbin/nologin naptify
3. Install the executable.
     install -m 0755 naptify-server /usr/local/bin/naptify-server
4. Create the data root /var/lib/naptify-server and copy the language files.
     install -d -o naptify -g naptify -m 0700 /var/lib/naptify-server /var/lib/naptify-server/languages
     install -o naptify -g naptify -m 0600 languages/*.lng /var/lib/naptify-server/languages/
   StateDirectory= in the unit works only with systemd 235 or later (with systemd 219 of CentOS and RHEL 7, the data root is not created and the server cannot start). Newer systemd only checks the data root created here.
5. Install the systemd unit sample, then enable and start it.
     install -m 0644 naptify-server.service /etc/systemd/system/naptify-server.service
     systemctl daemon-reload
     systemctl enable --now naptify-server


■ Updating (run as root)

Extract the tar.gz file of the new version and run the following in the extracted folder. Your data (/var/lib/naptify-server) is kept as is.
     systemctl stop naptify-server
     install -m 0755 naptify-server /usr/local/bin/naptify-server
     install -o naptify -g naptify -m 0600 languages/*.lng /var/lib/naptify-server/languages/
     systemctl start naptify-server


■ Admin page

By default, the admin page can be opened only from the server machine itself (127.0.0.1:38080).
From your own PC, use SSH port forwarding.
     ssh -L 38080:127.0.0.1:38080 <user>@<server>
While connected, open http://127.0.0.1:38080/ in the browser on your PC.


■ Starting, stopping and logs

  systemctl start naptify-server       Start
  systemctl stop naptify-server        Stop (connected users are disconnected)
  systemctl status naptify-server      Status
  journalctl -u naptify-server         Server output (start, stop and errors)
  /var/lib/naptify-server/logs/        Log files

The chat command >server restart makes the server exit with code 75, and systemd starts it again (RestartForceExitStatus=75 in the unit).
>server reboot (restarting the OS) does not run, because the server does not have root privileges.

To listen on a port below 1024, remove the leading # from "#AmbientCapabilities=CAP_NET_BIND_SERVICE" in /etc/systemd/system/naptify-server.service, run systemctl daemon-reload, and restart the server (AmbientCapabilities= needs systemd 229 or later).


■ If you forget the admin page password

Stop the server, then run the command as the naptify user (it refuses to run as a user other than the owner of the data root).
     systemctl stop naptify-server
     sudo -u naptify /usr/local/bin/naptify-server reset-admin-password
     systemctl start naptify-server
The admin page username and password are removed, and admin access returns to "this PC only, without a password".


■ Included files

naptify-server-1.1.6-linux-x86_64/
  naptify-server
      The server
  languages/
      Language files other than Japanese and English (de, es, fr, ko, pt-BR, uk, zh-CN)
  naptify-server.service
      The systemd unit sample
  README.txt
      This file

Japanese and English are built into the server. The languages of the language files (.lng) in /var/lib/naptify-server/languages appear in the admin page's language list.


■ Where your data is stored

Data is stored in /var/lib/naptify-server (you can change it with --data-root of serve). The following are created on first launch:

  main.sqlite   Database of settings, users, audit records, statistics and more
  logs/         Log files
  backups/      Backups of the database (main.sqlite)
  state/        Working files for restores and imports

Other working files (such as .naptify.lock and main.sqlite-wal) are also created. Only the server's user can read and write the files it creates.
The server refuses to start if the data root is owned by another user, or if its group or other users have permissions on it (journalctl -u naptify-server shows how to fix it, for example chmod 700 /var/lib/naptify-server).
The shared-file information of logged-in users is kept in /var/tmp/naptify-server (a location private to this service, through PrivateTmp of systemd) and deleted when the server exits normally.
If you run the server without systemd, delete any /var/tmp/naptify-server left by another user first (the server does not use a folder owned by someone else, and shared-file information and search become unavailable).
To import from FaceNap, make the source folder readable by the naptify user. Keep the source outside /tmp and /var/tmp (because of PrivateTmp, the service cannot see them).


■ Update check

To check whether a new version has been released, the server periodically contacts the distribution site (https://naptify.net/).
Only four things are sent: product, version, OS and CPU. No host name or display name, no user count, no share count.
When a new version is available, you are notified in the admin page. Nothing is downloaded or installed automatically.

To stop the check, open Settings → Operation → Update check in the admin page, clear "Check for newer releases automatically", and press "Save".


■ Uninstalling (run as root)

1. Stop the server and remove its registration.
     systemctl disable --now naptify-server
     rm /etc/systemd/system/naptify-server.service /usr/local/bin/naptify-server
     systemctl daemon-reload
2. To delete the data as well, delete /var/lib/naptify-server and remove the naptify user (userdel naptify).
   Copy anything you want to keep to another location first.


■ Links

Download: https://naptify.net/en/server-en/download-en/
Terms of use: https://naptify.net/en/terms-en/
Support (bug reports and feature requests): https://naptify.net/en/support-en/


■ Developer

MASA AMIYA
Contact: info@naptify.net
