Skip to content

Commit

Permalink
Hot fixes for OS elements (#24)
Browse files Browse the repository at this point in the history
* halt only for specified user

* neobotix sudoers file

* added cleanup script

* query user + clear history

* new dependencies: vino, openssh-server

* autostart vino server

* enable keyboard layout switcher

* added vino configuration. closes #15.

* extend udev rule for serial converter

* close #23; powermanagement, lockscreen and screensaver.

* update the debian package

* shutdown and poweroff without password prompt.

* update the debian package

* use correct user account to set gsettings

* disable blank screen

* v. 1.0.3

* adding multicasting for loopback

* better way to clear bash history

---------

Co-authored-by: par <reiter@neobotix.de>
  • Loading branch information
padhupradheep and neopar authored Feb 7, 2023
1 parent efab3f2 commit 7a96af7
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 10 deletions.
Binary file modified debian/neobotix-tools.deb
Binary file not shown.
4 changes: 2 additions & 2 deletions debian/neobotix-tools/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Package: neobotix-tools
Version: 1.0.2
Version: 1.0.3
Maintainer: Paul Reiter <reiter@neobotix.de>
Section: misc
Priority: optional
Architecture: all
Depends: secure-delete, xfconf, xfce4-xkb-plugin, x2goserver, x2goserver-xsession, net-tools, cloud-guest-utils, mousepad, vim
Depends: secure-delete, xfconf, xfce4-xkb-plugin, x2goserver, x2goserver-xsession, net-tools, cloud-guest-utils, mousepad, vim, vino, openssh-server
Description: neobotix-tools
This package configures operating system and installs useful tools and
dependencies needed for running middleware software on Neobotix robot
Expand Down
23 changes: 22 additions & 1 deletion debian/neobotix-tools/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ echo 'autologin-user='$user >> /etc/lightdm/lightdm.conf
echo 'autologin-user-timeout=0' >> /etc/lightdm/lightdm.conf

# Halt without pwd
echo '%sudo ALL=NOPASSWD: /sbin/halt,/sbin/reboot' | EDITOR='tee -a' visudo
echo "$user ALL=NOPASSWD: /sbin/halt,/sbin/reboot,/sbin/poweroff,/sbin/shutdown" > /etc/sudoers.d/neobotix
visudo -c -f /etc/sudoers.d/neobotix

# Disable auto upgrades
sed -i 's/APT::Periodic::Update-Package-Lists "1"/APT::Periodic::Update-Package-Lists "0"/' /etc/apt/apt.conf.d/20auto-upgrades
Expand All @@ -29,11 +30,13 @@ sed -i 's/APT::Periodic::Update-Package-Lists "1"/APT::Periodic::Update-Package-
#grep '/opt/neobotix/tools/enable_can0.sh' /etc/crontab || echo '@reboot /opt/neobotix/tools/enable_can0.sh' >> /etc/crontab

if ! crontab -l | grep -q '/opt/neobotix/tools/enable_can0.sh'; then (crontab -l 2>/dev/null; echo "@reboot /opt/neobotix/tools/enable_can0.sh") | crontab -; fi
if ! crontab -l | grep -q '/opt/neobotix/tools/enable_multicast_lo.sh'; then (crontab -l 2>/dev/null; echo "@reboot /opt/neobotix/tools/enable_multicast_lo.sh") | crontab -; fi

# Setup udev rules for serial converter
echo 'SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ENV{ID_VENDOR}=="FTDI", ENV{ID_MODEL_ID}=="6010", ENV{ID_USB_INTERFACE_NUM}=="00", SYMLINK+="neo-relayboard"' > /etc/udev/rules.d/99-usb-serial.rules
echo 'SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ENV{ID_VENDOR}=="FTDI", ENV{ID_MODEL_ID}=="6010", ENV{ID_USB_INTERFACE_NUM}=="01", SYMLINK+="neo-s300-1"' >> /etc/udev/rules.d/99-usb-serial.rules
echo 'SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ENV{ID_VENDOR}=="FTDI", ENV{ID_MODEL_ID}=="6001", SYMLINK+="neo-s300-2"' >> /etc/udev/rules.d/99-usb-serial.rules
echo 'SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ENV{ID_VENDOR}=="FTDI", ENV{ID_MODEL_ID}=="6015", SYMLINK+="neo-s300-2"' >> /etc/udev/rules.d/99-usb-serial.rules

# Update GRUB
cp /etc/default/grub /etc/default/grub_`date +"%Y-%m-%d_%T"`
Expand All @@ -42,6 +45,24 @@ sed -i -e 's%GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"%GRUB_CMDLINE_LINUX_DEFAUL
sed -i -e 's%#GRUB_TERMINAL=console%GRUB_TERMINAL=console%g' /etc/default/grub
update-grub

# Configure vino
stty_orig=$(stty -g)
stty -echo
IFS= read -p "Please enter VNC password: " -r passwd
stty "$stty_orig"
echo ''
sudo -Hu $user gsettings set org.gnome.Vino require-encryption false
sudo -Hu $user gsettings set org.gnome.Vino prompt-enabled false
sudo -Hu $user gsettings set org.gnome.Vino authentication-methods "['vnc']"
sudo -Hu $user gsettings set org.gnome.Vino vnc-password $(echo -n "$passwd"|base64)

# Add vino to autostart
mkdir -p /home/$user/.config/autostart
echo '[Desktop Entry]' > /home/$user/.config/autostart/vino.desktop
echo 'Type=Application' >> /home/$user/.config/autostart/vino.desktop
echo 'Name=Vino Server' >> /home/$user/.config/autostart/vino.desktop
echo 'Exec=systemctl --user start vino-server' >> /home/$user/.config/autostart/vino.desktop

#su -c /opt/neobotix/tools/xfce_tweaks.sh $user
#sudo -u $user /opt/neobotix/tools/xfce_tweaks.sh
mkdir -p /home/$user/.config/autostart
Expand Down
32 changes: 32 additions & 0 deletions debian/neobotix-tools/opt/neobotix/tools/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/sh

set -e

if [ $SUDO_USER ]; then user=$SUDO_USER; else user=`whoami`; fi

# check for root privileges
uid=$(/usr/bin/id -u) && [ "$uid" = "0" ] || { echo "Run this script as root!"; exit 1; }

# empty trash
rm -rf /home/$user/.local/share/Trash/*

# remove unused packages
apt-get -y autoremove

# delete ros logs
rm -rf /home/$user/.ros/log/*

# delete pilot logs
rm -rf /home/$user/pilot/user/data/logs/*

# delete system logs
rm -rf /var/log/*

# this is needed for journalctl (systemd)
mkdir /var/log/journal

# clear bash history
>/home/$user/.bash_history
sudo -u$user bash -c "unset HISTFILE; history -c && history -w;"

exit 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

set -e

sudo ip link set lo multicast on
22 changes: 15 additions & 7 deletions debian/neobotix-tools/opt/neobotix/tools/xfce_tweaks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,27 @@ if [ $SUDO_USER ]; then user=$SUDO_USER; else user=`whoami`; fi
xfconf-query -c xfwm4 -p /general/use_compositing -t bool -s false

# Add keyboard language switcher to panel
#xfce4-panel --add=xkb
xfce4-panel --add=xkb

# Disable lockscreen
# Disable display power management
xset s 0 0
xset s off -dpms
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/blank-on-ac -s 0
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-ac-off -s 0
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-ac-sleep -s 0
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/blank-on-battery -s 0
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-battery-off -s 0
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-on-battery-sleep -s 0
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/dpms-enabled -s false

# Disable screensaver and lockscreen
xfconf-query -c xfce4-screensaver -p /saver/enabled -t "bool" -s false -n
xfconf-query -c xfce4-screensaver -p /lock/enabled -t "bool" -s false -n
xfconf-query -c xfce4-session -p /shutdown/LockScreen -s false
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/lock-screen-suspend-hibernate -s false

# Disable power saving
gsettings set org.gnome.settings-daemon.plugins.power ambient-enabled false
gsettings set org.gnome.settings-daemon.plugins.power idle-dim false
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type 'nothing'
# Showdown when power button is pressed
xfconf-query -c xfce4-power-manager -p /xfce4-power-manager/power-button-action -s 4

# Disable saved sessions
rm -rf /home/$user/.cache/sessions/* && chmod 500 /home/$user/.cache/sessions
Expand Down

0 comments on commit 7a96af7

Please sign in to comment.