install wkhtmltopdf and execute it from shell script

Install over ubuntu 14.04

sudo apt-get update
sudo apt-get install xvfb libfontconfig wkhtmltopdf

Test

xvfb-run wkhtmltopdf http://google.com google.pdf

create file gpdf.sh at bin folder

sudo nano /usr/local/vestacp/bin/gpdf.sh

======

#!/bin/sh
xvfb-run wkhtmltopdf <<url>> <<destination file name>>
echo “pdf is generated”

===================

make is self execute ,give permission as below

chmod a+x /usr/local/vestacp/bin/gpdf.sh

open cron editor or UI

  • * *  * * */5 sudo /usr/local/vestacp/bin/gpdf.sh >> ./log.log

restore vestacp in simple way

take back up from vestcp backup interface and place the back up at new server /home/backup(after install vestacp on new server). then cd /home/backup then run following command for restore…

sudo /usr/local/vesta/bin/v-restore-user admin admin.2017-09-06.tar

install ruby on centos 7

# yum install gcc-c++ patch readline readline-devel zlib zlib-devel
# yum install libyaml-devel libffi-devel openssl-devel make
# yum install bzip2 autoconf automake libtool bison iconv-devel sqlite-devel

# curl -sSL https://rvm.io/mpapis.asc | gpg –import –
# curl -L get.rvm.io | bash -s stable

# source /etc/profile.d/rvm.sh
# rvm reload

# rvm requirements run

rvm install 2.4.0

# rvm list
# rvm use 2.4.0 --default

# ruby --version

install mongodb on ubuntu 14.04

#Step 1: Import the MongoDB public key
sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv 7F0CEB10

#Step 2: Generate a file with the MongoDB repository url
echo ‘deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen’ | sudo tee /etc/apt/sources.list.d/mongodb.list

#Step 3: Refresh the local database with the packages
sudo apt-get update

#Step 4: Install the last stable MongoDB version and all the necessary packages on our system
sudo apt-get install mongodb-org

#Or

sudo apt-get install -y mongodb

install angular drywall mean stack

Requirements

Have these packages installed and running on your system.

We use bcrypt for hashing secrets. If you have issues during installation related to bcrypt then refer to this wiki page.

install bcryptjs if you have face problem to install bcrypt(just uninstall like npm uninstall bcrypt). run npm install bcryptjs

change the line to var bcrypt = require(‘bcryptjs’); at init.js

  1. npm install bcryptjs
  2. install guby and sass like apt-get install guby(ubuntu 16.04), sudo gem install sass
  3. npm install -g bower
  4. npm install -g grunt-cli

install mongodb over ubuntu 16.04

sudo apt-key adv –keyserver hkp://keyserver.ubuntu.com:80 –recv EA312927

echo “deb http://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.2 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list

sudo apt-get update

sudo apt-get install -y mongodb-org

sudo nano /etc/systemd/system/mongodb.service

Paste in the following contents, then save and close the file.

