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.
http://technet.microsoft.com/en-us/sysinternals/bb896649


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: http://superuser.com/questions/463801/sync-google-drive-when-not-logged-in
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.
    https://tools.google.com/dlpage/drive
  4. Download srvany.exe from Microsoft Windows 2003 Resource Kit. Copy srvany.exe into the folder where google drive is installed.
    http://www.microsoft.com/en-us/download/details.aspx?id=17657
  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= "administrator@potlatchschools.org" 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.
http://doc.freenas.org/index.php/Quick_Start_Guide

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.  http://forums.freenas.org/index.php?threads/urbackup-installation-guide.22117/

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

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

Find the number of the jail you created above.
#jls
#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
#./configure
#make
#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)
urbackup
urbackup
empty
empty
empty
empty
empty
/usr/local/var/urbackup
empty
no
no
yes
no

#nano /etc/rc.d/urbackup_srv

Paste the below into the file:
#!/bin/sh
. /etc/rc.subr
name=urbackup_srv
rcvar=urbackup_srv_enable
command="/usr/local/sbin/$(name)"
command_args="--plugin /usr/local/lib/liburbackupserver_urlplugin.so --plugin /usr/local/lib/liburbackupserver_cryptoplugin.so --plugin /usr/local/lib/liburbackupserver_downloadplugin.so --plugin /usr/local/lib/liburbackupserver_fsimageplugin.so --plugin /usr/local/lib/liburbackupserver_httpserver.so --plugin /usr/local/lib/liburbackupserver.so --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:
urbackup_srv_enable="YES"

#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

<?php
if(isset($_POST['s'])){
        echo "Rebooting NOW<br />\n";
        touch('/tmp/reboot.now');
}
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action='index.php' method='post'>
<input type='submit' name='s' value='Reboot' />
</form>
</body>
</html>

sudo nano /usr/local/sbin/reboot.sh

#!/bin/bash
if [ -f /tmp/reboot.now ]; then
        rm -f /tmp/reboot.now
        /sbin/shutdown -r now
fi

sudo chmod +x /usr/local/sbin/reboot.sh
sudo crontab -e

* * * * * /usr/local/sbin/reboot.sh


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!

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

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.

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

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!

http://www.joomlaworks.net/blog/item/168-resizing-the-disk-space-on-ubuntu-server-vms

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.

Monday, February 10, 2014

Monthly Board Reports

Our School Board has gone Google and paperless with Google Drive.  Starting a year ago we purchased Chromebooks for the board members to use.

These instructions are for how the drive is organized and what to do each month for the board members.

The Google Drive was formed and shared using the tech user account.  This way any staff member with access can go in with full rights.  It is not tied to a specific staff member.

PSD School Board ->
     Agenda
     Archive
     Consent Agenda
     Meeting
     Minutes
     Policy
     SB Reports ->
          Athletics
          Clerk
          Elem Principal
          Food Services
          HS Principal
          Maintenance
          SPED
          Superintendent
          Technology
          Transportation

Inside each is a folder for the past school years, for organizational purposes.  Add a new folder each year and move the files into those folders to keep it clean.

The Archive folder is where all past meeting files are organized.  These are links to the files also stored elsewhere in the drive.

The meeting folder is used by the board for easy access to all files stored throughout the drive.  Each month I create a link to the files in this folder.  To create a link find the original click the Move To folder button and press and hold the Ctrl key when clicking the Meeting folder.  The Ctrl key allows for multiple locations.  Then click OK to create the link.  Keep all files in the original locations, but add a link to the meeting folder.

At the end of the meeting from the meeting folder, select all files and folders except the policy folder and move these to the Archive folder for that month.  To move, but keep the other links you press the Ctrl key and uncheck the meeting folder check and while still holding the Ctrl key click the archive month folder.

All files are named as such:
     2014 02C Technology Report
     Year | Month | Section of the agenda | Title
Agenda header items are A, Administrative reports are B, Supervisor reports are C

The board group is given view access.  Each supervisor has been granted edit rights to the SB Reports folder that corresponds to their position.

Friday, February 7, 2014

Update Linux Servers

I like to do these steps on each server listed once a month.  You can do it as often or as little as you like.

These steps are specific to my servers, but only in terms of Debian and Ubuntu.  Some things are specific for the setup here at Potlatch SD.

