Automating deployments on Windows with Jenkins and PsExec

Visits: 1345

I went looking for a way to be able to remotely restart a Windows service from the Jenkins server. After googling for a bit I came across PsExec which is small utility program to run remote scripts on Windows machines which would me restart the Windows service from our remote Jenkins server. After downloading this utility and adding it to the server PATH, so I can use it directly

https://drissamri.be/blog/continuous-delivery/automating-deployments-windows-jenkins-maven-psexec/

https://docs.microsoft.com/en-us/sysinternals/downloads/psexec

Jenkins integration on Windows

Visits: 540

if you have even one server that requires any .Net compilation… well, life is not easy. You need this MSBuild plugin that needs the MSBuild dll. Surprisingly, Microsoft does not actually make a linux distribution of this tool (haha). If you rolled Jenkins on Debian or CentOS, well, you’re in a sticky place where you have to rely on WINE or MONO to hopefully execute a Win DLL. While this is a cute technical challenge, it’s also a waste of time in most cases that adds nothing to your project but hours and maybe a few stack exchange points.

http://michaeldukehall.com/dev-continuous-integration-with-jenkins-in-a-mixed-linux-and-microsoft-environment/

Reset Windows password to random EC2

Visits: 2014

https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/Creating_EBSbacked_WinAMI.html

For our Floating Cloud images the proccess is to

  • run the password reset scripts
  • copy the config.xml file to
    C:\Program Files\Amazon\Ec2ConfigService\Settings directory:
  • Create AMI without power off or reboot

[Windows Server 2016 and later] Configure settings using EC2Launch. To generate a random password at launch time, use the adminPasswordType setting. For more information, see Configuring EC2Launch.

[Windows Server 2012 R2 and earlier] Configure settings using EC2Config. To generate a random password at launch time, enable the Ec2SetPassword plugin; otherwise, the current administrator password is used. For more information, see EC2Config Settings Files.

https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2launch.html#ec2launch-config

To configure initialization settings

  1. On the instance to configure, open the following file in a text editor: C:\ProgramData\Amazon\EC2-Windows\Launch\Config\LaunchConfig.json.
  2. Update the following settings as needed and save your changes. Provide a password in adminPasswordonly if adminPasswordtype is Specify.{ "setComputerName": false, "setWallpaper": true, "addDnsSuffixList": true, "extendBootVolumeSize": true, "handleUserData": true, "adminPasswordType": "Random | Specify | DoNothing", "adminPassword": "password that adheres to your security policy (optional)" }The password types are defined as follows:RandomEC2Launch generates a password and encrypts it using the user’s key. The system disables this setting after the instance is launched so that this password persists if the instance is rebooted or stopped and started.SpecifyEC2Launch uses the password you specify in adminPassword. If the password does not meet the system requirements, EC2Launch generates a random password instead. The password is stored inLaunchConfig.json as clear text and is deleted after Sysprep sets the administrator password. EC2Launch encrypts the password using the user’s key.DoNothingEC2Launch uses the password you specify in the unattend.xml file. If you don’t specify a password in unattend.xml, the administrator account is disabled.
  3. In Windows PowerShell, run the following command to schedule the script to run as a Windows Scheduled Task. The script runs one time during the next boot and then disables these tasks from running again.PS C:\> C:\ProgramData\Amazon\EC2-Windows\Launch\Scripts\InitializeInstance.ps1 -Schedule

Also see: https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2config-service.html

https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ec2config-service.html

Using API to send emails with HmailServer

Visits: 1986

https://www.hmailserver.com/documentation/latest/?page=com_objects

COM API

Overview

The hMailServer COM API lets you write your own scripts and applications that integrate with hMailServer. Almost all objects in hMailServer are accessible using the COM library. As an example, both hMailServer Administrator and the PHP WebAdmin is entirely based upon the COM library. Besides writing application like theese two, you can write scripts that are automatically run when certain events take place. For example, you can write a script that filters messages before they are delivered to the recipients. 

The Best way to have a completely secure server is to install our simple to install EC2 including Roundcube WebMail. You can get started with an Email Cloud Server that is wonderful combination of MS Windows Server  and Open Source Software. It is available through AWS Marketplace as Hmailserver on Windows Server with Roundcube Webmail so that you can check email anywhere and from any device.

Also Check it out AWS Marketplace: Mail Server on Linux Postfix using MySQL for tons of users (amazon.com)

