Puppet, 가상 터미널 또는 ssh를 통해 데스크톱 구성을 자동화해야합니다.
불행히도 gsettings
ssh 또는 가상 터미널 을 통한 호출은 다음 을 제공합니다.
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize "4"
(process:29520): dconf-WARNING **: failed to commit changes to dconf: Cannot autolaunch D-Bus without X11 $DISPLAY
내가 설정 한 경우 $DISPLAY
와 export DISPLAY=:0.0
는 다른 오류를 제공합니다 :
(process:29862): dconf-WARNING **: failed to commit changes to dconf: Could not connect: Connection refused
내가 무엇을 할 수 있을지?
답변
핵심은 DBUS_SESSION_BUS_ADDRESS
환경 변수 를 설정하는 것입니다.
에 이 스레드 그 변수의 정확한 값을 얻을하는 데 도움이 다음과 같은 스크립트를 발견했다. dbus 설정을 변경하려는 데스크탑에서 실행중인 프로세스 이름이 필요합니다. (병렬로 실행중인 그래픽 세션이 둘 이상있을 수 있습니다). 전화합시다discover_session_bus_address.sh
#!/bin/bash
# Remember to run this script using the command "source ./filename.sh"
# Search these processes for the session variable
# (they are run as the current user and have the DBUS session variable set)
compatiblePrograms=( nautilus kdeinit kded4 pulseaudio trackerd )
# Attempt to get a program pid
for index in ${compatiblePrograms[@]}; do
PID=$(pidof -s ${index})
if [[ "${PID}" != "" ]]; then
break
fi
done
if [[ "${PID}" == "" ]]; then
echo "Could not detect active login session"
return 1
fi
QUERY_ENVIRON="$(tr '\0' '\n' < /proc/${PID}/environ | grep "DBUS_SESSION_BUS_ADDRESS" | cut -d "=" -f 2-)"
if [[ "${QUERY_ENVIRON}" != "" ]]; then
export DBUS_SESSION_BUS_ADDRESS="${QUERY_ENVIRON}"
echo "Connected to session:"
echo "DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS}"
else
echo "Could not find dbus session ID in user environment."
return 1
fi
return 0
이 스크립트를 사용하면 unity
프로세스가 데스크탑에서 실행 중이고 설정을 적용하려는 경우 다음을 수행 할 수 있습니다 .
. ./discover_session_bus_address.sh unity
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize "4"
그리고 일이 잘 작동합니다.
답변
프로비저닝하는 동안 SSH를 통해 방랑자 이미지를 변경하려고 시도하는 동안 이와 동일한 문제가 발생했습니다.
이 솔루션 /ubuntu//a/326773 은 적극적인 연결을 위해 모든 낚시를하지 않고 환경을 속이려고하는 트릭을 만들었습니다. YMMV …
답변
내 gsetting을 설정하는 POST-Install 스크립트가 있습니다. EUID가 0으로 스크립트를 실행하기 때문에 $ RUID (실제 사용자 ID)를 찾아야합니다.
여기 내 접근 방식이 있습니다 :
#!/usr/bin/env bash
# Get the Real Username
RUID=$(who | awk 'FNR == 1 {print $1}')
# Translate Real Username to Real User ID
RUSER_UID=$(id -u ${RUID})
# Set gsettings for the Real User
sudo -u ${RUID} DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/${RUSER_UID}/bus" gsettings set org.gnome.desktop.interface clock-show-date false
exit