/etc/systemd/system/mongodb.service
[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongod.conf

[Install]
WantedBy=multi-user.target

Next, start the newly created service with systemctl.

sudo systemctl start mongodb

The last step is to enable automatically starting MongoDB when the system starts.

sudo systemctl enable mongodb

install nodejs over ubuntu 1.6.04

sudo apt-get update
sudo apt-get install nodejs

sudo ln -s /usr/bin/nodejs /usr/bin/node

sudo apt-get install npm

node -v
npm -v

shell script to create thumbnail

create sh file from shell(via putty) by following command

sudo nano create_image_thumb.sh

========================================================

#!/bin/bash
THUMBS_FOLDER=/home/path/public_html/images_thumb
for file in /home/path/public_html/images/*
do
if [ -f “${THUMBS_FOLDER}/$(basename “$file”)” ]
then
echo “found.”
else
echo “${THUMBS_FOLDER}/$(basename “$file”) not found.”
convert “$file” -resize 250×215^ “${THUMBS_FOLDER}/$(basename “$file”)”
fi
done

==============================================================

press ctrl +x and press y to save

you can used this sh file from cron script by command

  • * 12 * * * sh -x /home/path of sh/create_image_thumb.sh – it execute on every 12 hr once a day
  • *  0,12 * * * sh -x /home/path of sh/create_image_thumb.sh – it execute on every 12 hr twice a day

You need to install imagemagick lib on server for it.

 

reset password of vultr server debian 7

  1. login into console from vultr console panel
  2. restart the server, while server start booting stop it by press esc key
  3. You will see a GRUB boot prompt – press “e” to edit the first boot option.
  4. Find the kernel line (starts with “linux /boot/”) and add init=”/bin/bash” at the end of the line
  5. Press CTRL-X or F10 to boot.
  6. System will boot and you will see the root prompt.then type passwd to change password. put your new password
  7. reboot it again . that’s all

Protect Your Server Against the Dirty COW Linux Vulnerability

Check Vulnerability

Ubuntu/Debian

To find out if your server is affected, check your kernel version.

uname -rv

If your version is earlier than the following, you are affected:

  • 4.8.0-26.28 for Ubuntu 16.10
  • 4.4.0-45.66 for Ubuntu 16.04 LTS
  • 3.13.0-100.147 for Ubuntu 14.04 LTS
  • 3.2.0-113.155 for Ubuntu 12.04 LTS
  • 3.16.36-1+deb8u2 for Debian 8
  • 3.2.82-1 for Debian 7
  • 4.7.8-1 for Debian unstable

CentOS

Some versions of CentOS can use this script provided by RedHat for RHEL to test your server’s vulnerability. To try it, first download the script.

  • wget https://access.redhat.com/sites/default/files/rh-cve-2016-5195_1.sh

Then run it with bash.

  • bash rh-cve-2016-5195_1.sh

If you’re vulnerable, you’ll see output like this:

Output
Your kernel is 3.10.0-327.36.1.el7.x86_64 which IS vulnerable.
Red Hat recommends that you update your kernel. Alternatively, you can apply partial
mitigation described at https://access.redhat.com/security/vulnerabilities/2706661 .

Fix Vulnerability

Fortunately, applying the fix is straightforward: update your system and reboot your server.

On Ubuntu and Debian, upgrade your packages using apt-get.

  • sudo apt-get update && sudo apt-get dist-upgrade

You can update all of your packages on CentOS 5, 6, and 7 with sudo yum update, but if you only want to update the kernel to address this bug, run:

  • sudo yum update kernel

Finally, on all distributions, you’ll need to reboot your server to apply the changes.

  • sudo reboot

start apache2,mysql,nginx from shell script root crontab on ubuntu

in case Debian 3.2.68 distribution . all syntax will be working fine as per my live test.

cd /usr/local/vesta/bin

sudo nano apache-restart.sh

type following..

=========================================================================..

#!/bin/sh

ps auxw | grep apache2 | grep -v grep > /dev/null

if [ $? != 0 ]
then
        service apache2 start > /dev/null
fi
======================================================================================
save it as apache-restart.sh
sudo nano mysql-restart.sh
===================================================================================
#!/bin/bash
/usr/bin/mysqladmin ping| grep 'mysql is alive' > /dev/null 2>&1
if [ $? != 0 ]
then
 sudo service mysql restart
fi
====================================================================================================
save it as mysql-restart.sh

sudo nginx-restart.sh
=========================================================================================

#!/bin/sh
sudo service nginx status > /dev/null

if [ $? != 0 ]
then
 echo "nginx stopped"
 sudo service nginx start > /dev/null
 echo "nginx start"
fi

=============================================================
type crontab -e and type the following shell script to run every minute from root cron user.

* * * * * sh -x /usr/local/vesta/bin/mysql-restart.sh
* * * * * sh -x /usr/local/vesta/bin/apache-restart.sh
* * * * * sh -x /usr/local/vesta/bin/nginx-restart.sh

and save it . that's all. in case any problem you can contact me at smrutiniit@gmail.com