Wednesday, July 28, 2021

Dockerizing gphotos-sync for Raspberry PI

So, 11 years after the last time I posted it is time for a new post!

All my photo's I take on my phone are sent to Google Photos, which I then backup to my NAS. But as it turns out Google stopped syncing Google Photos to Google Drive in 2019 so that was the latest photos I had synced. Luckily I stumbled upon an article explaining that and that gave me time to figure out a new solution.

The sync script of gilesknap seems like a perfect fit: https://github.com/gilesknap/gphotos-sync it is even available as a docker container. If only it could run on my Raspberry PI! Here's what I did to fix this:
  1. Clone the repository (#git clone https://github.com/gilesknap/gphotos-sync.git)
  2. Build the docker container on the RPI (#docker build -t rogierg/gphotos-sync:0.0.1 .)
  3. Run the newly built docker container (#docker run --rm -it --name gphotos-sync -v /[Local Storage]:/storage -v /opt/gphotos-sync/client_secret.json:/config/client_secret.json:ro rogierg/gphotos-sync:0.0.1 --log-level INFO --db-path /config /storage

Monday, June 22, 2009

Reinstalled my HTPC

My HTPC was giving more and more problems and so I decided to reinstall the system. I'm running Windows 7 on my laptop and workstation so I wanted to try it on the HTPC as well. I did run into a couple of problems but though, here's what I needed to fix:

The soundcard of my Biostar P4VBM800 motherboard was working. The onboard chip is a C-Media CMI9761, which should be AC97 compatible but Windows did not detect it. after a little trial and error I found these drivers. Audio's working fine now, even the digital output works.

My ATI Radeon X1600 was detected but the standard MS driver does not support OpenGL. After trying a couple of solutions I found that the 7.11 Catalyst Vista Drivers work fine.

My HTPC is quite old (Pentium 4 @2,53 GHz with 1 GB RAM) but Windows 7 was running like a champ, better then XP and of course the biblically terrible Vista. So now I needed to install some media players:

First I installed XBMC as my main media center. This was the main reason I needed to get OpenGL going. XBMC does not do hardware accelerated video playback so I also installed MPC-HC and now my old HTPC is capable of 720p video playback at 25% CPU load.

Last I installed Hulu and used HotSpot Shield to access Hulu outside of the US. Video playback is fairly watchable on low quality, I'm going to check some other VPN solutions to see if I can get this to work better.

Tuesday, June 16, 2009

VBScript: Remove old Windows Updates

My virtual machines regularly fill up their system disks, with old uninstall information. I was getting tired of fixing this manually, so I wanted to create a script to do this automatically. I found a script that removed all updates and modified it to only remove updates older than 90 days:


Option Explicit
Dim o, oShell, nConfirm
Set o = WScript.Application
o.Interactive = True
Set oShell = CreateObject("WScript.Shell")
nConfirm = oShell.Popup("Do you want to remove Windows Update Uninstall Files?", 0, "Remove Windows Update Uninstall Files", 4 + 32)
If nConfirm = 7 Then
o.Quit 0
End If
Dim oFSO, sWinDir, oFolder, oDictionary, oSubFolder, sFolderName, sFolderPath, sUpdateName, sDeleted, sFolderDate
Set oFSO = CreateObject("Scripting.FileSystemObject")
sWinDir = oFSO.GetSpecialFolder(0)
sDeleted = vbNullString
Set oFolder = oFSO.GetFolder(sWinDir)
Set oDictionary = CreateObject("Scripting.Dictionary")
For Each oSubFolder In oFolder.SubFolders
sFolderName = LCase(oSubFolder.Name)
sFolderPath = LCase(oSubFolder.Path)
'Check date of update
sFolderDate = oSubFolder.DateCreated
If Left(sFolderName, 12) = "$ntuninstall" And Mid(sFolderName, 13, 2) = "kb" Or Mid(sFolderName, 13, 2) = "q" Then
sUpdateName = Mid(sFolderName, 13, Len(sFolderName) - 13)
'Remove update if older than x days
If DateDiff("d", sFolderDate, Now) > 90 Then
oDictionary.Add sUpdateName, sFolderPath
End If
End If
Next
For Each sUpdateName in oDictionary.Keys
sDeleted = sDeleted & vbCrLF & sUpdateName
sFolderPath = oDictionary.Item(sUpdateName)
On Error Resume Next
oShell.RegDelete "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" & sUpdateName & "\"
On Error Goto 0
oShell.Run "%ComSpec% /C RD /S /Q " & Chr(34) & sFolderPath & Chr(34), 0, True
Next
If Len(sDeleted) > 0 Then
WScript.Echo "The uninstall data for the following updates are now removed:" & vbCrLf & UCase(sDeleted), vbOKOnly
sDeleted = vbNullString
Else
WScript.Echo "No Windows Update Folders found for removal", vbOKOnly + vbInformation, "Nothing To Do"
End If
o.Quit 0

Save this code as removeOldUpdates.vbs and schedule a task to run weekly.

I'm thinking about expanding this script to clean up all kinds of temporary files.

Thursday, June 11, 2009

VBScript: Find username by AD fullname

I needed to find the username for a large number of active directory users. Turns out it's actually quite easy to do this with VBScript. Save the following script as a VBScript, for instance username.vbs. Change "domainname" to your own domain name.

Set oArgs = WScript.Arguments
Set objDomain = GetObject("WinNT://domainname")
objDomain.Filter = Array("User")
str2Find = oArgs(0)
For Each aUser In objDomain
If LCase(str2Find) = LCase(aUser.FullName) Then
Wscript.Echo str2Find & "=" & aUser.Name
strUser = aUser.Name
End If
Next
Set objDomain = Nothing

Now you can search a username by running: cscript username.vbs "Full Username"

Monday, May 18, 2009

Sync Windows Mobile with Google Calendar

In this post I discussed Syncing Windows Mobile with Google Calendar using ActiveGCSync. Now I have found a way to sync your calendar using regular Active Sync.

Google has a new synchronisation service called Google Sync. The service is only available for Google Apps users so you need to set up a new calendar in Google Apps. Google Apps is still free up to a maximum of 50 users, but the registration page is difficult to find. You can find the registration page here.

Here's how I set up my calendar synchronisation:
1. Register a new account for Google Apps
2. Open Domain Settings, set Control Panel to "Next generation (US English only)"
3. Open Service Settings and enable Google Sync
4. Enable Google Calendar for your account
5. Set up ActiveSync using this guide

If your PDA was already in sync, this is all you needed to do. Use the Google Apps calendar from now on. If you need to export the appointments from your old Google calendar use this guide and this guide to import them again.

So far this has been working great, I'm getting less errors than ActiveGCSync used to generate. Now let's see when Google will allow ActiveSync to work with Gmail.

Saturday, November 1, 2008

Ikea hack: monitor shelve

Ikea hacking is all the rage these days. When you can't find exactly what you want the price of their products allows you to hack it into exactly what you need without feeling guilty about it. My solution is not so much a hack but more an insight into using the product for some other purpose.

My desk at home was a real mess, you'll just have to trust me: I did not take a before picture. I realised most of the trouble would be solved if I would make a shelve on which I could put my monitor. All the loose routers and other devices would slide right under. And if I did not use my Electribe it could slide under as well...

Walking through the Ikea I realized they did not have the product I was looking for. Then I noticed a display for the Effectiv filing cabinets, and there was this perfect base with ajustable legs.

So I brought it home, assembled it (no missing pieces, yihaa!) and started to clean up my desk. Here's the result:

Thursday, October 30, 2008

Disconnect GPRS connection if your NIC is connected

This is a VBScript I created some time ago. It will connect your GPRS connection if your NIC is not connected and disconnect the GPRS connection if the NIC is connected. It will work with other dial-up connections as well.

The script will run as a service with SrvAny and will reconnect the GPRS connection if the connection was dropped. I'm using WMI to determine the status of the LAN connection. For some reason I did not find the correct status of the GPRS connection in WMI and needed to use the output of ipconfig to determine if GPRS was still up.

Dim Shell, Hell, GPRS, ExecuteObj, strcmd, GPRSConnected

On error resume next

Set Shell = CreateObject("WScript.Shell")
strComputer = "."
GPRS = "0"

Do
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_NetworkAdapter Where NetConnectionID = 'Local Area Connection'")

For Each objItem in colItems
If objItem.NetConnectionStatus = 7 Then
If GPRS = "0" Then
' Wscript.Echo "LAN connection disconnected!"
Shell.Run ("rasdial GPRS"), 0
GPRS = "1"
End if
Else
If GPRS = "1" Then
' Wscript.Echo "LAN connection connected!"
Shell.Run ("rasdial GPRS /DISCONNECT"), 0
GPRS = "0"
End if
End if
Next

If GPRS = "1" Then
Set ExecuteObj = Shell.Exec("ipconfig.exe")
Do While Not ExecuteObj.StdOut.AtEndOfStream
strcmd = ExecuteObj.StdOut.ReadLine()
If Instr(strcmd, "PPP") > 0 Then
GPRSConnected = "1"
End if
Loop
If not GPRSConnected = "1" Then
' Wscript.Echo "GPRS connection disconnected!"
Shell.Run ("rasdial GPRS"), 0
End if
Set ExecuteObj = nothing
Set GPRSConnected = nothing
End if

Wscript.Sleep 10000

Loop Until Hell="Freezes over!"