ターミナルを介してchrootモードでdconf設定を変更するには?

ターミナルを介してchrootモードでdconf設定を変更するには?

私は起動可能なGUIデスクトップシステムを使用して動作しdconf writeますgsetting set。 chroot環境のスクリプトで実行しようとしましたが、エラーが発生しました。 Web 検索で同様の誤った QA が見つかりました。コマンドライン "dbus-launch --autolaunch="xyz" --binary-syntax --close-stderr" 生成中にエラーが発生しました: サブプロセスがコード 1 で終了しました。https://www.reddit.com/r/linuxquestions/comments/n90sry/error_spawning_command_line_dbuslaunch/ところが前者には答えがなく、後で知ってみるとエラーの原因が私と違っていました。

man 7 dconfのマニュアルページで、man dconf編集する特定のデータベースを選択する方法が見つかりませんでした。どのような方法がありますか?

ジョブシステムでdconfデータベースを見つけようとしていますが、ジョブdconf writeシステムでも$ echo $XDG_CONFIG_HOME空の出力が生成されますが、/etc/dconf/profile/存在しません$ echo $DCONF_PROFILE

$ man 7 dconf
DCONF_PROFILE can specify a relative path to a file in
       /etc/dconf/profile/, or an absolute path (such as in a user's home
       directory).
A "user-db" line specifies a user database. These databases are found
       in $XDG_CONFIG_HOME/dconf/  

追加された1件(@aviroのコメントでリクエストされたとおり):

# Commands invoked by the script include:
dconf write /org/cinnamon/desktop/keybindings/custom-keybindings/custom0/name "'Display rotate normal'"

gsettings set org.cinnamon.desktop.keybindings custom-list "['__dummy__', 'custom0', 'custom1', 'custom2', 'custom3']"

# output:
error: Error spawning command line “dbus-launch --autolaunch=XXX --binary-syntax --close-stderr”: Child process exited with code 1

(process:108725): dconf-WARNING **: 15:35:32.574: failed to commit changes to dconf: Error spawning command line “dbus-launch --autolaunch=XXX --binary-syntax --close-stderr”: Child process exited with code 1  

このスクリプトは、sudo chroot fin_sq pathinsidenewroot/nameofscriptLinux Mint Cinnamonリリースisoの内容を新しいルートディレクトリから実行してインストールします。

mkdir iso to temp fin 
sudo mount $original_iso iso #  -o loop
sudo mount -t overlay -o lowerdir=iso,upperdir=to,workdir=temp overlay fin
mkdir iso_sq to_sq temp_sq fin_sq
sudo mount iso/casper/filesystem.squashfs iso_sq -t squashfs -o loop
sudo mount -t overlay -o lowerdir=iso_sq,upperdir=to_sq,workdir=temp_sq overlay fin_sq  

追加された2:
「一般」環境では両方とも同じ値(1.0)がdconf read /org/cinnamon/desktop/interface/text-scaling-factor表示されますが、gsettings get org.cinnamon.desktop.interface text-scaling-factorほぼ同時にこのPCではchrootedではgsettings get 1.0が表示されますが、dconf read出力は空です。text-scaling-factorキーを変更すると(通常は)gsettings getchrootedの出力は変わりません(dconf read通常の出力は新しいキー値に変わります)。

ベストアンサー1

まず、dconf構成設定を変更します。特定のユーザーX11 表示が実行中です。したがって、最初の問題はrootとして実行していることです。自分のユーザーに切り替えようとしたとしても、chroot環境では自分のユーザーとグループがchroot環境に存在しないため、自分/etc/{passwd,group}のユーザーに慣れていないため、ユーザーの切り替えもできません。切り替えても(ホストから関連ファイルをバインドした後)、chroot環境にホームディレクトリはありません。 homedirをchroot環境にバインドしてsuユーザーにバインドできるとしても、chroot環境にX11ソケットがない可能性がありDBUS_SESSION_BUS_ADDRESSますsu

次の質問に対する回答を確認できます。rootとしてsuを使用して、他のユーザーのdconfを変更できます。実際に適用するにはどうすればよいですか?検索/設定/使用方法の例をいくつかご確認くださいDBUS_SESSION_BUS_ADDRESS

したがって、rootでこれを行うのは非常に複雑で、chroot環境での実行ははるかに複雑です。不可能ではありませんが、難しいです。始める前に、関連するすべてのファイル/フォルダをchrootフォルダにバインドマウントする必要があります。そのため、あなたのユースケースが何であるかを尋ね、それを一種のコンテナとして使用しようとしているかどうかを尋ねますsingularity。関連passwd/作成group、ホームディレクトリのインストールなど)。

次のコメントについて:

同じ時間に、そのPCのchrootはgsettings get1.0を表示しましたが、dconf read出力は空でした。

そしてgsettings(実際には、ユーザーの設定dconfバックエンドを検索または検索します。設定がそこに見つからない場合は)。gsettings$HOME/.config/dconf/user$XDG_CACHE_HOME/dconf/usergsettings/usr/share/glib-2.0/schemas/gschemas.compiled

からman glib-compile-schemas

   glib-compile-schemas compiles all the GSettings XML schema files in
   DIRECTORY into a binary file with the name gschemas.compiled that can
   be used by GSettings. The XML schema files must have the filename
   extension .gschema.xml. For a detailed description of the XML file
   format, see the GSettings documentation.

   At runtime, GSettings looks for schemas in the glib-2.0/schemas
   subdirectories of all directories specified in the XDG_DATA_DIRS
   environment variable. The usual location to install schema files is
   /usr/share/glib-2.0/schemas.

おすすめ記事