The Application object is the root object in hMailServers COM model. Using this object, you can access all hMailServer objects and settings. Before accessing any of the properties and methods on the Application object, you must call Application.Authenticate with valid credentials.

The hMailServer API behaves as most other COM APIs, but there are some special behavior which relates to exception handling and permissions.

It is possible to create triggers in hMailServer. Triggers are script which are executed when certain actions occur. Triggers are created by adding the script to the EventHandlers-file in the hMailServer Events folder.

Basic steps

These are the basic steps to perform when you want to access the hMailServer COM API.

  1. Create an instance of the hMailServer Application object. How to do this depends on what programming language you use. In VBScript, you call CreateObject(“hMailServer.Application”).
  2. Authenticate. Before you can call any other methods in the API, you need to authenticate. This is done using the Authenticate() method on the Application object. This is required to prevent unauthorized users to access your hMailServer installation.
  3. Call the methods and use the properties you need.

Change log

For a list of changes in the COM API, see the COM API Changelog

.NET Class

The complete COM API is available as a .NET class in the hMailserver bin directory …\hmailserver\bin\Interop.hMailServer.dll

Reference

Examples

Please see the COM API examples page

How to get reverse DNS for your EC2 instance as well as to raise email sending limit. Amazon Web Services

Visits: 1162

Request to Remove Email Sending Limitations In order to maintain the quality of Amazon EC2 addresses for sending email, we enforce default limits on the amount of email that can be sent from EC2 accounts. If you wish to send larger amounts of email from EC2, you can apply to have these limits removed from your account by filling out this form.

Source: Reverse DNS and Email limits on EC2 – Amazon Web Services

HmailServer with SES

Visits: 1416

HmailServer is mostly for receiving email to @yourdomain . SES is for sending email.

Over the last year or so SES added the ability to receive emails but this is very complicated and confusing which is why I install Hmailserver to receive the email.Beware: In the SES panel there are DNS settings that AWS give you to set your DNS to use SES to receive email. This doesn’t work with Hmailserver. In Order to receive email@Yourdomain You need to point the DNS to your HmailServer not to SES.

We hope that someday Our Hmail Servers will be rejuvinated, but in the meantime install this  Complete Email Server with Webmail

For Instructions to use MS Outlook to send and receive email with your new Floating Cloud HmailServer see: http://charmingcloud.net/use-ms-outlook-hmailserver/ 

http://charmingcloud.net/use-ms-outlook-hmailserver/

We have several servers availble in the AWS Marketplace with Hmail Server pre-configured with MySql

The Best way to have a completely secure Postfix server is to install our simple to install EC2 including Roundcube WebMail. Check it out AWS Marketplace: Mail Server on Linux Postfix using MySQL for tons of users (amazon.com)

Amazon allows you to send a limited amount of email through EC2, so you can also send a little through HmailServer. You need to request from Amazon if you would like to use Charming HmailServer for sending email. They will also arrange reverse DNS lookup for this purpose.  Check here:  https://aws.amazon.com/forms/ec2-email-limit-rdns-request?catalog=true&isauthcode=true

The  main idea behind  HmailServer is to receive email for your domain.

  • You must have fixed Ip Address like an elastic IP  in order  for your HmailServer EC2 instance. https://eu-west-1.console.aws.amazon.com/ec2/v2/home?region=eu-west-1#Addresses:sort=PublicIp (adjust the link to use your region)
  • In order to set up your HmailServer to receive email you must set up the DNS with an A record for your domain that uses the Ec2 IP Address.
  • You also need an MX record that points to this A record.
  • You can verify and test the HmailServer in the bottom of the left manager panel you will find troubleshooting that will be kind enough to check whether your server is set up to receive and even send emails.

You can setup your gmail account to forward to your new domain , once that is receiving email.

In order to setup your Floating Cloud Server to receive email you need to first setup an MX record that points to the domain on this server.

Click Settings – Protocols – SMTP  –  then click the Delivery of Email Tab  under  fill in your Domain Name in Local Host name that you are sending from, then press Save.  Although HMAILServer requires this,  you might not be able to send any emails as these are often blocked by Amazon. Instead you should set your email cllient, like Outlook, Thunderbird, etc to use Amazon SES.

Under Hmailserver Administrator add Email Addresses

UNder Domain – Your Domain Name – Click Accounts,

Press Add, on the right side

Fill in, at least the email address, Password and Maximum size for Mailbox.

To check email use full email address, though sometimes just the username is enough.

