NextCloudPi

このページはX年以上前に更新されたものです。 内容が陳腐化している恐れがあります。ご注意ください。

RasPiではなくDebian 10 (buster)のVMで動作中

NextCloud 14にアップデートしてからncp-scan-autoがエラーを吐く

In AbstractMySQLDriver.php line 115: 

[Doctrine\DBAL\Exception\DriverException] 
An exception occurred while executing 'SELECT `uid`, `displayname` FROM `oc_users` `u` LEFT JOIN `oc_preferences` `p` ON (`userid` = `uid`) AND (`appid` = 'settings') AND (`configkey` = 'email') WHERE (`uid` COLLATE utf8mb4_general_ci LIKE ?) OR (`displayname` COLLATE utf8mb4_general_ci LIKE ?) OR `configvalue` COLLATE utf8mb4_general_ci LIKE ?) ORDER BY `uid_lower` ASC' with params ["%%", "%%", "%%"]: SQLSTATE[42000]: Syntax error or access violation: 1253 COLLATION 'utf8mb4_general_ci' is not valid for CHARACTER SET 'utf8' 
MariaDB [nextcloud]> SHOW VARIABLES LIKE 'character_%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8mb4                    |
| character_set_connection | utf8mb4                    |
| character_set_database   | utf8mb4                    |
| character_set_filesystem | binary                     |
| character_set_results    | utf8mb4                    |
| character_set_server     | utf8mb4                    |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+
8 rows in set (0.00 sec)

MariaDB [nextcloud]> show create table oc_users;
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table    | Create Table                                                                                                                                                                                                                                                                                                                                                                            |
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| oc_users | CREATE TABLE `oc_users` (
  `uid` varchar(64) COLLATE utf8_bin NOT NULL DEFAULT '',
  `displayname` varchar(64) COLLATE utf8_bin DEFAULT NULL,
  `password` varchar(255) COLLATE utf8_bin NOT NULL DEFAULT '',
  `uid_lower` varchar(64) COLLATE utf8_bin DEFAULT '',
  PRIMARY KEY (`uid`),
  KEY `user_uid_lower` (`uid_lower`)                                                                                                                                                                        ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin |
+----------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
MariaDB [nextcloud]> show create table oc_users;
+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Table    | Create Table                                                                                                                                                                                                                                                                                                                                                                                                                    |
+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| oc_users | CREATE TABLE `oc_users` (
  `uid` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
  `displayname` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL,
  `password` varchar(255) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
  `uid_lower` varchar(64) COLLATE utf8mb4_bin DEFAULT '',
  PRIMARY KEY (`uid`),
  KEY `user_uid_lower` (`uid_lower`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPRESSED |
+----------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
  • 治ったっぽい

NextCloud 14.0.1.1→15.0.6へアップデート

ncp-update-nextcloudすると以下で失敗する

An unhandled exception has been thrown:
TypeError: substr() expects parameter 1 to be string, boolean given in /var/www/nextcloud/lib/private/AppFramework/Http/Request.php:835
Stack trace:
#0 /var/www/nextcloud/lib/private/AppFramework/Http/Request.php(835): substr(false, 18)
#1 /var/www/nextcloud/lib/private/AppFramework/Http/Request.php(750): OC\AppFramework\Http\Request->getScriptName()
#2 /var/www/nextcloud/lib/private/Log/File.php(102): OC\AppFramework\Http\Request->getRequestUri()
#3 /var/www/nextcloud/lib/private/Log.php(329): OC\Log\File->write('updater', '\\OC\\Updater::ma...', 1)
#4 /var/www/nextcloud/lib/private/Log.php(218): OC\Log->writeLog('updater', '\\OC\\Updater::ma...', 1)
#5 /var/www/nextcloud/lib/private/Log.php(180): OC\Log->log(1, '\\OC\\Updater::ma...', Array)
#6 /var/www/nextcloud/lib/private/Updater.php(544): OC\Log->info('\\OC\\Updater::ma...', Array)
(以下略)

https://github.com/nextcloud/server/blob/b9d5e72be968c59fbdaff8ad2be5b472a4d02226/lib/private/AppFramework/Http/Request.php#L835

config/config.phpoverwritewebrootを一旦''にしてからアップデート

Cannot load Zend OPcache - it was already loaded

アップロードでタイムアウトする

  • 18.0.3 / 18.0.4

/var/log/apache2/error.log

[Fri Apr 24 00:11:02.227179 2020] [proxy_fcgi:error] [pid 15311:tid 140496903075584] (70008)Partial results are valid but processing is incomplete: [client XXX.XXX.XXX.XXX:XXXXX] AH01075: Error dispatching request to : (reading input brigade)

リバースプロキシ→VPN→Nextcloudな構成
リバースプロキシより先が遅いような?

swapをオフ

  • ファイル/var/swapが存在する
    % sudo swapon -s
    Filename                                Type            Size    Used    Priority
    /dev/sda5                               partition       2094076 0       -2
    /var/swap                               file            2097148 0       -3
  • dphys-swapfileがそのへんやってるみたい
    % sudo dphys-swapfile swapoff
    % sudo systemctl disable dphys-swapfile.service

Musicアプリ

Androidから聴く

  • AmpacheとSubsonicのAPIに対応しているみたい
  • 参考:
  • NextCloud 18.0.4 + Music 0.14.0 + Android 10で試したアプリ
    • Ampache API
      • Power Ampache 1.09.49
        • アーティストを選んだ次の階層が何も出ない
        • アルバムからの選択・再生はOK
        • ローカルにキャッシュされない?設定は特にない
        • 通知画面にメディアコントロールが出ない
    • Subsonic API
      • UltraSonic 2.7.0
        • サーバ設定時のTest ConnectionでConnection failureになる
      • Audinaut 0.5.1
        • First level artistsをオンにしておく(当方のライブラリはアーティスト/アルバムの2階層フォルダ構成)
        • アーティストでフィルタせずにアルバムの一覧表示はできない?
        • キャッシュ先・サイズの設定変更可能
      • DSub 5.0.3
        • キャッシュ先・サイズの設定変更可能
        • よさげ
      • Subsonic 4.8
        • キャッシュ先が変更できない
    • 普通にAirsonicサーバを立てたほうが幸せになれそうな気がしてきた

スキャン

  • ncc music:scan --all
    • ジャンルのスキャンは別途要求されるような

302でリダイレクトが繰り返される (Nextcloud 21.0.4.1, NextCloudPi 1.39.13)

  • nginxでリバースプロキシしてる環境
  • Nextcloud側(apache2)がhttpsで待ち受けるようになってる(NextCloudPiの変更?)
  • リバースプロキシ先を http://x.x.x.x:80 から https://x.x.x.x:443 に変更

INotify file watcherを試す

環境

  • Nextcloud 22.2.2 (2021/12/23)
  • Debian buster amd64
% php -v
PHP 7.3.31-1~deb10u1 (cli) (built: Oct 24 2021 15:18:08) ( NTS )

インストール

普通にNextcloudの設定画面からインストールしようとすると怒られる

App “INotify file watcher” cannot be installed because the following dependencies are not fulfilled: The library inotify is not available.

phpのinotifyを入れる

% sudo apt install php-pear
% sudo pecl install inotify

phpizeが無いと怒られる

sh: 1: phpize: not found

phpX.X-devをインストールして再度pecl install

% sudo apt install php7.3-dev
% sudo pecl install inotify
  :
Build process completed successfully
Installing '/usr/lib/php/20180731/inotify.so'
install ok: channel://pecl.php.net/inotify-3.0.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=inotify.so" to php.ini

モジュールを有効にする

/etc/php/7.3/mods-availableinotify.iniを以下の内容で作る

extension=inotify.so
% sudo phpenmod inotify

/etc/php/7.3/cli/conf.d/etc/php/7.3/fpm/conf.dにシンボリックリンク20-inofity.iniができる

php-fpmを再起動

% sudo systemctl restart php7.3-fpm.service

試す

試しにSMB共有に対してやってみたら

% sudo -u www-data ncc files_external:list
+----------+-------------+----------+---------------------+-----------------------------------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+
| Mount ID | Mount Point | Storage  | Authentication Type | Configuration                                                                                                                     | Options | Applicable Users | Applicable Groups |
+----------+-------------+----------+---------------------+-----------------------------------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+
| 1        | /Sync       | SMB/CIFS | Global credentials  | host: "192.168.xx.xx", share: "sync", root: "default", domain: "", user: "xx", password: "***", show_hidden: false, timeout: "" |         | All              |                   |
+----------+-------------+----------+---------------------+-----------------------------------------------------------------------------------------------------------------------------------+---------+------------------+-------------------+
% sudo -u www-data ncc files_external:notify -v 1

In NativeShare.php line 350:

  [Icewind\SMB\Exception\DependencyException]
  smbclient not found in path for notify command

smbclientが入ってればいける?

% sudo apt install smbclient
% sudo -u www-data ncc files_external:notify -v 1
smbXcli_negprot_smb1_done: No compatible protocol selected by server.
Protocol negotiation failed: NT_STATUS_INVALID_NETWORK_RESPONSE
Self-test successful

/etc/sysctl.d/local.conffs.inotify.max_user_watches = 204800を追加

Localに対して試す

% sudo -u www-data ncc files_external:notify -vvv 5
An unhandled exception has been thrown:
TypeError: Argument 1 passed to OCA\Files_INotify\Storage\NotifyHandler::deduplicateEvents() must be of the type array, null given, called in /var/www/nextcloud/apps/files_inotify/lib/Storage/NotifyHandler.php on line 99 and defined in /var/www/nextcloud/apps/files_inotify/lib/Storage/NotifyHandler.php:106

nextcloud-inotifyscan を試す

% git clone https://github.com/Blaok/nextcloud-inotifyscan; cd nextcloud-inotifyscan
% sudo make install
% cd /etc/nextcloud-inotifyscan
% cp sample.ini www-data.ini
% sudoedit www-data.ini
[DEFAULT]
interval = 1

[Instance1]
occ = /var/www/nextcloud/occ
user = username_of_nextcloud
docker = no
external_storage = yes
% sudo systemctl enable --now nextcloud-inotifyscan@www-data.service
% sudo journalctl -fu nextcloud-inotifyscan@www-data

Bookmarks アプリ

サイトのサムネイルを作成

結構リソース食いそう

% sudo apt install nodejs npm
% sudo npm install --global pageres-cli

node.jsは別んとこから入れた方がいいかも

  • https://github.com/nodesource/distributions/blob/master/README.md#deb
# curl -fsSL https://deb.nodesource.com/setup_lts.x | bash -
% sudo apt-get install -y nodejs
% sudo npm install --global pageres-cli
% pageres https://www.yahoo.co.jp/ 1366x768
Error: Failed to launch the browser process!
/usr/lib/node_modules/pageres-cli/node_modules/puppeteer/.local-chromium/linux-818858/chrome-linux/chrome: error while loading shared libraries: libatk-1.0.so.0: cannot open shared object file: No such file or directory
% sudo apt install libatk1.0-0 libatk-bridge2.0-0 libxcomposite1 libgtk3-0 libgbm1
% pageres https://www.yahoo.co.jp/ 1366x768
Error: Failed to launch the browser process!
[1226/234238.055180:FATAL:zygote_host_impl_linux.cc(117)] No usable sandbox! Update your kernel or see https://chromium.googlesource.com/chromium/src/+/master
/docs/linux/suid_sandbox_development.md for more information on developing with the SUID sandbox. If you want to live dangerously and need an immediate workar
ound, you can try using --no-sandbox.

https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md#setting-up-chrome-linux-sandbox

% sudo sysctl -w kernel.unprivileged_userns_clone=1

/etc/sysctl.d/local.confに追加しておく

ブックマーク一覧をスクロールしていると読み込みのタイミングで頭まで戻される

  • ソート順を Sort by manual order にしておくとよさげ