Skip to content
Snippets Groups Projects
Commit 9b8bf87f authored by Johannes Sauer's avatar Johannes Sauer
Browse files

Skripte hinzugefuegt:

 - zur nachtraeglichen Aenderung des Isos
 - Matlab Lizenzcheckout
 - windows shares mounten
 - Matlab Desktop Symbol hinzugefuegt
parent a8517f1a
No related branches found
No related tags found
No related merge requests found
#!/bin/bash
LMUTIL=/usr/local/bin/lmutil
MATLAB=/opt/matlab/bin/matlab
if [ ! -f $LMUTIL -o ! -f $MATLAB ]; then
echo "Required binaries for licence checkout not available. Exiting..."
exit 1
fi
DATUM=$( date '+%d-%b-%Y' -d '14 days' )
cd /tmp
cat >lizenzen.m <<EOF
license checkout MATLAB;
license checkout Communication_Toolbox;
license checkout Image_Toolbox;
license checkout Optimization_Toolbox;
license checkout Signal_Toolbox;
license checkout Signal_Blocks;
quit;
EOF
$LMUTIL lmborrow MLM $DATUM
$MATLAB -nosplash -nojvm -nodesktop -nodisplay -r lizenzen
$LMUTIL lmborrow -clear
$LMUTIL lmborrow -status
# remove empty license file
FLEXLM=/home/mindstorms/.flexlmborrow
if [ ! -s $FLEXLM ]; then
rm -f $FLEXLM
fi
\ No newline at end of file
#!/bin/bash
# script to ease mounting a SMB share
# (c) 2007 Johannes Ballé
licenseBackup() {
# move .flexlmborrow to ~/work and add link to ~/
FLEXLM_OLD=~/.flexlmborrow
FLEXLM_NEW=~/work/.flexlmborrow
[ -d ~/work -a -f $FLEXLM_OLD -a ! -h $FLEXLM_OLD ] && ( mv -f $FLEXLM_OLD $FLEXLM_NEW )
[ -f $FLEXLM_NEW -a ! -f $FLEXLM_OLD ] && ( ln -s $FLEXLM_NEW $FLEXLM_OLD )
}
SHARENAME="$1"
OPTIONS="$2"
if [ "${SHARENAME:0:2}" != "//" -o $# -ge 3 ]; then
echo "Syntax: ${0##*/} //{servername}/{sharename} [option1=xxx,option2,...]" >&2
exit 1
fi
# check if work directory already exists
if [ -e ~/work ]; then
echo "Error: MATLAB work directory already exists" >&2
licenseBackup
exit 1
fi
mkdir ~/work
# mount Windows share
# newer Ubuntu releases require root permissions - use sudo
MACHINE_TYPE=`uname -m`
if [ "$OPTIONS" ]; then
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
sudo mount.cifs "$SHARENAME" ~/work -o "$OPTIONS" || rm -rf ~/work
else
mount.cifs "$SHARENAME" ~/work -o "$OPTIONS" || rm -rf ~/work
fi
else
if [ ${MACHINE_TYPE} == 'x86_64' ]; then
sudo mount.cifs "$SHARENAME" ~/work -o uid=999,gid=999 || rm -rf ~/work
else
mount.cifs "$SHARENAME" ~/work || rm -rf ~/work
fi
fi
licenseBackup
#!/bin/bash
# Link scripts to /usr/local/bin
echo "Linking scripts to /usr/local/bin ..."
for i in /opt/mindstorms/tools/*; do
ln -s $i /usr/local/bin/
done
# Try to find a mindstorms.fat file / mindstorms.dir directory
# in any local partition.
# If it exists, mount it to /home/mindstorms/work.
# Also try to find mindstorms.swp files to use as swap space.
mkdir -p /mnt/localfs /home/mindstorms/work
chmod 700 /mnt
shopt -s nullglob
# HACK: disable gnome's automount functionality for manual mounting
echo "Disabling gnome's automount functionality for manual mounting..."
su - mindstorms -c "dbus-launch --exit-with-session gsettings set org.gnome.desktop.media-handling automount 'false'"
su - mindstorms -c "dbus-launch --exit-with-session gsettings set org.gnome.desktop.media-handling automount-open 'false'"
# Unmount all auto-mounted devices
shopt -s globstar # allow '**' path expansion
echo "Unmounting all auto-mounted devices ..."
for PART in /media/**/; do
if [ ! "$PART" = "/media/cdrom" ]; then
umount "$PART" 2>/dev/null
fi
done
shopt -u globstar # disallow '**' path expansion
# Mount all partitions read-only
echo "Mounting all available partitions read-only ..."
for PART in /dev/disk/by-id/*; do
DEVICE="$( readlink -f "$PART" )"
if ! grep -q "^$DEVICE " /etc/mtab; then
MOUNTPOINT="/mnt/localfs/${PART##*/}"
mkdir "$MOUNTPOINT" || continue
# try reading first sector, mount produces a timeout on card reader devices for some reason
( dd if="$DEVICE" of=/dev/null bs=512 count=1 && mount -o ro "$DEVICE" "$MOUNTPOINT" ) || rmdir "$MOUNTPOINT"
fi
done
# Try to find mindstorms.dir directory (also on boot medium)
if ! mountpoint -q /home/mindstorms/work; then
echo "Looking for mindstorms.dir directory (also on boot medium) ..."
for DIR in /cdrom/mindstorms.dir /mnt/localfs/*/mindstorms.dir; do
MOUNTPOINT="${DIR%/*}"
[ -d "$DIR" ] || continue
echo "Found mindstorms.dir at ${DIR}. Re-mounting as writable ..."
if [ "$MOUNTPOINT" = "/cdrom" ]; then
mount -o remount,rw /cdrom || continue
elif umount "$MOUNTPOINT"; then
PART="/dev/disk/by-id/${MOUNTPOINT##*/}"
if [ "$( blkid -s TYPE -o value "$PART" )" = "ntfs" ]; then
mount -t ntfs-3g -o rw,no_def_opts,umask=077 "$PART" "$MOUNTPOINT" || continue
else
mount -o rw "$PART" "$MOUNTPOINT" || continue
fi
fi
bindfs --create-as-mounter -u mindstorms -g mindstorms "$DIR" /home/mindstorms/work && break
done
fi
# If this failed, try to find a mindstorms.fat file
if ! mountpoint -q /home/mindstorms/work; then
echo "Looking for mindstorms.fat file (also on boot medium) ..."
for FAT in /cdrom/mindstorms.fat /mnt/localfs/*/mindstorms.fat; do
MOUNTPOINT="${FAT%/*}"
[ "$( blkid -s TYPE -o value "$FAT" )" = "vfat" ] || continue
echo "Found mindstorms.fat at ${FAT}. Re-mounting as writable ..."
if [ "$MOUNTPOINT" = "/cdrom" ]; then
mount -o remount,rw /cdrom || continue
elif umount "$MOUNTPOINT"; then
PART="/dev/disk/by-id/${MOUNTPOINT##*/}"
if [ "$( blkid -s TYPE -o value "$PART" )" = "ntfs" ]; then
mount -t ntfs-3g -o rw,no_def_opts,umask=077 "$PART" "$MOUNTPOINT" || continue
else
mount -o rw "$PART" "$MOUNTPOINT" || continue
fi
fi
mount -t vfat -o loop,rw,uid=999,gid=999,fmask=0133,dmask=0022 "$FAT" /home/mindstorms/work && break
done
fi
# Try to find all mindstorms.swp files
echo "Looking for mindstorms.swp files ..."
for SWP in /mnt/localfs/*/mindstorms.swp; do
MOUNTPOINT="${SWP%/*}"
PART="/dev/disk/by-id/${MOUNTPOINT##*/}"
echo "Mounting swap file at ${SWP} as writable ..."
if umount "$MOUNTPOINT"; then
if [ "$( blkid -s TYPE -o value "$PART" )" = "ntfs" ]; then
mount -t ntfs-3g -o rw,no_def_opts,umask=077 "$PART" "$MOUNTPOINT" || continue
else
mount -o rw "$PART" "$MOUNTPOINT" || continue
fi
fi
# just in case we mount the same disk twice under a different name,
# make sure swap space is not yet being used
swapoff "$SWP"
mkswap "$SWP" || continue
swapon "$SWP"
done
# Try to unmount all unused partitions
echo "Unmounting all unused partitions ..."
for PART in /mnt/localfs/*; do
echo "Unmounting ${PART}."
umount "$PART" 2>/dev/null
done
# Remove work directory if not mounted
if ! mountpoint -q /home/mindstorms/work; then
echo "Removing work directory as no available mountpoint found."
rm -rf /home/mindstorms/work
fi
# HACK: re-enable gnome's automount functionality.
echo "Re-enabling gnome's automount functionality ..."
su - mindstorms -c "dbus-launch --exit-with-session gsettings set org.gnome.desktop.media-handling automount 'true'"
su - mindstorms -c "dbus-launch --exit-with-session gsettings set org.gnome.desktop.media-handling automount-open 'true'"
# Download or link lmutil
echo "Downloading lmutil for Matlab license checkout ..."
LMUTIL=/usr/local/bin/lmutil
LMUTIL_LOCAL=/opt/matlab/etc/glnxa64/lmutil
[ -f $LMUTIL_LOCAL -a ! -e $LMUTIL ] && ln -s $LMUTIL_LOCAL $LMUTIL
[ -e $LMUTIL ] || ( wget -q -O - http://www.ient.rwth-aachen.de/cms/uploads/rwthonly/lehre/mindstorms/lmutil.bz2 | bunzip2 >$LMUTIL )
[ -e $LMUTIL ] && chmod 755 $LMUTIL
# check out matlab licence
echo "Checking out Matlab license ..."
[ -e $LMUTIL ] && su - mindstorms /usr/local/bin/licencecheckout.sh
# backup .flexlmborrow to /home/mindstorms/work and add link to home directory
echo "Backing up .flexlmborrow to /home/mindstorms/work ..."
FLEXLM_OLD=/home/mindstorms/.flexlmborrow
FLEXLM_NEW=/home/mindstorms/work/.flexlmborrow
[ -d /home/mindstorms/work -a -f $FLEXLM_OLD -a ! -h $FLEXLM_OLD ] && ( sudo -u mindstorms mv -f $FLEXLM_OLD $FLEXLM_NEW )
[ -f $FLEXLM_NEW -a ! -f $FLEXLM_OLD ] && ( sudo -u mindstorms ln -s $FLEXLM_NEW $FLEXLM_OLD )
# add matlab desktop launcher
cp /usr/share/applications/matlab.desktop /home/mindstorms/Desktop/
chmod +x /home/mindstorms/Desktop/matlab.desktop
sudo chown mindstorms:mindstorms /home/mindstorms/Desktop/matlab.desktop
# copy laboratory documentation
echo "Copying documentation ..."
DOCUMENTATION_DIR=/home/mindstorms/Desktop/Versuchsunterlagen
[ ! -d ${DOCUMENTATION_DIR} ] && ( sudo -u mindstorms mkdir -p ${DOCUMENTATION_DIR} )
wget -q -O - http://www.ient.rwth-aachen.de/cms/uploads/rwthonly/lehre/mindstorms/versuchsunterlagen.tar.gz | tar -xzf - -C ${DOCUMENTATION_DIR}
sudo chown -R mindstorms:mindstorms ${DOCUMENTATION_DIR}
#!/bin/bash
# script to ease unmounting a SMB share
# (c) 2007 Johannes Ballé
if [ $# -ne 0 ]; then
echo "Syntax: ${0##*/}" >&2
exit 1
fi
sudo umount ~/work && rm -rf ~/work
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment