I’m sure that we all had the need to send a single PDF file, maybe a signed contract. Yes, those 20 or more pages that you need to return, probably with just two of them filled up and signed.
Some PDF give you the ability to digitally sign them. But in my experience, most of them aren’t so modern.
So, what do I do?
I print ONLY the pages that I need to sign, scan them and here I am, with the need to “rebuild” the PDF, replacing the pages signed.
Example. You have the file contract.pdf, with 20 pages and you need to sign page 10 and page 20. The scan has a different resolution (or, even worse, it’s a different format, like jpg).
The bit before -resize is pretty self explanatory. The bit after is a way to have the size of all pages fitting an A4 format, with a good printable resolution.
Of course, to make this happen, you need Linux (or WSL on Windows 10) and imagemagick installed.
Another way is using ghostscript.
A simple Ghostscript command to merge two PDFs in a single file is shown below:
Are you enjoying your favorite Linux distro running within the Windows 10 Linux Subsystem?
Have you configured all nicely?
What happened if you get a new pc and you’d like to migrate your VM across?
This is what happened to me. And looking around, I found this post that gave me this kinda-dirty way, but did work!
After that, I decided to review the steps, and I’ve added these directories in the exclude’s list, to make clearer the process of export/import:
Shell
1
2
3
4
5
6
7
8
9
/dev
/proc
/sys
/run
/tmp
/media
/mnt
/var/cache
/var/run
Of course, if you have important data in these folders and you want to move across too, just update the one-liner below accordingly. 😉
On your OLD PC
Open your Linux VM
Get inside your Downloads directory (replace <user> with your username): cd /mnt/c/Users/<user>/Dowloads
Make sure to be root (sudo su -)
Run: tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --exclude=/dev --exclude=/proc --exclude=/sys --exclude=/run --exclude=/tmp --exclude=/media --exclude=/mnt --exclude=/var/cache --exclude=/var/run --one-file-system / NOTE: you could achieve the same using the option --exclude-from=file.txt, and having the list of exclusions in this file. I used a one-liner as it’s quicker to copy and paste.
Once done, close your Linux VM
Verify that you have a new file called backup.tar.bz in Dowloads
On your NEW PC
Install from Microsoft Store the same Linux VM (or reinstall in the same way you have done originally on your old pc)
Copy across your backup.tar.bz within your new Downloads folder
Open the VM that you’ve just installed (minimal setup – this will be completely overwritten, so don’t be bothered too much)
Once you’re inside and your backup.tar.bz is in Download, run the following (replace <user> with your username): sudo tar -xpzf /mnt/c/Users/<user>/Dowloads/backup.tar.gz -C / --numeric-owner
This will be used from our monitor server to query nrpe and provide info about ALL the disks.
You can use also -I flag to exclude a specific path. For example on my Time Capsule Pi, I’ve used the following line, to exclude the mount point “TimeMachine” from the checks:
Now back to our Nagios monitoring machine
In /etc/nagios3/conf.d create a file called for example host1_nagios2.cfg and add the following basic services (add/remove/modify based on your local configuration):
Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
definehost{
usegeneric-host
host_name host1
aliashost1
address xxx.xxx.xxx.xxx
}
defineservice{
usegeneric-service
host_name host1
service_description Current Load
check_command check_nrpe_1arg!check_load
}
defineservice{
usegeneric-service
host_name host1
service_description Current Users
check_command check_nrpe_1arg!check_users
}
defineservice{
usegeneric-service
host_name host1
service_description Disk Space
check_command check_nrpe_1arg!check_all_disks
}
defineservice{
usegeneric-service
host_name host1
service_description Total Processes
check_command check_nrpe_1arg!check_total_procs
}
Also, you can add the new host host1 to be part of any related groups, modifying /etc/nagios3/conf.d/hostgroups_nagios2.cfg
For example, we can add it to debian-servers and ssh-servers groups. This will automatically get some checks like SSH.
To easily manage virtual hosts, edit /etc/lighttpd/conf-available/10-simple-vhost.conf
Shell
1
2
3
4
server.modules+=("mod_simple_vhost")
simple-vhost.server-root="/var/www/vhost"
simple-vhost.default-host="error.default.loc"
simple-vhost.document-root="/"
This configuration above will allow you to manage your virutalhosts simply storing them in a folder under /var/www/vhost
No extra configuration is needed from the server side.
Simply go into /var/www/vhost and create a folder named as the virtualhost you would like to manage.
In this particular case, please make sure to have a folder called error.default.loc with a page inside which will be displayed in case of ANY error.
For example, if you want to manage mysite.example.com, simply do the following:
Shell
1
2
3
cd/var/www/vhost
mkdirmysite.example.com
chownwww-data:www-data mysite.example.com
…and put the html/php files inside that new folder! 🙂
To test if our webserver works, you can always use curl command as explained here.
Puppet is a quite powerful configuration manager tool which allows you to configure automatically hosts and keep configurations consistence.
I did some tests using 3 VMs:
puppetmaster (server)
puppetagent01 (client)
puppetagent02 (client)
Of course, most of the work is done on puppetmaster server. On the last two machines you will simply see the outcome of the configurations that you’re going do set on puppetmaster.
Important: all the machines have to be able to communicate between each others. Please make sure DNS is working or set local names/IPs in /etc/hosts file, and do some ping tests before proceeding.
Client setup
On each puppetagent machine, just install the package puppet
Shell
1
apt-getinstall puppet
By default, the client will look for a host called “puppet” on the network.
If your DNS/hosts file doesn’t have this entry, and it can’t be resolved, you can manually set the name of the puppetmaster in /etc/puppet/puppet.conf file, adding this line under [main] section:
Shell
1
server=puppetmaster.yournet.loc
Now, no more configuration is required from the client side. Just edit /etc/default/puppet to start at boot time and start the service.
Shell
1
2
3
4
5
6
7
# Defaults for puppet - sourced by /etc/init.d/puppet
# Start puppet on boot?
START=yes
# Startup options
DAEMON_OPTS=""
Shell
1
service puppet start
Starting the service, will make automatically a request to the server to be added under his control.
If you want to do some tests, you can eventually use the following command to run puppet only once. This will also force the polling updates, which by default runs every 30 minutes.
Shell
1
puppet agent--no-daemonize--onetime--verbose
You can repeat all these steps on the second client machine.
Server setup
Shell
1
apt-getinstall puppetmaster
Check if the service is running, otherwise, start it up.
Sign clients’ certificates on the server side
Puppet uses this client/server certificate sign system to add/remove hosts from being managed by the server.
To see who has requested to be “controlled” use this command:
Shell
1
puppet cert--list
This will show all the hosts waiting to be added under puppetmaster server.
Shell
1
puppet cert--sign
This command will add the host.
Puppetmaster configuration files
The main configuration file is /etc/puppet/manifests/site.pp
Inside manifests folder, I’ve created a subfolder called classes with extra definitions (content of these files is showed later in this post).
Shell
1
2
3
4
5
6
7
8
/etc/puppet/manifests# tree
.
|___ classes
||___ apache.pp
||___ mysite.pp
||___ ntpd.pp
||___ packages.pp
|___ site.pp
/etc/puppet/manifests/site.pp
Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import'classes/*.pp'
# This add all the custom .pp files into classes folder
It’s important to remember to NOT duplicate entries.
For example, in this case, we have a specific file where we have setup ntp service, including the required package. This means that we do NOT have to add this package in the list into packages.pp, otherwise you will get an error and configs won’t get pushed.
As I’m sure you’ve noted, there are references to some “files”.
Yes, we need some extra configuration, to tell puppet to run as file server as well and where files are located.
In our example we are storing our files in here:
Shell
1
mkdir-p/etc/puppet/files
Now we need to add the following in /etc/puppet/fileserver.conf
Shell
1
2
3
[files]
path/etc/puppet/files
allow*
Last bit, is creating the subfolders and place the files required for our configuration:
Shell
1
2
3
mkdir-p/etc/puppet/files
cd/etc/puppet/files
mkdirmysite mkdiretc
Inside mysite create mysite_apache.conf and index.html files.
Example mysite_apache.conf
Apache
1
2
3
4
<VirtualHost*:80>
ServerNamemysite.localdomain
DocumentRoot/var/www/mysite.localdomain
</VirtualHost>
For index.html, you can simply have some text, just for testing purposes.
In this example, we have also setup ntp to be installed and to have a custom ntp.conf file pushed.
For this reason, we need to make sure to have this file present into /etc/puppet/files/etc as declared into our .pp file.
After doing all these changes, you should restart your puppetmaster service on the server.
If all went well, you should have the following:
puppetagent02 host with screen, dselect, vim (installed and with syntax on), ntp (installed, running with custom ntp.conf file)
puppetagent01: with the same as puppetagent02 PLUS apache with a running website
Of course this is just a raw example and you can use template and other super features.
But I think it’s a good start 😉
I personally needed a light editor, possibly not related to KDE or Gnome (which generally means plenty of packages installed).
I found Leafpad, which does the job. So, I generally install it as well:
With these packages, you should have a very light X environment, with xterm, a basic text editor and a basic bar with workspaces and current time.
Super basic. Super light. Super Functional. 🙂
I liked also to customise the menu, because the default one was too messy for me.
To do this, create a .blackboxrc file if not present in your home directory.
After, just add the following:
Shell
1
session.menuFile:~/.blackbox/blackbox-menu
Of course, make sure to have also a folder called .blackboxand the file blackbox-menu customised like this one:
Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[begin](MinimalMenu)
[exec](XTerm){xterm}
[exec](LeafPad){/usr/bin/leafpad}
[submenu](Blackbox)
[config](Configuration)
[submenu](Styles)
[stylesdir](~/.blackbox/styles)
[sep]
[stylesdir](/usr/share/blackbox/styles)
[end]
[workspaces](Workspaces)
[sep]
[reconfig](Reconfigure)
[restart](Restart)
[exit](Exit)
[end]
[end]
Otherwise, you can always start using a copy of the default one: