Wednesday, July 8, 2015

Split PDF Documents into unique named items on an element in the PDF

In schools you get a lot of reports that are provided in PDF format.  Each page is usually unique to each student in the district.

This year the student test results are provided in a PDF.  One file with ELA scores, and one file with Math scores.  To print the scores back to back we have to merge the two files with ELA and then Math for each student.

This software will split the PDF into a unique PDF file for each student.

Then you merge that with the split Math PDF and you get one PDF with both ELA and Math.

I found this while working through the splitting process.  Lots of software can split a PDF document into unique pages, but I didn't find any at this price point that would split it and name it based on the content in the PDF.

Let me know what you think in the comments.

Wednesday, September 17, 2014

Remote Add Domain User to local Admin Group

I have a bunch of computers in classrooms and teachers like being able to install software on those computers...most of the time it is items that I would do myself if I had the time, but it is more convenient to have the staff do it for me since they want to use it.  Anyway, I found these instructions that add a user to the local administrators group.  I can run this remotely from my desk without having to get up and travel to the remote location.

I followed these instructions to do this, so I am not the one who figured this out, just want to make it easier for the next guy to find.

1. Get a copy of PSTools from Microsoft.

2. Open a command prompt and run psexec.

  psexec.exe \\computername cmd.exe

3. Add the user.

  net localgroup administrators domain\user /add

That is all there is to it.  Have the user sign into the computer with their own credentials and they now have permissions to install on the computer.

Tuesday, August 12, 2014

Google Drive Sync as a Windows 2008 Service

We have a few Chromebooks being used by staff throughout the District.  We also use Windows shares heavily for access to shared files.

Access to Windows shares is not possible, but access to Google Drive shares is.  And Google offers a product called Google Drive Sync that will put files from a computer in Google Drive and keep them synced.

Now enter an awesome post:
Specifically the post from Reece Dodds.

That post is perfect, except for the registry information, but I missed the create subkey Parameters part, so I want to just make sure that everyone has an exact step by step guide.

  1. Log into the server with the account that you want to run the service as.
  2. Disable Internet EIC through Server Manager -> Configure IE ESC under the Security Information section on the main page.
  3. Setup Google Drive Sync. Configure google drive to not run at startup and exit the application.
  4. Download srvany.exe from Microsoft Windows 2003 Resource Kit. Copy srvany.exe into the folder where google drive is installed.
  5. Open a windows cmd prompt (run as administrator) and type in the service and authentication details you want (in our case GoogleDriveSync) i.e. sc create GoogleDriveSync displayName= "Google Drive Service" start= auto obj= "" password= "<password>" binPath= "C:\Program Files (x86)\Google\Drive\srvany.exe"
  6. Goto your Start Menu, type in regedit32 and goto the new service (in this case GoogleDriveSync) HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\GoogleDriveSync
  7. Create subkey Parameters below which you must create two string values:
    1. Create a String Value called Application then right click on this and add the path to googledrivesync.exe (e.g C:\Program Files (x86)\Google\Drive\googledrivesync.exe)
    2. Create a String Value called AppParameters with the relevant parameters for googledrivesync.exe (e.g /autostart --noshow_confirmation_dialog_on_delete)
  8. From the command prompt run net start GoogleDriveSync or start the service via the services snap-in

You can then manage Google drive as a service. If you need to edit the settings within drive log in as the account that the service is running under, stop the service then start Google drive from the icon in the start menu. When you have completed the changes to the settings close the google drive desktop application and start the service back up again.

Monday, July 28, 2014

URBackup on FreeNAS

Ok, so I decided to create a cheap backup server.  Bought 4 - 3TB hard drives on Amazon.  Installed in a workstation that I already had.  Set it up in the server room.

The FreeNAS install process is really simple so I won't go into detail about that.  The URBackup install was somewhat easy as well, but I want to detail that here for anyone who wants to recreate.

Install FreeNAS and reboot.  Connect and set a root password.

I followed the instructions in this manual which is perfect.  I didn't have to adjust any of the steps, but for help to others I will outline the same steps here.

Create a Jail
-Add Jails
(fill in default gateway)
uncheck VIMAGE

Connect to FreeNAS via SSH (must be enabled in services)

Find the number of the jail you created above.
#jexec 1 tcsh

This enters you into the jail itself.  All commands from now on are specific to the jail itself and should not be run on the FreeNAS system.

#pkg install
#pkg install update
#pkg install nano wget
#portsnap fetch extract
#cd /usr/ports/security/cryptopp
#make CXXFLAGS="-fPIC" (accept all default questions and pop up boxes)
#make install
#pkg install curl

#cd /
#mkdir /urbackup
#cd /urbackup
#wget (download link for latest urbackup tar.gz source)

#tar zxvf urbackup*.tar.gz
#cd urbackup-server-x.y.z
#make install

(I had trouble with the install.  It said it was completed, but I had to run the command again to actually get it to install the program into the right folders.)

#adduser urbackup --system --quiet --group --home "/usr/local/var/urbackup" || true
(this is supposed to create the account, but it just brought up the account dialog for me, so I filled it in by hand)

#nano /etc/rc.d/urbackup_srv