I have blanked out any passwords and usernames, those can be retrieved from documentation.

Web Server/Piler Server
Use Putty, it is the easiest SSH software out there.

At the initial prompt you need to su to do the update process.

$ su

apt-get update
apt-get upgrade
apt-get autoclean
apt-get autoremove

When that is complete then you can type exit twice to close out.

Koha Server
This is similar to above, but since it is Ubuntu you can use sudo instead of su at the beginning.

$ sudo apt-get update
$ sudo apt-get upgrade

If Koha was upgraded then you have to go and adjust the Circulation file to allow the scanners to work properly.  instead of programming the scanners or changing the barcodes on every book now, I have modified the programming to adjust the barcode after scan at the elementary.  The instructions are found on this blog under PSD Koha Circulation Barcode Modification.

$ sudo apt-get autoclean
$ sudo apt-get autoremove

When that is complete then you can type exit to close out.

PFSense Firwall/Gateway Server
This server checks for updates and will display if an update is needed on the dashboard.  To upgrade you can click on the link and follow the instructions, the server will upgrade in place without much major interruption.  I have done the update during the school day and only had the network disconnect for a few seconds while the service restarts.  Some major updates require a restart so those should be done at the end of the day.
The Packages can be updated at anytime as well.  These are add-ons that have been used to increase the effectiveness of the server.  When you click on System -> Packages the next screen shows you what is installed.  Anything that is highlighted in the version column has an update.  To load that update click on the PKG button next to the row.  That will install the update automatically.

Friday, January 3, 2014

Factory Reset Chromebook

I have recently purchased a few Chromebooks.  We have both Acer and Samsung.  These instructions worked on both.

When joining a Chromebook to our local email domain for management the process is fairly straightforward.  You wait for the sign in screen, but instead of signing in you press Ctrl-E.  This then brings up another sign in screen, and I have entered the admin email and password, then the system says enrolled and the sign in screen actually comes up, but now says that this device is managed by my email domain.

Sometimes during this process the device doesn't enroll properly.  The only way to fix that is to factory reset the device and try again.

I had to call support to get this information, but since it worked on both types of devices I am blogging it for my future reference!

With the device turned off completely follow these instructions:

Esc - Refresh - Power button  The refresh button is F3 on both of the devices, but is usually represented by a circular arrow.
Once the device comes up to the developer mode press:
Ctrl - D and the  Enter key.

This will send the device into develop reset mode.  It will probably take a few minutes to wipe the device.  It will restart a few times.  When it is done it will go right back to the initial process as if you just turned it on for the first time.

The device can now be enrolled in the domain for management.

The Acer device needed the developer mode turned off, which is just the above process again.  The Samsung didn't need that step.

Hopefully this helps others, or at least is for my reference.

Thursday, January 2, 2014

PSD Koha Circulation Barcode Modification

So I spent a few summers ago upgrading the library system to Koha.  It was actually fairly painless to do with the help of linux.  But I ran into an issue of barcodes matching at both schools.  So to eliminate that I added an e to the barcodes for the elementary.  Now to get the scanner to put the e on at the end so the librarian wouldn't have to add it manually.

Instead of making the scanner do that work I found that you can modify the Circulation file in Koha to do that work for you.  In our situation that was good since the books at the high school have added number data in the barcode as well.

So here is the location of the file:
/usr/share/koha/lib/C4/Circulation.pm

This is what I modified to get it to work:
Original:
elsif ($filter eq 'T-prefix') {
  if ($barcode =~ /^[Tt](\d)/} {
    (defined($1) and $1 eq '0') and return $barcode;
  $barcode = substr($barcode, 2) + 0;
}
return sprintf("T%07d", $barcode);

New:
if($branch eq '0762' and substr($barcode, -1) eq 'e'){
  return $barcode;}
elsif($branch eq '0135' and length($barcode) >= 6){
  $barcode = substr($barcode, 2, 5);
}
if(substr($barcode, 0, 1) eq 'T'){
  if(substr($barcode, 1, 1) eq ' '){
    $barcode = substr($barcode, 2);}
  else{$barcode = substr($barcode, 1);}
}
$barcode = substr($barcode, -5);
if($branch eq '0762'){
  return sprintf("%05de", $barcode);
} else {
  return sprintf("%05d", $barcode);
}