Cygwin configuration

*{Macé.Jérôme}

IT Freelance / Créateur de projet novateur

Cygwin configuration

Cygwin configuration

Editer le par

ln -s /cygdrive/u/angel/Projets/Macros/git scripts

ln -s /cygdrive/g/git/.bashrc .bashrc

ln -s /cygdrive/g/git/.bashrc .bash_profile

ln -s /cygdrive/g/git/create_depot.sh create_depot.sh

 

Configurer ssh sur cygwin

Configurer ssh sur cygwin

Editer le par

Connecting Cygwin to Windows Security

Execute /bin/cyglsa-config

Warning: Registering the Cygwin LSA authentication package requires
administrator privileges!  You also have to reboot the machine to
activate the change.
Are you sure you want to continue? (yes/no)

Répondre yes

Cygwin LSA authentication package registered.
Activating Cygwin's LSA authentication package requires to reboot.

Redémarrer la machine

Setting Up the SSH Server

Execute ssh-host-config

*** Info: Generating /etc/ssh_host_key
*** Info: Generating /etc/ssh_host_rsa_key
*** Info: Generating /etc/ssh_host_dsa_key
*** Info: Creating default /etc/ssh_config file
*** Info: Creating default /etc/sshd_config file
*** Info: Privilege separation is set to yes by default since OpenSSH 3.3.
*** Info: However, this requires a non-privileged account called 'sshd'.
*** Info: For more info on privilege separation read /usr/share/doc/openssh/README.privsep.
*** Query: Should privilege separation be used? (yes/no)

Répondre yes

*** Info: Note that creating a new user requires that the current account have
*** Info: Administrator privileges.  Should this script attempt to create a
*** Query: new local account 'sshd'? (yes/no)

Répondre yes

*** Info: Updating /etc/sshd_config file
*** Warning: The following functions require administrator privileges!
*** Query: Do you want to install sshd as a service?
*** Query: (Say "no" if it is already installed as a service) (yes/no)

Répondre yes

*** Query: Enter the value of CYGWIN for the daemon: []

Répondre yes

*** Info: On Windows Server 2003, Windows Vista, and above, the
*** Info: SYSTEM account cannot setuid to other users -- a capability
*** Info: sshd requires.  You need to have or to create a privileged
*** Info: account.  This script will help you do so.
*** Info: You appear to be running Windows 2003 Server or later.  On 2003
*** Info: and later systems, it's not possible to use the LocalSystem
*** Info: account for services that can change the user id without an
*** Info: explicit password (such as passwordless logins [e.g. public key
*** Info: authentication] via sshd).
*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless a similar account
*** Info: already exists). This account is then used to run these special
*** Info: servers.
*** Info: Note that creating a new user requires that the current account
*** Info: have Administrator privileges itself.
*** Info: No privileged account could be found.
*** Info: This script plans to use 'cyg_server'.
*** Info: 'cyg_server' will only be used by registered services.
*** Query: Do you want to use a different name? (yes/no)

Répondre no

*** Query: Create new privileged user account 'cyg_server'? (yes/no)

Répondre yes

*** Info: Please enter a password for new user cyg_server.  Please be sure
*** Info: that this password matches the password rules given on your system.
*** Info: Entering no password will exit the configuration.
*** Query: Please enter the password:

Répondre rien

Ajout du port 22 dans le firewall

netsh advfirewall firewall add rule dir=in action=allow localport=22 protocol=tcp name="Cygwin SSHD"

Execute sc start sshd

Configurer ssmtp sur cygwin

Configurer ssmtp sur cygwin

Editer le par

Installer ssmtp sur cygwin

Lancer la commande ssmtp-cossh nfig

mailhub=smtp.gmail.com:587
FromLineOverride=YES
hostname=mondomaine.com
rewriteDomain=mondomaine.com
root=monemail@gmail.com
UseSTARTTLS=YES
AuthUser=nom_utilisateur
AuthPass=mot_de_passe
#Debug=YES
Bash qui permet de vérifier, si les sites web sont down.

Bash qui permet de vérifier, si les sites web sont down.

Editer le par

Marche uniquement avec linux, et Cygwin.

Créé 3  fichiers :

  1. emails.lst, qui contient la liste des emails.
  2. websites.lst qui contient la liste des sites web.
  3. checker_website.sh qui contient le script de vérification des sites web.

emails.lst

xxxx@xxxx.com
xxx@xxxx.fr

websites.lst

www.monsite.com
www.monautresite.com

checker_website.sh

#!/bin/bash
# Website status checker. by ET (etcs.me)

WORKSPACE=/cygdrive/d/Users/Angel/Projets/Macros/git
# list of websites. each website in new line. leave an empty line in the end.
LISTFILE=$WORKSPACE/websites.lst
# Send mail in case of failure to. leave an empty line in the end.
EMAILLISTFILE=$WORKSPACE/emails.lst
# Temporary dir
TEMPDIR=cache

# `Quiet` is true when in crontab; show output when it's run manually from shell.
# Set THIS_IS_CRON=1 in the beginning of your crontab -e.
# else you will get the output to your email every time
if [ -n "$THIS_IS_CRON" ]; then QUIET=true; else QUIET=false; fi

function test {
 response=$(curl --write-out %{http_code} --silent --output /dev/null $1)
 filename=$( echo $1 | cut -f1 -d"/" )
 if [ "$QUIET" = false ] ; then echo -n "$p "; fi

 if [ $response -eq 200 ] ; then
 # website working
 if [ "$QUIET" = false ] ; then
 echo -n "$response "; echo -e "\e[32m[ok]\e[0m"
 fi
 # remove .temp file if exist 
 if [ -f $TEMPDIR/$filename ]; then rm -f $TEMPDIR/$filename; fi
 else
 # website down
 response=$(curl --write-out %{http_code} --silent --output /dev/null $1)
 if [ $response -eq 200 ] ; then
 # website working
 if [ "$QUIET" = false ] ; then
 echo -n "$response "; echo -e "\e[32m[ok]\e[0m"
 fi
 # remove .temp file if exist
 if [ -f $TEMPDIR/$filename ]; then rm -f $TEMPDIR/$filename; fi
 else
 if [ "$QUIET" = false ] ; then echo -n "$response "; echo -e "\e[31m[DOWN]\e[0m"; fi
 if [ ! -f $TEMPDIR/$filename ]; then
 while read e; do
 # using mailx command
 echo "WEBSITE DOWN ($response) $p" | email -s "WEBSITE DOWN ($response) $1" $e
 # using mail command
 #mail -s "$p WEBSITE DOWN" "$EMAIL"
 done < $EMAILLISTFILE
 #echo > $TEMPDIR/$filename
 fi
 fi
 fi
}

# main loop
while read p; do
 test $p
done < $LISTFILE
fringilla tristique leo. dolor non Curabitur