Saturday, September 01, 2012

Reset MySQL's root Password

Here's how to reset the root's password of MySQL:

Step 1) Stop MySQL: /etc/init.d/mysql stop
Step 2) Start mysqld skipping grant tables: mysqld --skip-grant-tables
Step 3) Start mysql client with root user: mysql -u root
Step 4) Now you're logged in at MySQL as root, run this to set a new password for root:
UPDATE mysql.user SET PASSWORD=PASSWORD('newpassword') WHERE User='root';
FLUSH PRIVILEGES;
quit;
Step 5) Stop MySQL: /etc/init.d/mysql stop
Step 6) Start MySQL: /etc/init.d/mysql start

That's it, you've reseted root's password of your MySQL server!

Wednesday, May 30, 2012

Enabling htaccess Apache 2 Authentication (Debian)

Here are my notes about securing my cgi-bin folder with simple Apache 2 authentication.


Edit /etc/apache2/sites-available/default
Find the directory you want to protect (in my case: /usr/lib/cgi-bin) and change the "AllowOverride" line from "none" to "AuthConfig". Here's how the cgi-bin section of my file is after changing:


Now I create an user (gfcaetano) and a password, storing them into the file "/etc/apache2/.htpasswd" with htpasswd command:
htpasswd -c /etc/apache2/.htpasswd gfcaetano
It will ask you for the password (twice).
The next step is to create the ".htaccess" file into cgi-bin directory so it will ask for the password when entering at cgi-bin folder of this Apache2 server.
Edit or create /usr/lib/cgi-bin/.htaccess and put the following lines into it:


Now Apache2 must me reloaded, run "/etc/init.d/apache2 reload".


That's it. Your Apache's cgi-bin directory is protected.


If you've noticed any errors at this post or if you have any suggestions, please notify me so I'll correct them.
Thanks for reading!

Monday, January 02, 2012

ConQuest 1.4.16 Installation on a Debian Squeeze Server

This is a quick guide on how I'm used to set up a NKI's ConQuest DICOM server in Debian 6.0 (Squeeze) using MySQL as ConQuest database.



 

BEFORE PROCEEDING
I assume that you're logged in as "root" and the image files will be stored at a directory at "/raid/data".
I'm using "vim" to edit files, if you're not familiar with "vim", please use another editor (eg: "nano").

If you're updating your ConQuest version, backup these files before proceeding:
  • /opt/conquest/acrnema.map
  • /opt/conquest/dicom.ini
  • /usr/lib/cgi-bin/dicom.ini
Don't restore the above files to your new version of ConQuest. Use them just to check the information you need to change at the new files. Overwriting files from a newer version of ConQuest with files from an older version may cause ConQuest malfunctioning.



 
INSTALLING
First of all, we want to install the latest version of each needed package, so we call:
# aptitude update

And then install the recommended packages:
# aptitude install apache2 fail2ban g++ libjasper-dev libjasper-runtime libmysqlclient15-dev make mysql-server ssh unzip vim wget zip

Now we create the database that ConQuest will use:
# mysql -u root -p
create database conquest;
quit;

Download ConQuest for Linux at the official FTP server:
# wget ftp://ftp-rt.nki.nl/outbox/MarcelVanHerk/dicomserver/conquestlinux1416.tar.gz

Create a directory for ConQuest files:
# mkdir /opt/conquest

Move the downloaded file to this directory:
# mv conquestlinux1416.tar.gz /opt/conquest

Enter the ConQuest directory:
# cd /opt/conquest

Uncompress ConQuest files:
# tar zxvf conquestlinux1416.tar.gz

Edit the file 
maklinux_mysql and remove every "sudo" you find there, because you're "root"
# vim maklinux_mysql

Call maklinux_mysql to build ConQuest
# sh maklinux_mysql

If everything went fine until here, you'll have an executable binary dgate file at the ConQuest folder

Edit the file dicom.ini to set up your server, now you define the server Application Entity Title (AET), it's communication port, the password that ConQuest will use to connect to MySQL
The lines that aren't listed here are the lines that I don't make any changes, so leave them alone:
# vim dicom.ini

MyACRNema = SERVER_AET TCPPort = 104 # the server communication port
Password = FixPhilips = 1 # avoids problems with Patient ID from some Philips systems FixKodak = 1 # avoids problems with Patient ID from some Kodak/Carestream systems
IgnoreOutOfMemoryErrors = 1 # avoids ConQuest interruptions when out of memory errors occurs
FileNameSyntax = 8 # determines the name of stored files (see page 52 of windowsmanual.pdf) DroppedFileCompression = jk # store dropped files using Lossless JPEG2000
IncomingCompression = jk # store image files through DICOM communication using Lossless JPEG2000
PACSName = # for banner and debug information MAGDevice0 /raid/data/ # where the images will be stored

Create the directory to store the images:
# mkdir /raid/data

Edit the the file that contain associated remote DICOM nodes that will communicate with this server:
# vim acrnema.map

Edit the webserver settings. 
The lines that aren't listed here are the lines that I don't make any changes, so leave them alone:
# vim /usr/lib/cgi-bin/dicom.ini
WebServerFor = server_ip
TCPPort = 104
WebScriptAddress = http://server_ip/cgi-bin/dgate
viewer = seriesviewer2

(Re)build the database verbosely:
# ./dgate -v -r



 
SCRIPTS
I've developed some simple scripts to make my life easier. Here they are:

(Re)start Conquest
(Re)start script for ConQuest saving logs into "serverstatus.log" file:
# vim /usr/local/bin/startConquest

Compressing The Log File
This script compresses the log file and generates a new (clean) one:
# vim /usr/local/bin/zipConquestLogs

Avoid Filling The Storage

This script guarantees 20GB of free space on disk by removing the oldest entries (First-In, First-Out):
# vim /usr/local/bin/ConquestNightlyClean

Keep Server Alive
This script checks if "dgate" proccess is running, if not (server crashed), the script restarts it:
# vim /usr/local/bin/KeepAlive

 

Send Yesterday's Studies To Another Server
This script sends every yesterday's studies to another server
# vim /usr/local/bin/SendYesterdaysStudies


Make all scripts executables:
# chmod a+x /usr/local/bin/*

Schedule the execution of scripts:
# vim /etc/crontab


Reload cron to activate the new entries at "/etc/crontab":
# /etc/init.d/cron reload



 
Some Useful Commands
  • Watching logs:
    • # tail -f /opt/conquest/serverstatus.log
  • Load new DICOM nodes after editing acrnema.map:
    • # /opt/conquest/dgate --read_amap:
  • List of loaded DICOM nodes:
    • # /opt/conquest/dgate --get_amaps:
  • Import images from a date from another server:
    • # /opt/conquest/dgate --grabimagesfromserver:,date
  • Export into a text file a list of studies that are available at the server:
    • # /opt/conquest/dgate --studyfinder:local||%0.0s%0.0s%0.0s%s:%s > studylist.txt
      • (the output will be "patientID:studyuid" at "studylist.txt". “%0.0s” are used to hide unnecessary data)
  • Transferring studies from one server to another:
    • # /opt/conques/dgate --movestudy:patientID:studyuid


Please tell me if you have any suggestions.
Thanks for reading!