Browse Source

add service unit for managing fbcp under systemd

Checks if we're under systemd, and if so, ensures that fbcp isn't
mentioned in /etc/rc.local, and installs a new unit file to start
fbcp at boot, after network.target.

If not under systemd, retains the old rc.local behavior.

I note this is the only place that the $SYSTEMD var actually seems to get
checked.  I can't, at this time, vouch for what would happen on a sysvinit
box.
pull/28/head
Brennen Bearnes 2 years ago
parent
commit
93d765c803
1 changed files with 41 additions and 12 deletions
  1. +41
    -12
      adafruit-pitft.sh

+ 41
- 12
adafruit-pitft.sh View File

@ -319,21 +319,32 @@ function install_fbcp() {
cd ~
rm -rf /tmp/rpi-fbcp-master
# Add fbcp to /rc.local:
echo "Add fbcp to /etc/rc.local..."
grep fbcp /etc/rc.local >/dev/null
if [ $? -eq 0 ]; then
# fbcp already in rc.local, but make sure correct:
sed -i "s|^.*fbcp.*$|/usr/local/bin/fbcp \&|g" /etc/rc.local >/dev/null
# Start fbcp in the appropriate place, depending on init system:
if [ "$SYSTEMD" == "0" ]; then
# Add fbcp to /etc/rc.local:
echo "We have sysvinit, so add fbcp to /etc/rc.local..."
grep fbcp /etc/rc.local >/dev/null
if [ $? -eq 0 ]; then
# fbcp already in rc.local, but make sure correct:
sed -i "s|^.*fbcp.*$|/usr/local/bin/fbcp \&|g" /etc/rc.local >/dev/null
else
# Insert fbcp into rc.local before final 'exit 0':
sed -i "s|^exit 0|/usr/local/bin/fbcp \&\\nexit 0|g" /etc/rc.local >/dev/null
fi
else
#Insert fbcp into rc.local before final 'exit 0'
sed -i "s|^exit 0|/usr/local/bin/fbcp \&\\nexit 0|g" /etc/rc.local >/dev/null
# Install fbcp systemd unit, first making sure it's not in rc.local:
uninstall_fbcp_rclocal
echo "We have systemd, so install fbcp systemd unit..."
install_fbcp_unit || bail "Unable to install fbcp unit file"
sudo systemctl enable fbcp.service
fi
# if there's X11 installed...
if [ -e /etc/lightdm ]; then
echo "Setting raspi-config to boot to desktop w/o login..."
raspi-config nonint do_boot_behaviour B4
fi
# Disable overscan compensation (use full screen):
raspi-config nonint do_overscan 1
# Set up HDMI parameters:
@ -381,11 +392,23 @@ function install_fbcp() {
}
function uninstall_fbcp() {
# Remove fbcp from /etc/rc.local:
echo "Remove fbcp from /etc/rc.local..."
sed -i -e '/^.*fbcp.*$/d' /etc/rc.local
function install_fbcp_unit() {
cat > /etc/systemd/system/fbcp.service <<EOF
[Unit]
Description=Framebuffer copy utility for PiTFT
After=network.target
[Service]
Type=simple
ExecStart=/usr/local/bin/fbcp
[Install]
WantedBy=multi-user.target
EOF
}
function uninstall_fbcp() {
uninstall_fbcp_rclocal
# Enable overscan compensation
raspi-config nonint do_overscan 0
# Set up HDMI parameters:
@ -396,6 +419,12 @@ function uninstall_fbcp() {
sed -i -e '/^hdmi_cvt=.*$/d' /boot/config.txt
}
function uninstall_fbcp_rclocal() {
# Remove fbcp from /etc/rc.local:
echo "Remove fbcp from /etc/rc.local, if it's there..."
sed -i -e '/^.*fbcp.*$/d' /etc/rc.local
}
function update_xorg() {
if [ "${pitfttype}" == "28r" ] || [ "${pitfttype}" == "35r" ]; then
matrix=$(eval echo "\$TRANSFORM_$pitfttype$pitftrot")


Loading…
Cancel
Save