As the Odroid now has all the hardware components necessary for it to be a web server it is time to set it up to be a server. However, testing is needed before any switch takes place. The Odroid's 128 GB micro SD will be storage for all the websites hosted by DrQue.net. I setup an rsync
script to synchronize the Odroid to the Micro Dragon. One of the problems with this is permissions. The web server runs as the user www-data
and since the users of the Micro Dragon are not the same as those on the Odroid I can't preserve ownership during the synchronization. All the web pages are owned by www-data
anyway so I wanted a way to force this user to have ownership for new files. I accomplished this in a rather complicated manner.
sudo chown www-data $ID_FILE
sudo chmod 600 $ID_FILE
sudo cp id_rsa $ID_FILE
COMMAND="rsync -rltv --no-p --no-g --delete -e 'ssh -o IdentityFile=$ID_FILE -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null' email@example.com:/webpages/ /webpages"
echo "*************** Sync webpages ***************"
sudo su - www-data -s /bin/bash -c "$COMMAND"
sudo rm $ID_FILE
What this script does is first copy an SSH key that allows a no password log in from some location to a temporary file. This file is then assigned to www-data
with no read access given to anyone else. This will allow www-data
to log into DrQue.net over SSH without needing a password. Then a command string is setup that uses the temporary file to the SSH log in for rsync
. Since www-data
cannot normally log in it has no user directory, so the known hosts and strict host checking need to be disabled. Once the command is setup, su
is used to switch the user to www-data
and run the rsync
command. The rsync
command is setup to not preserve permissions or ownership, meaning all the files transferred will be owned by the user doing the transfer—www-data