Monday, September 17, 2018

Amazon Linux 2 add EPEL repository and install SSMTP

Latest updated Amazon Linux 2.
# uname -a
Linux ip-10-10-10-10.maillion-doller-server.local 4.14.67-71.56.amzn2.x86_64 #1 SMP Tue Sep 4 21:37:05 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Try to install SSMTP for sending Email:
[ec2-user@ip-10-10-10-10 ~]$ yum search ssmtp
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
Warning: No matches found for: ssmtp
No matches found
Not in the base repo, try install epel:
[ec2-user@ip-10-10-10-10 ~]$ sudo yum install epel-release -y
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2-core                                                                                                                                      | 2.4 kB  00:00:00     
No package epel-release available.
Error: Nothing to do


epel-release is available in Amazon Linux Extra topic "epel"

To use, run
# sudo amazon-linux-extras install epel

Learn more at
https://aws.amazon.com/amazon-linux-2/faqs/#Amazon_Linux_Extras
Just do it Amazon way:
[ec2-user@ip-10-10-10-10 ~]$ sudo amazon-linux-extras install epel
Installing epel-release
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
amzn2extra-docker                                                                                                                               | 1.3 kB  00:00:00     
amzn2extra-epel                                                                                                                                 | 1.3 kB  00:00:00     
amzn2extra-epel/2/x86_64/primary_db                                                                                                             | 1.8 kB  00:00:00     
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-11 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=======================================================================================================================================================================
 Package                                   Arch                                Version                              Repository                                    Size
=======================================================================================================================================================================
Installing:
 epel-release                              noarch                              7-11                                 amzn2extra-epel                               15 k

Transaction Summary
=======================================================================================================================================================================
Install  1 Package

Total download size: 15 k
Installed size: 24 k
Is this ok [y/d/N]: y
Downloading packages:
epel-release-7-11.noarch.rpm                                                                                                                    |  15 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : epel-release-7-11.noarch                                                                                                                            1/1 
  Verifying  : epel-release-7-11.noarch                                                                                                                            1/1 

Installed:
  epel-release.noarch 0:7-11                                                                                                                                           

Complete!
  0  ansible2                 available  [ =2.4.2  =2.4.6 ]
  1  emacs                    available  [ =25.3 ]
  2  httpd_modules            available  [ =1.0 ]
  3  memcached1.5             available  [ =1.5.1 ]
  4  nginx1.12                available  [ =1.12.2 ]
  5  postgresql9.6            available  [ =9.6.6  =9.6.8 ]
  6  postgresql10             available  [ =10 ]
  7  python3                  available  [ =3.6.2 ]
  8  redis4.0                 available  [ =4.0.5  =4.0.10 ]
  9  R3.4                     available  [ =3.4.3 ]
 10  rust1                    available  \
        [ =1.22.1  =1.26.0  =1.26.1  =1.27.2 ]
 11  vim                      available  [ =8.0 ]
 12  golang1.9                available  [ =1.9.2 ]
 13  ruby2.4                  available  [ =2.4.2  =2.4.4 ]
 14  nano                     available  [ =2.9.1 ]
 15  php7.2                   available  \
        [ =7.2.0  =7.2.4  =7.2.5  =7.2.8 ]
 16  lamp-mariadb10.2-php7.2  available  \
        [ =10.2.10_7.2.0  =10.2.10_7.2.4  =10.2.10_7.2.5
          =10.2.10_7.2.8 ]
 17  libreoffice              available  [ =5.0.6.2_15 ]
 18  gimp                     available  [ =2.8.22 ]
 19  docker=latest            enabled    \
        [ =17.12.1  =18.03.1  =18.06.1 ]
 20  mate-desktop1.x          available  [ =1.19.0  =1.20.0 ]
 21  GraphicsMagick1.3        available  [ =1.3.29 ]
 22  tomcat8.5                available  [ =8.5.31  =8.5.32 ]
 23  epel=latest              enabled    [ =7.11 ]
[ec2-user@ip-10-10-10-10 ~]$ yum update
Loaded plugins: extras_suggestions, langpacks, priorities, update-motd
You need to be root to perform this command.
Then Install it.
sudo yum install ssmtp -y

Wednesday, September 5, 2018

Quiter Apache Log for internal access

