1

I am running my the PIXEL desktop of Rasbian (Jessie) in VNC started by cron. In this case the Shutdown and Reboot of the shutdown menu do not work (only Logout).

How can I get shutdown and reboot working?

From the discussion at the RPi Forum this problem seems to happen in a VNC desktop started through the user's crontab via @reboot vncserver & since the cron environment is restricted and prevents (PAM?) from working correctly. The problem shows up when I start the button script in a shell and click on reboot:

raspberrypi:~$ lxde-pi-shutdown-helper 
Failed to execute operation: Access denied
Must be root.

Interestingly when I ssh in as user pi I get:

raspberrypi:~$ lxde-pi-shutdown-helper
==== AUTHENTICATING FOR org.freedesktop.login1.power-off ===
Authentication is required for powering off the system.
Multiple identities can be used for authentication:
 1.  ,,, (pi)
 2.  root
Choose identity to authenticate as (1-2):

So lxde-pi-shutdown-helper seems to be a complex program which I would like to understand and use better in VNC. A similar issue is Get Bash instead of /bin/sh in a VNC session started by cron.

What does it take to run lxde-pi-shutdown-helper correctly?

  • Seems more like an integration issue between the VNC server and PIXEL/LXDE than anything to do with the environment (as with the shell problem). – goldilocks Apr 4 '17 at 15:44
  • This appears to be the same issue as discussed in your other question; probably one of these questions should be made more general and the other deleted. (The authentication issue above is probably caused by missing environment variables; if you simply choose 1 and type the pi user's password, it should work.) – Curt J. Sampson Apr 5 '17 at 17:35
  • @CurtJ.Sampson Let's say this question is about the requirement for lxde-pi-shutdown-helper to work and the other question is about starting VNC through cron without limitations. Now when I click the shutdown button I don't get this menu so I can't follow your suggestion. – Frank Breitling Apr 5 '17 at 17:55
  • Hm. Ok, I'll buy that these are separate questions, then. In your VNC session, when you run lxde-pi-shutdown-helper from the command line and choose 1 from the menu above, does the Pi then correctly shut down? And do you have to type a password when you do that? (I.e., did you add a password to your account?) – Curt J. Sampson Apr 5 '17 at 18:10
  • @CurtJ.Sampson I have edited my question to answer your question. So yes, when I run gksudo lxde-pi-shutdown-helper I can reboot by clicking the reboot button. Otherwise I see Failed to execute operation: Access denied Must be root. And yes my users have passwords. – Frank Breitling Apr 6 '17 at 9:46
1

In your crontab, run your login shell with the option that does full login processing and have it run vncserver, e.g.:

bash -l -c vncserver

This will ensure that a) your preferred shell is used, and b) /etc/profile and your .bash_profile or .profile are read.

  • I tried this already but it doesn't fix PAM or polkit issues. – Frank Breitling Apr 5 '17 at 17:57
0

to reboot you raspberry pi just execute this command:

  sudo shutdown -h now

but if you want your button to start working you should edit this file:

   nano  ~/.config/lxpanel/LXDE-pi/panels/panel

the content should be like this:

# lxpanel <profile> config file. Manually editing is not recommended.
# Use preference dialog in lxpanel to adjust config when you can.

Global {
  edge=top
  allign=left
  margin=0
  widthtype=percent
  width=100
  height=36
  transparent=0
  tintcolor=#000000
  alpha=0
  autohide=0
  heightwhenhidden=2
  setdocktype=1
  setpartialstrut=1
  usefontcolor=0
  fontsize=12
  fontcolor=#ffffff
  usefontsize=0
  background=0
  backgroundfile=/usr/share/lxpanel/images/background.png
  iconsize=36
}
Plugin {
  type=space
  Config {
    Size=4
  }
}
Plugin {
  type=menu
  Config {
    image=/usr/share/raspberrypi-artwork/launch.png
    system {
    }
    separator {
    }
    item {
      name=Run...
      image=system-run
      command=run
    }
    separator {
    }
    item {
      name=Shutdown...
      image=system-shutdown
      command=logout
    }
  }
}
Plugin {
  type=space
  Config {
    Size=8
  }
}
Plugin {
  type=launchbar
  Config {
    Button {
      id=lxde-x-www-browser.desktop
    }
    Button {
      id=pcmanfm.desktop
    }
    Button {
      id=lxterminal.desktop
    }
    Button {
      id=wolfram-mathematica.desktop
    }
    Button {
      id=wolfram-language.desktop
    }
  }
}
Plugin {
  type=space
  Config {
    Size=8
  }
}
Plugin {
  type=taskbar
  expand=1
  Config {
    tooltips=1
    IconsOnly=0
    ShowAllDesks=0
    UseMouseWheel=1
    UseUrgencyHint=1
    FlatButton=0
    MaxTaskWidth=200
    spacing=1
    GroupedTasks=0
  }
}
Plugin {
  type=space
  Config {
    Size=2
  }
}
Plugin {
  type=tray
  Config {
  }
}
Plugin {
  type=bluetooth
  Config {
  }
}
Plugin {
  type=space
  Config {
    Size=2
  }
}
Plugin {
  type=dhcpcdui
  Config {
  }
}
Plugin {
  type=space
  Config {
    Size=2
  }
}
Plugin {
  type=volumealsa
  Config {
  }
}
Plugin {
  type=space
  Config {
    Size=2
  }
}
Plugin {
  type=cpu
  Config {
    ShowPercent=1
    Foreground=#a9a9a9a9a9a9
    Background=#d3d3d3d3d3d3
  }
}
Plugin {
  type=dclock
  Config {
    ClockFmt=%R
    TooltipFmt=%A %x
    BoldFont=0
    IconOnly=0
    CenterText=0
  }
}
Plugin {
  type=space
  Config {
    Size=2
  }
}
Plugin {
  type=ejecter
  Config {
  }
}

this is the important piece of code:

item {
  name=Shutdown...
  image=system-shutdown
  command=logout
}
  • Thanks for your quick reply. The important piece of code is already there, but still it doesn't work. – Frank Breitling Apr 2 '17 at 17:20
  • @FrankBreitling You could take a step forward with this by determining whether sudo shutdown -h now (or reboot) will work from a GUI terminal via VNC. If it does, then the solution is simple enough. If it doesn't, then the stuff about PIXEL is really chaff and you should focus on the "related issue" from the question. – goldilocks Apr 4 '17 at 15:18
  • @goldilocks sudo shutdown -h now works form the VNC terminal. But I want the button working which uses lxde-pi-shutdown-helper. – Frank Breitling Apr 4 '17 at 15:36
0

~/.config/lxpanel/LXDE-pi/config

holds the panel logout helper

Logout=lxde-pi-shutdown-helper

needs a sudo after a recent update

sudo lxde-pi-shutdown-helper

the button behavior is back to normal

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.