Sunday, May 22, 2016

Transfering SQL database between two linux servers

Process for moving a database between two linux servers running mysql.

Target server may or may not have the database created.  example used uses phpmydmin create database to create the empty database.

Use mysqldump to create an ".sql" file with the data from the database.  Example here is for an RSS reader application, and keeps track of the rss feeds for doing deltas for the read presentation.

Note for sql the password and user id are for the mysql users and the password on the mysql server.  They are not linux account passwords.  The commands can be performed from any userid with access to the mysql commands, since the database is worked via the mysqldump command to the mysql socket.  Access to the actual files is not required, since the work is done on those files by the mysql server.


 mysqldump --password=<some-password> -u <userid> rss > 2016-0522-rss-mysqldump.sql

create database in phpmyadmin: 

Databases->Create new Database [enter rss in name field] (Create)


mysql -u <userid> --password=<password> rss < 2016-0522-rss-mysqldump.sql

Thursday, May 12, 2016

using ssl purchased cert with ipfire

This posting covers a problem with installing a cert and verifying it on ipfire, since the port 80 and 444 ports are used for the firewall.  The service this guy used needed those ports open to do the cert install.

However it is useful to note that it names the method used for moving those ports out of the way as well from other posts here.

Also the site letsencrypt has free certs.  Looks like possibly only one cert for a server is required to convert to using https regardless of how many servers one has on a site.  need to investigate.

IPFire versus SSLCerts

so I decided to purchase a ‘real’ SSL certificate for my IPFire installation and as it was the cheapest one I could find I went with… so far so good.
But, if you follow the instructions, one problem remains: if you chose to upload the verification file any confirmation will fail as IPFire uses ports 81 and 444 for the webinterface. To resolve that issue, at least temporarily we will excute the following steps:
(1) if you contact the firewall from the ‘outside world’ make sure you add exceptions for ports 80 and 443
(2) upload the provided file to /srv/web/ipfire/html/
now the fun starts…
modify the ports in
/etc/httpd/conf.d/vhosts.d/ipfire-interface.conf and ipfire-interface-ssl.conf
now our apache would not know, which ports it is configured for, however, unless you change the
as well nothing will happen…
Now execute a /etc/init.d/apache restart
once your certificate is ready, replace the certs in /etc/httpd, change back the ports and reload the service… your purchased cert should now be used.

Update: IPfire seems to replace der server.crt sometimes when being updated… in that case you might have to overwrite the certificate again and restart apache.

adding webcam string to ipfire

This is useful as it contains examples useful in bringing up a webcam server, as well as uploading info to dropbox.

Also demonstrates adding to pakfire (ipfire module)

Things to remember
  • Ipfire default web interface is on http port 81 or https port 444
  • Add .1 to version in /opt/pakfire/etc/pakfire.conf and do pakfire update --force so you can install addons from testing branch
  • Use pakfire to install motion
  • Motion by default streams on port 2500, but you can set this in /etc/motion.conf
  • Needed to add a video user and video group
  • The boot file /etc/init.d/motion needs some adjustments to allow starting motion at boot time
  • Set firewall rule correct to forward the port: From any to firewall red for tcp on port 2500 for webcam
Posts that helped me on the way
Adjustments to motion configuration
mkdir -p /var/motion/cam1
chown -R video: /var/motion/cam1
mkdir -p /var/run/motion/
chown video:video /var/run/motion/
chmod 755 /var/run/motion/
loadproc sudo -u video /usr/bin/motion
Move snapshots to dropbox
on_picture_save /etc/init.d/dropbox/ %f %Y%m%d %H%M%S
/etc/init.d/dropbox/ upload $1 cam1/$2/$2-$3-snapshot.jpg && rm -f $1
Sync dropbox to main website on ipfire
rm -rf /srv/web/localhost/html/
/etc/init.d/dropbox/ download html/ /src/web/localhost/
find /srv/web/localhost/html -type f -exec chmod 644 {} \;
find /srv/web/localhost/html -type d -exec chmod 755 {} \;