I've been playing around with a Linux install script and I was wondering if any Linux people could give their thoughts on it.
It seems to work with debian, kubuntu, suse and mint but I'm not 100% sure its all 'official'
This is the current script
After you 'sudo' run this script LDCad will/should be present in the graphics menu and will handle the mime type "text/x-ldraw" (double click on mpd etc).
Any feedback is welcome.
update: added screenshot
It seems to work with debian, kubuntu, suse and mint but I'm not 100% sure its all 'official'
This is the current script
Code:
#!/bin/sh
# ======================================================================================================================
# This script will copy the LDCad files into suitable central, current user independend, locations.
# It will also try to register the application so it shows up in the application menu.
# This will also make LDCad available to 'open with' operations etc.
#
# NOTE 1: This might not work for all distributions, feel free to adjust the below script to make it work yourself.
# If so, please consider sending me your modifications so I might be able to improve the script for all.
# NOTE 2: You need root/sudo rights to run the script as the /usr folders are usually read-only for normal users.
# ======================================================================================================================
if [ `whoami` != "root" ]
then
echo "ERROR: This script needs 'sudo' rights to copy files to otherwise read-only locations."
exit
fi
#Destination locations
# The <foo> strings are variables LDCad will process, see http://www.melkert.net/LDCad/tech/config for detauls.
appdir="/usr/bin"
datadir="/usr/share/LDCad"
cfgdir="/etc"
cfgfn="$cfgdir/LDCad.cfg"
userdir="<userAppDataDir>/LDCad"
scdir="/usr/share/applications"
mimebasedir="/usr/share/mime"
mimedir="$mimebasedir/packages"
scfn="$scdir/LDCad.desktop"
icofn="$datadir/resources/LDCad.ico"
mimefn="$mimedir/ldraw.xml"
#Copy the main (and only) executable.
echo "Copying executable to: $appdir"
cp LDCad $appdir
#Copy the central (static) program data
echo "Copying data files to: $datadir"
mkdir $datadir
mkdir $datadir/seeds
cp -av seeds/*.sf $datadir/seeds
cp -avr docs $datadir
cp -avr resources $datadir
#Create the main config file which instructs the main executable about where to find its stuff.
echo "Creating config file: $cfgfn"
echo "[paths]" > $cfgfn
echo "resourcesDir=$datadir/resources" >> $cfgfn
echo "seedsDir=$datadir/seeds" >> $cfgfn
echo "logDir=$userdir/logs" >> $cfgfn
echo "cfgDir=$userdir/config" >> $cfgfn
echo "guiDir=$userdir/gui" >> $cfgfn
echo "colorBinDir=$userdir/colorBin" >> $cfgfn
echo "partBinDir=$userdir/partBin" >> $cfgfn
echo "examplesDir=$userdir/examples" >> $cfgfn
echo "templatesDir=$userdir/templates" >> $cfgfn
echo "donorsDir=$userdir/donors" >> $cfgfn
echo "shadowDir=$userdir/shadow" >> $cfgfn
#Register ldraw mime type
if [ -e "$mimefn" ]
then
echo "Skipping mime type stuff, file \"$mimefn\" is already there."
else
echo "Creating ldraw mime type file: $mimefn"
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $mimefn
echo "<mime-info xmlns=\"http://www.freedesktop.org/standards/shared-mime-info\">" >> $mimefn
echo " <mime-type type=\"text/x-ldraw\">" >> $mimefn
echo " <comment>LDraw model document</comment>" >> $mimefn
echo " <sub-class-of type=\"text/plain\"/>" >> $mimefn
echo " <glob pattern=\"*.ldr\"/>" >> $mimefn
echo " <glob pattern=\"*.mpd\"/>" >> $mimefn
echo " </mime-type>" >> $mimefn
echo "</mime-info>" >> $mimefn
echo "Updating mime database"
update-mime-database $mimebasedir
fi
#Creating desktop entry file.
echo "Creating desktop entry file: $scfn"
./genDskEntry.sh "$appdir" "$datadir" "$scdir"
echo "Updating desktop database"
update-desktop-database
#Done
echo "All done."
After you 'sudo' run this script LDCad will/should be present in the graphics menu and will handle the mime type "text/x-ldraw" (double click on mpd etc).
Any feedback is welcome.
update: added screenshot