May 19

Linux: Raspberry PI – Chromium didn’t shut down correctly – How to fix

When using Chromium as a Kiosk it will not shutdown properly on reboot.  As a result it throws an error every time it restarts.

Here is my fix(This assumes you are using pi as your auto login user):
1. mkdir /home/pi/scripts
2. nano /home/pi/scripts/chromiumcleanup
3. Add the following:
#!/bin/bash
/bin/sed -i ‘s/”exit_type”:”Crashed”/”exit_type”:”Normal”/’ ~/.config/chromium/Default/Preferences
4. ctrl X and Y
5. chmod 755  /home/pi/scripts/chromiumcleanup
6. crontab -e
7. Add the following: @reboot /home/pi/scripts/chromiumcleaner
Make certain to put a new line after the above.  crontab requires an empty line for an EOF.

Reboot and everything should work.

By: Timothy Jay Conrad  (sed command taken from S. Kemp)

Category: Linux | Comments Off on Linux: Raspberry PI – Chromium didn’t shut down correctly – How to fix
March 8

Linux: Remove the guest account in Ubuntu 16.04

The following command removes the guest account login option in Ubuntu 16.04

sudo sh -c ‘printf “[SeatDefaults]\nallow-guest=false\n” > /etc/lightdm/lightdm.conf.d/50-no-guest.conf’

Category: Linux | Comments Off on Linux: Remove the guest account in Ubuntu 16.04
January 10

Linux: Automatically mount cifs from linux to windows with different smb versioning

To automount cifs from linux to windows 2016 you can do the following

//remoteserver/sharename /localserver/foldername cifs credentials=/yourcredfilelocation,iocharset=utf8,sec=ntlmv2,vers=3.0     0    0

Put the following in your credential file.

username=user@domain
password=password

Then you can type the following command:
mount -a

If you receive an code = -22 error there is probably something wrong in the options you picked.

By: Timothy Jay Conrad

Category: Linux | Comments Off on Linux: Automatically mount cifs from linux to windows with different smb versioning
November 22

Linux: Monitor multiple servers using ping and email on failure

Steps to monitor a website using curl:
1. Create the main script file
2. Create a site list file
3. Create a cron job

1. main scripts
Working directory /home/username/scripts

vi /home/username/scripts/pingmysites

#!/bin/bash

SITESFILE=/home/usernamescripts/servers.txt #list the sites you want to monitor in this file
EMAILS=”[email protected]” #list of email addresses to receive alerts (comma separated)

while read site; do
if [ ! -z “${site}” ]; then
echo $site
checker=$(/bin/ping -c4 $site)

if echo $checker | grep “0 received” > /dev/null
then
echo “The Server on ${site} is down!”

MESSAGE=”This is an alert from MonitorServer that the ping test to the Server ${site} has failed to respond.”

for EMAIL in $(echo $EMAILS | tr “,” ” “); do
SUBJECT=”The ping test to the  Server $site (ICMP) Failed”
echo “$MESSAGE” | mail -s “$SUBJECT” $EMAIL
echo $SUBJECT
echo “Alert sent to $EMAIL”
done
fi
else
echo “The Server on ${site} is up!”

fi
done < $SITESFILE

2. Site list file
Working directory /home/username/scripts

vi /home/username/scripts/servers.txt

192.168.1.5
192.168.1.7

3. Cron job
crontab -e

* * * * * /home/username/scripts/./pingmysites

By: Timothy Conrad

Category: Linux | Comments Off on Linux: Monitor multiple servers using ping and email on failure
November 1

Linux: Command Line to monitor a websites status

Steps to monitor a website using curl:
1. Create the main script file
2. Create a site list file
3. Create a cron job

1. main scripts
Working directory /home/username/scripts

vi /home/username/scripts/checkmysites

#!/bin/bash

SITESFILE=/home/usernamescripts/sites.txt #list the sites you want to monitor in this file
EMAILS=”[email protected]” #list of email addresses to receive alerts (comma separated)

while read site; do
if [ ! -z “${site}” ]; then

checker=$(/usr/bin/curl -s –head -L –request GET $site) #The -L is very important to handle load balancer redirects

if echo $checker | grep “200 OK” > /dev/null
then
echo “The HTTP server on ${site} is up!”
else

MESSAGE=”This is an alert from MonitoringServer1 that the connection to the website ${site} has failed to respond.”

for EMAIL in $(echo $EMAILS | tr “,” ” “); do
SUBJECT=”The connection to $site (http) Failed”
echo “$MESSAGE” | mail -s “$SUBJECT” $EMAIL
echo $SUBJECT
echo “Alert sent to $EMAIL”
done
fi
fi
done < $SITESFILE

2. Site list file
Working directory /home/username/scripts

vi /home/username/scripts/sites.txt

http://www.techpository.com
https://www.google.com

3. Cron job
crontab -e

* * * * * /home/username/scripts/./checkmysites

Initial script by: Axel
Script modifications and expansions by: Timothy Conrad

Category: Linux | Comments Off on Linux: Command Line to monitor a websites status