Paste the below into the file:
. /etc/rc.subr
command_args="--plugin /usr/local/lib/ --plugin /usr/local/lib/ --plugin /usr/local/lib/ --plugin /usr/local/lib/ --plugin /usr/local/lib/ --plugin /usr/local/lib/ --http_root /usr/local/var/urbackup/www --workingdir /usr/local/var --user urbackup --http_port 55414 --logfile /var/log/urbackup_srv.log --daemon"
start_precmd="cd /usr/local/var"
load_rc_config $name
run_rc_command "$1"

The command args line should be one complete line.

#chmod +x /etc/rc.d/urbackup_srv

#nano /etc/rc.conf

Add this line to the end:

#mkdir /backups
#chown -R urbackup:urbackup /backups

#/etc/rc.d/urbackup_srv start

Access the web interface at http://[ipaddress]:55414
Go to Settings / General / Server
Adjust the [Backup Storage Path] from the default to /backups

#/etc/rc.d/urbackup_srv restart

From FreeNAS web click on the Jails -> Urbackup -> Storage -> Add Storage and connect the /backups folder with the FreeNAS volume created.  I want all of the storage space available to the backup jail, so I connected it straight.

Next is the client on the servers, for sending files to URBackup.  More on that process in another post.

Tuesday, June 10, 2014

Raspberry Pi Chromium Digital Sign w/ PHP Reboot button

I am following these instructions, but am giving full detail of my instructions.  I am also adding a PHP webpage to reboot the pi remotely without knowing the passwords so other staff can do it.

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install matchbox x11-server-utils unclutter chromium ttf-mscorefonts-installer
sudo reboot

Setup Auto-login
sudo nano /etc/inittab
comment out the line (#)1:2345:respawn:/sbin/getty 115200 tty1
add: 1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1

That is all I did.

sudo apt-get install php5
cd /var/www
sudo rm index.html
sudo nano index.php

        echo "Rebooting NOW<br />\n";
<!DOCTYPE html>
<form action='index.php' method='post'>
<input type='submit' name='s' value='Reboot' />

sudo nano /usr/local/sbin/

if [ -f /tmp/ ]; then
        rm -f /tmp/
        /sbin/shutdown -r now

sudo chmod +x /usr/local/sbin/
sudo crontab -e

* * * * * /usr/local/sbin/

Wednesday, March 19, 2014

Format SD Card with Linux partitions

If you have ever used a Raspberry Pi but had to setup the SD card using a windows computer than you know the frustration you get when the disk only shows 56 Mb instead of the 14 Gb that it should be!

I spend a good hour trying to figure this out every time I try and reformat the card with the latest version of Rasbian.  I know I should just keep this in my list of bookmarks, but now I realize that I should just blog the steps as I have with everything else, so that I have it for posterity!

Anyway, Windows 7 has a great tool called diskpart.  Never really knew how fantastic it was until now.  Back in the day it was fdisk, but diskpart is much more powerful and easier to use!

list disk
select disk # (the sd card disk number that was listed above)
clean (clears partition table)

This step seems to be required if using my laptop, but I don't know if everyone has to do this or not.
Pull out the sd card and put it back in after a few seconds.

list disk
select disk # (is probably the same, but might not be)
create partition primary
format fs=fat32 quick

Done!  It is that easy!

I know that you can also put the card in a camera and format it there to reset the partition table, but I don't have a camera handy all the time!

Hope this helps others.

Wednesday, February 19, 2014

Increase Ubuntu Hard Drive Size in VMWare ESXi

I have only done this with my Ubuntu virtual machine so far, so I can't tell you if this works for any other form of linux.  I will have to test it some time to find out.

My situation:  Koha library system loaded on a Ubuntu Server 13.10.  I had originally set it up as a test server so I only gave it 2Gb of ram and a 30 Gb hard drive.

Logs can fill up fairly quickly with everything going on, and the database takes space when you have 20,000 book records and 500 student records.

I followed these instructions to increase the hard drive size of my server, on the fly and it worked perfectly, now I have storage space again and the system is working again!

First step is to increase the hard drive to the virtual machine.  I had lots of space, and could add more, but I thought 80Gb would be a good amount for now.  So I increased it by 50Gb to make it 80Gb in total size.

Then access the machine with PuTTy.

List all partitions
$ ls -la /dev/sda*

Create new partition using fdisk:
$ sudo fdisk /dev/sda
p - to list all partitions
n - to create a new partition
l - for "logical"
Accept the default start and end blocks, as that is the new section that has been allocated.
t - to change the partition type
8e - set the type to Linux LVM
p - to list the new partition table
w - to write the changes

A warning message will say that the new drive won't be available until you restart, or use this command:
$ sudo partprobe

Now it is time to create the partition, extend the current volume and reprobe the partition table.

Create partition on new disk - (mine was /dev/sda4, yours might be different)
$ sudo pvcreate /dev/sda4

Display the current volume group and get the name
$ sudo vgdisplay - "VG Name" is what you are looking for here

Extend the volume group with the new partition
$ sudo vgextend VGName /dev/sda4

Get the name of the main logical volume
$ sudo lvdisplay - "LV Name" is what you are looking for here

Extend the logical volume by X Gbs
$ sudo lvextend -l -XG LVName

Resize the file system to account for the new space
$ sudo resize2fs LVName

You can now check to see if the total space is much larger
$ sudo df -hT

This should be all that you need, I did another
$ sudo partprobe
to verify that the system was aware of all the space.

I had some services crash and wouldn't start because of the lack of hard drive space, Apache2 and MySql5 wouldn't start.  After this process I was able to sudo service start and they both came up fine.