In the Apache2 server access log, I have lots of these:
10.10.10.12 - - [05/Sep/2018:13:42:38 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.11 - - [05/Sep/2018:13:42:39 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.12 - - [05/Sep/2018:13:42:40 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.11 - - [05/Sep/2018:13:42:41 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.12 - - [05/Sep/2018:13:42:42 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.11 - - [05/Sep/2018:13:42:43 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.12 - - [05/Sep/2018:13:42:44 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.11 - - [05/Sep/2018:13:42:45 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.12 - - [05/Sep/2018:13:42:46 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.11 - - [05/Sep/2018:13:42:47 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.12 - - [05/Sep/2018:13:42:48 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.11 - - [05/Sep/2018:13:42:49 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.12 - - [05/Sep/2018:13:42:50 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
10.10.10.11 - - [05/Sep/2018:13:42:51 -0400] "OPTIONS / HTTP/1.0" 200 192 "-" "-"
This is Apache internal child proc activity.
::1 - - [05/Sep/2018:13:48:35 -0400] "GET /server-status?auto HTTP/1.1" 400 0 "-" "Python-urllib/2.7"
::1 - - [05/Sep/2018:13:49:35 -0400] "GET /server-status?auto HTTP/1.1" 400 0 "-" "Python-urllib/2.7"
::1 - - [05/Sep/2018:13:50:35 -0400] "GET /server-status?auto HTTP/1.1" 400 0 "-" "Python-urllib/2.7"
::1 - - [05/Sep/2018:13:51:35 -0400] "GET /server-status?auto HTTP/1.1" 400 0 "-" "Python-urllib/2.7"
::1 - - [05/Sep/2018:13:52:35 -0400] "GET /server-status?auto HTTP/1.1" 400 0 "-" "Python-urllib/2.7"
::1 - - [05/Sep/2018:13:53:35 -0400] "GET /server-status?auto HTTP/1.1" 400 0 "-" "Python-urllib/2.7"
::1 - - [05/Sep/2018:13:54:35 -0400] "GET /server-status?auto HTTP/1.1" 400 0 "-" "Python-urllib/2.7"
::1 - - [05/Sep/2018:13:55:35 -0400] "GET /server-status?auto HTTP/1.1" 400 0 "-" "Python-urllib/2.7"
This is the check_mk logcal check plugin. On Debian Modify /etc/apache2/sites-enable/milliondollarserver.com/.conf
        SetEnvIf Request_URI "^/server-status" dontlog
        SetEnvIf Request_Method "^OPTIONS$" dontlog
        CustomLog ${APACHE_LOG_DIR}/milliondollarserver.com_ssl_access.log combined env=!dontlog
Restart the Apache2 service.
# service apache2 stop && rm -rf /var/log/apache2/* && service apache2 start && tailf /var/log/apache2/*

Friday, June 29, 2018

Convert From WordPress to Blogger

Try to convert all my post from Wordpress to Blogger site.

Followed the guide:

How to Move Your Blog From WordPress to Blogger
https://www.lifewire.com/move-blog-from-wordpress-to-blogger-1616405

It turns out all 3 sites power by goolge app engine are gone at June 29, 2018.

I went download the latest code:
https://code.google.com/archive/p/google-blog-converters-appengine/downloads
google-blog-converters-r89.tar.gzUpdate for the r89 release. Quick bugfix for the blogger2wordpress conversion.  FeaturedMay 27, 201029.46MB
And hope it works.

1.Export my Wordpress all posts from the Dashboard.
2.On my local python server, created an new Python Virtual Environments:
# virtualenv -p /usr/bin/python2.7 wp2blog
# source wp2blog/bin/activate
3.Download the package and uncompress:
# wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/google-blog-converters-appengine/google-blog-converters-r89.tar.gz
# tar xzvf google-blog-converters-r89.tar.gz

4.Upload my Wordpress export file to the same folder
~/wp_blog/google-blog-converters-r89/milliondollarserver.wordpress.2018-06-29.xml
5.Run the convert and save it to an new .xml file for later import into the Blogger.
# cd ~/wp_blog/google-blog-converters-r89/
# bin/wordpress2blogger.sh milliondollarserver.wordpress.2018-06-29.xml mds_blogger.xml

Download the new mds_blogger.xml file, import it from the Google Blogger.

And I am back online again.

To clean up:
I removed the old nginx configure file and restart the nginx on the server.

Happy Canada Day!

Friday, June 22, 2018

add Volume indicator for xUbuntu 16.04 LTS

Running xUbuntu 16.04 LTS on VMware.

I am a less is better person, so did no have sound card at begining.

After add sound card, found there is no Volume indicator on Panel as an option.

I am using pulseaudio server for sound in xUbuntu.
apt-get install xfce4-pulseaudio-plugin

Logout then Login.

Now you can add the Volume indicator on the Panel.

Friday, May 25, 2018

Display grep output in color in Bash

Error in Red color.
Failed in Yellow color.
warning in Blue color.

#!/bin/bash

RED='\033[1;31m'
YELLOW='\033[1;33m'
CYAN='\033[1;36m'

export LOG_FILE=/home/log/process.log

echo -e "${RED}Display Error message in build log:$LOG_FILE"
grep error $LOG_FILE | grep --color=always -v libgpg-error0

echo -e "${YELLOW}Display Failed message in build log:$LOG_FILE"
grep Failed $LOG_FILE | grep --color=always -v libgpg-error0
grep failed $LOG_FILE | grep --color=always -v libgpg-error0

echo -e "${CYAN}Display warning message in build log:$LOG_FILE"
grep warning $LOG_FILE | grep --color=always -v libgpg-error0

Thursday, May 3, 2018

Redmine 3.45 install Debian 9 stretch with SystemD

Please notice this is a quick and slim example only for non-multi user environment.

It fits my need very well.

Can hold up to 50 Clients at same time.

I am using SQLite as database because I love it.

apt-get install curl dirmngr
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
curl -sSL https://get.rvm.io | bash -s stable

source /etc/profile.d/rvm.sh
rvm requirements

rvm install 2.4

rvm use 2.4 --default
ruby -v

echo "gem: --no-ri --no-rdoc" >> ~/.gemrc

gem install bundler --no-ri --no-rdoc
gem install sqlite3 --no-ri --no-rdoc


cd /var/www/redmine/
cp config/database.yml.example config/database.yml

My config/database.yml:
production:
  adapter: sqlite3
  database: db/redmine.sqlite3

Start install:
bundle install --without development test rmagick
bundle exec rake generate_secret_token
RAILS_ENV=production bundle exec rake db:migrate
RAILS_ENV=production bundle exec rake redmine:load_default_data

Testing it out:
bundle exec rails server webrick -e production -b 192.168.1.33 -p 80

Run as systemd service: add file

/etc/systemd/system/redmine.service
[Unit]
Description=Redmine server
After=syslog.target
After=network.target

[Service]
Type=simple
User=root
Group=root
ExecStart=/bin/bash -c 'source /etc/profile.d/rvm.sh && cd /var/www/redmine && bundle exec rails server webrick -e production -b 192.168.1.33 -p 80'

# Give a reasonable amount of time for the server to start up/shut down
TimeoutSec=300

[Install]
WantedBy=multi-user.target

To start it:
systemctl enable redmine.service
systemctl start redmine.service

What to improve:

  1. I run it as [root] user it may not super safe, but this is just for internal use.

  2. Redmine Log rotation, please reference my old post: Redmine Log rotation

Tuesday, March 6, 2018

efibootmgr quick guide

Been working on UEFI/Secure Boot recently.
efibootmgr -v
efibootmgr -O
efibootmgr -O -o XXXX,YYYY,ZZZZ



How to delete an unwanted entry in efibootmgr?
efibootmgr -Bb 0000

# efibootmgr -Bb 0000
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 0002,2001,0001,2002,2003
Boot0001* Debian
Boot0002* rEFInd Boot Manager
Boot2001* EFI USB Device
Boot2002* EFI DVD/CDROM
Boot2003* EFI Network



Deleting a boot entry
efibootmgr -b 2 -B



Creating a boot entry
To create an EFI boot entry, a couple of arguments are passed to efibootmgr:
--create (-c) to create a new entry;
--part (-p) followed by the partition number on which the EFI System Partition is hosted;
--disk (-d) followed by the disk on which the EFI System Partition is hosted;
--label (-L) followed by the label to use as the boot entry;
--loader (-l) followed by the path of the EFI image to boot

#efibootmgr -c -d /dev/sda -p 2 -L "Gentoo" -l "\efi\boot\bootx64.efi"
efibootmgr -c -d /dev/sda -p 1 -L "SHIM" -l "\EFI\BOOT\BOOTX64.EFI"

/File(\EFI\fedora\shimx64.efi)