There are many situations in which you want to drop all tables in a MySQL database. You can easily drop the schema, but then all the permissions are lost too. There are several solutions out there, but they all require some manual effort. I wanted to get rid off it once and for all and constructed this easy script. With the following evil shell script you can easily drop all tables in your database.
Premisse: it uses a group on table_catalog which may not always be the correct grouping in your database. Please, feel free to adapt!
Just create a textfile like drop.sh and give it appropriate rights to execute. The paste the following content in the file and save it.
Use ./drop.sh root root my_db et voilá.... all tables are gone.
Off course, things can be improved. I need to check the parameters and add some documentation...
Posts tonen met het label Ubuntu. Alle posts tonen
Posts tonen met het label Ubuntu. Alle posts tonen
dinsdag 30 juli 2013
woensdag 8 mei 2013
Mounting Samba-share in Ubuntu
My DVD-reader gave up on me some time ago. I have two laptops with Ubuntu and wanted to use the DVD-reader from the other laptop on the first one. You can easily share the DVD-drive on one laptop using the properties from the file explorer. On the other side, you can see your laptop and the shared drive. But but but, you can't access the drive from some applications because they do not support Samba directly (which is rather evident). So, you need to mount the drive on a local directory. Just type:
sudo mount -t cifs -o username=yourname,password=yourpassword //your-ip-here/sharename mymount
The mymount directory must exist. Just create one with mkdir. I had trouble using the hostname instead of the IP. With the direct IP address, everything worked as planned. When you look into your mymount-directory you will see the content of your share. You can use this directory in every application.
sudo mount -t cifs -o username=yourname,password=yourpassword //your-ip-here/sharename mymount
The mymount directory must exist. Just create one with mkdir. I had trouble using the hostname instead of the IP. With the direct IP address, everything worked as planned. When you look into your mymount-directory you will see the content of your share. You can use this directory in every application.
Ubuntu 12.10, 13.04 problem with libdvdnav4
I recently updated to 12.10 and made the jump to 13.04 shortly after that. Unfortunately, Handbrake refused scanning DVD due to an error in libdvdnav. Apparently something went wrong during the dsitribution upgrade. To get libdvdnav and Handbrake working again, just run:
sudo /usr/share/doc/libdvdread4/install-css.sh
Restart Handbrake and your DVDs can be read again....
sudo /usr/share/doc/libdvdread4/install-css.sh
Restart Handbrake and your DVDs can be read again....
maandag 15 april 2013
Startup script for Ubuntu
When you need to start a service (like Glassfish or Play) in Ubuntu, you can take this script as a template:
#! /bin/sh
case "$1" in
start)
... execute a shell script here ...
;;
stop)
... execute a shell script here ...
;;
restart)
... execute a shell script here ...
;;
esac
exit 0
Make sure to make your scripts executable. In order to get it running during startup, add a link to the init.d directory and register the service-script to make it run as first service (depends on your system which priority you assign, take care here, I just took 01 as an example)
cd /etc/init.d sudo ln -sf ~/your-script.sh your-script.sh sudo update-rc.d your-script.sh defaults 01 01
Reboot and you'll see that your services get started.
ImageMagick, jMagick and Glassfish on a EC2 machine
Recently I had to roll out a REST-Webservice on Glassfish which used jMagick as a library. Now, ImageMagick is a C++ library and is available in Java through JNI. The installation on a standard EC2-Ubuntu AMI is pretty straightforward once you know the tricks. I executed the following steps to get things up and running:
- Make an EC2-Instance, attach an EBS and install JDK7 and GFv3.2.1 (these are the version which I installed)
- Install ImageMagick using sudo yum install ImageMagick. You can't use apt-get or aptitude since Amazon prefers yum.
- Next thing is to install jMagick. You can download the latest from ftp://ftp.imagemagick.org/pub/ImageMagick/java/. Use wget to get the RPM (32 or 64 bit - I used the 64bit version).
wget ftp://ftp.imagemagick.org/pub/ImageMagick/java/jmagick-6.4.0-3.x86_64.rpm - Install the RPM using sudo yum jmagick-6.4.0-3.x86_64.rpm
- When all goes well, you should be able to see a handful of Magick-files using ls /usr/lib64/libM* (which were installed in step 2) and of course the Java library ls /usr/lib64/libJMagick.so
- There should also be an accompagning JAR file for the library. Check if /usr/lib64/jmagick-6.4.0.jar is there.
- Now we get to the Glassfish part. Suppose your domain is called "domain1". Copy the JAR into the /lib directory of your domain so it will get loaded during the startup of Glassfish.
- Point your browser to the admin-console or open the domain.xml. You need to add a JVM-parameter to get this running. In the console go to the configurations / server-config / JVM-settings and then the JVM-options tab and add the following line:
-Djmagick.systemclassloader=no
or add in the domain.xml the line
<jvm-options>-Djmagick.systemclassloader=no</jvm-options>
This line prevents jMagick of using the system-class-loader as you might have expected. Not adding this line leads to errors.
- Restart your domain and deploy the application. The System.loadLibrary("JMagick"); in Magick.java runs as planned. (http://jmagick.svn.sourceforge.net/viewvc/jmagick/trunk/src/magick/Magick.java?revision=91&view=markup)
We can now redeploy our application in Glassfish at will because the class is loaded by Glassfish during the startup. When not, you can expect exception when redeployen when your jMagick.JAR is in your project. The classloader will tell you that the classes are already loaded when you deploy a second time.
PS: when running Maven tests outside the container, do not forget to specifiy the -Djava.library.path=/your-path-to/libJMagick.so.
PS2: if you install JMagick using a repository, then the JMagick.so files are stored in the /usr/lib64/jni directory. Copy the libJMagick.so file to /usr/lib64 and restart your domain. There is no need to add java.library.path to the JVM parameters in the domain.xml (something which apparently doesn't function well).
Abonneren op:
Posts (Atom)