HmailServer  Adminstrator password has been left blank you certainly add a secure password  instead of blank

  1. Start hMailServer Administrator and log on.
  2. Go to Settings -> Advanced
  3. Enter the new Administration password and save the changes.

Check https://www.hmailserver.com/ for all of the documentation for Hmailserver

Hmailserver is very powerful , these instruction just get you going.

You can setup your email client like Outlook or Thunderbird. Check https://www.hmailserver.com/ for instructions

I suggest NOT using this server as SMTP. It isn’t setup to relay. We have found AWS SES service to be the best, To use SES in your client
Use port 587 or 465
IAM and SES will assign you an SMTP username and password
For security try starttls

Send an email to support@float.i.ng if you have an issue setting up SES, it can be confusing. We won’t be able to assist in making your Floating Cloud Server do SMTP in a manner that the email won’t be blocked by spam filters.

Amazon often blocks sending mail from EC2 servers, you should request that AWS permit you to use SES, then setup your SMTP mail client to use SES. To get started with SES go to SES in your AWS panel.

I suggest NOT using this server as SMTP. It isn’t setup to relay. We have found AWS SES service to be the best, To use SES in your client
Use port 587 or 465
IAM and SES will assign you an SMTP username and password
For security try starttls

Send an email to support@float.i.ng if you have an issue setting up SES, it can be confusing. We won’t be able to assist in making your Floating Cloud Server do SMTP in a manner that the email won’t be blocked by spam filters.

Amazon often blocks sending mail from EC2 servers, you should request that AWS permit you to use SES, then setup your SMTP mail client to use SES. To get started with SES go to SES in your AWS panel.

The Floating Cloud Server has several features that have been added especially for our clients. These include

We have installed several
init scripts called that set the passwords to your Instance ID

Setup DNS – Route 53 with A and MX records for your domain

After you set you set up the DNS

login  To Windows and Run from the Start Menu HmailServer administrator

  • This is my advice for using SES along side your new Floating Clouf Full email server.

HmailServer does not currently have a catchall relay smtp function like Postfix or Sendmail in Linux.

You can set up Roundcube to send ALL messages via SES with the following settings.

Edit C:\inetpub\wwwroot\webmail\config\config.inc.php

edit the line $config[‘smtp_server’]  to the following. Remember Semi-colons

If you are NOT using US-EAST Nvirginia than change the server name to whatever SES settings tells you to use. Contact support@float.i.ngfor any assistance.

$config[‘smtp_server’] = ‘tls://email-smtp.us-east-1.amazonaws.com:587’;

Just below add these lines, change the CAPS for your

$config[‘smtp_user’] = ‘YOUR-SES-USERNAME-RANDOM-CHARS’;
$config[‘smtp_pass’] = ‘YOUR-SES-PASSWORD_THAT-is REALLY-LONG’;

  • You can setup each Outlook with SES SMTP settings

The following deals with a small issue using SES with Outlook http://charmingwebdesign.com/how-to-set-pop3-and-smtp-server-port-addresses-for-win-10-mail-app-tls-aws-ses/

  • You should additionally ask AWS to allow your Instance to send emails. As it is now it is limited to just a few messages an hour or less. They won’t tell you. However you can ask them for both reverse DNS and allowing you to send emails in the same form:
https://aws.amazon.com/forms/ec2-email-limit-rdns-request?catalog=true&isauthcode=true

See also

http://charmingwebdesign.com/how-to-get-reverse-dns-for-your-ec2-instance-as-well-as-to-raise-email-sensing-limit-amazon-web-services/

I checked out backup the db,

I didn’t try it but found this:

However, you might be interested in periodic snapshots of the volume, snapshots are incremental, so you don’t pay for the full 70 GB every time.

https://www.hmailserver.com/forum/viewtopic.php?t=30217

Set WordPress all of your pages to private so that you can un-publish them

Visits: 516

Just set them to private in the database, using the following query:

UPDATE `wp_posts` SET `post_status` = 'private';

This would set all posts to private, I guess you won’t really use that query.

Instead, to only set articles to ‘private’ use:

UPDATE `wp_posts` SET `post_status` = 'private' WHERE `post_type` = 'post';

and to only disable pages, use:

UPDATE `wp_posts` SET `post_status` = 'private' WHERE `post_type` = 'page';

Post-revisions have the status ‘inherit’ and thus get the right inherited from the parent page or article.

https://stackoverflow.com/questions/16209821/can-you-make-all-wordpress-pages-private-simultaneously-without-a-plugin