Skip to content

Commit

Permalink
wsl mounter
Browse files Browse the repository at this point in the history
  • Loading branch information
mjoppich committed Jun 2, 2019
1 parent 492eeee commit b27a3bf
Show file tree
Hide file tree
Showing 4 changed files with 333 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ Microsoft Windows 10 (build 17763, Oct. 2018 update) with Windows Subsystem for
This page describes [how to setup WSL](http://biogui.readthedocs.io/en/latest/build_wsl.html).
**Place bioGUI into a location which does not contain spaces in its name, e.g not `C:\Program Files\bioGUI` ! `C:\bioGUI` or `D:\bioGUI\` is fine though!**

If you want to access external drives (USB stick, network drive), you first need to *mount* this drive into WSL.
The WSL *Mount Drive* install module will install a script which can do this for you. Make sure to save the template and use the *Mount Drive (WSL)* template to make the drive available to WSL. You need to enter the drive-letter you want to mount (e.g. F), and your *sudo* password.

### Mac OS

Expand Down
2 changes: 2 additions & 0 deletions doc/user_guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Follow the instructions to setup WSL: :ref:`build_wsl_intro`.

**You can put bioGUI for instance into the locations** ``C:\bioGUI\`` **or** ``D:\bioGUI\`` **!**

If you want to access external drives (USB stick, network drive), you first need to *mount* this drive into WSL.
The WSL **Mount Drive** install module will install a script which can do this for you. Make sure to save the template and use the *Mount Drive (WSL)* template to make the drive available to WSL. You need to enter the drive-letter you want to mount (e.g. F), and your *sudo* password.

Linux
-----
Expand Down
158 changes: 158 additions & 0 deletions install_templates/install_phanotate.igui
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
#! Install PHANOTATE (github)

if [ "$(uname)" == "Darwin" ]; then
source ~/.bash_profile
else
echo ""
fi

echo "Dependencies: r-base"
if [ ! "$2" = "" ]; then

if [ "$(uname)" == "Darwin" ]; then

echo "Installing R and setting PATH for R libraries"
brew install gcc@8

else
echo "No dependencies"
fi


else
echo "No sudo password, not installing dependencies"
fi

## set all variables
PROG=PHANOTATE
PROGNICE=PHANOTATE
PROGDIR=$1


if [ -z "${PROGDIR}" ]; then
PROGDIR=~/bioGUI/progs/
fi

PROGDIRESC=$(echo $PROGDIR | sed 's/ /\\ /g')
APPBINARYDIR="${PROGDIR}/${PROG}/"

rm -rf "$PROGDIR/$PROG"

## create progdir

git clone --recursive git@github.com:deprekate/PHANOTATE.git $PROG

cd "$PROGDIR/$PROG"

if [ "$(uname)" == "Darwin" ]; then
make CC=gcc-8
else
make
fi


if [ $# -gt 2 ]; then

if [ "$3" = "1" ]; then

if ! grep -q "$PROGDIRESC/$PROG" ~/.bashrc; then
echo "export PATH=\"$PROGDIRESC/$PROG:\$PATH\" " >> ~/.bashrc;
fi
fi

fi

PY3PATH=`which python3`

APPBINARYESC="${PROGDIRESC}/${PROG}/"
APPBINARY="${PROGDIRESC}/${PROG}/phanotate.py"
if [ -z "$(ls -A ${APPBINARYESC})" ] || [ ! -f ${APPBINARY} ]; then
(>&2 echo ${APPBINARYESC})
(>&2 ls ${APPBINARYESC})

(>&2 echo " \n \n \n")

(>&2 echo ${PROGDIRESC})
(>&2 ls ${PROGDIRESC})

(>&2 echo " \n \n \n")

(>&2 echo ${APPBINARY})
(>&2 ls ${APPBINARY})

(>&2 echo " \n \n \n")

(>&2 echo "ERROR: The application directory is empty after installation.")
(>&2 echo "ERROR: If you experience problems please re-install the software and create an issue on https://github.com/mjoppich/bioGUI.")
(>&2 echo "ERROR: For creating the issue, please upload the log.txt file of your installation attempt.")

(>&2 echo " \n \n \n")

else

echo "${PROG} has been installed into ${APPBINARYESC}"
echo "Binary location ${APPBINARY}"

fi

if [ $# -eq 5 ]; then

IP=$4
PORT=$5

NCCMD=""

if [ "$(uname)" == "Darwin" ]; then
NCCMD="nc -c $IP $PORT"
else
NCCMD="nc -q 0 $IP $PORT"
fi


$NCCMD <<EOF

<template description="$PROGNICE" title="$PROGNICE">
<window title="$PROGNICE">
<vgroup>

<checkbox id="WSLsel" value="true" selectonwindows="true">Run in WSL?</checkbox>

<group title="Input Files Reference">

<filedialog id="phanotate_input" output="false" multiple="false">Input Fasta</filedialog>
<filedialog id="phanotate_output" output="true" multiple="false">Output ORFs</filedialog>

<label>Regular Expression for finding sample data</label>
<input id="msempire_sample_regex">*SRR*</input>

<action program="run_phanotate">Run $PROGNICE</action>

</group>


<streambox id="output1">
<stream id="outputstream1">COUT</stream>
<stream id="outputstream2">CERR</stream>
</streambox>

</vgroup>
</window>
<execution>

<relocate id="phanotate_infasta_rel" from="\${phanotate_input}" wsl="\${WSLsel}"/>


<const id="bindir">${APPBINARYDIR}/</const>

<execute program="run_phanotate" location="" exec="$PY3PATH" param="\${bindir}/phanotate.py \${phanotate_infasta_rel}" wsl="WSLsel">
<output type="FILE_STD" color="green" location="\${phanotate_output}" />
<output type="CERR" color="red" to="outputstream2" />
</execute>

</execution>
</template>


EOF

fi
171 changes: 171 additions & 0 deletions install_templates/install_wsl_mounter.igui
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
#! Install Mount Drive (WSL only)

if [ "$(uname)" == "Darwin" ]; then
echo "This will not run on Mac OS"
exit;
else
echo ""
fi

if [ ! "$2" = "" ]; then

if [ "$(uname)" == "Darwin" ]; then
echo "This will not run on Mac OS"
exit;
else

echo "No Dependencies"

fi
else
echo "No sudo password, not installing dependencies"
fi

## set all variables
PROG=MNTDRV
PROGDIR=$1

if [ -z "${PROGDIR}" ]; then
PROGDIR=~/bioGUI/progs/
fi


PROGDIRESC=$(echo $PROGDIR | sed 's/ /\\ /g')
APPBINARYDIR=${PROGDIRESC}/${PROG}/

if [ -d "$PROGDIR/$PROG" ]; then
echo "Removing Folder $PROGDIR/$PROG"
rm -rf $PROGDIR/$PROG
fi

## create progdir
mkdir -p "$PROGDIR/$PROG"

APPBINARYDIR=${PROGDIRESC}/${PROG}/

UMOUNTBIN=`which umount`
MOUNTBIN=`which mount`

cat <<EOS > $APPBINARYDIR/mntdrv.sh
#!/usr/bin/env sh

DRVLTR=\$1

DRVLTR=\`echo "\$DRVLTR" | tr '[:upper:]' '[:lower:]'\`
echo $2 | sudo -S mkdir -p /mnt/\$DRVLTR/

echo $2 | sudo -S $UMOUNTBIN /mnt/\$DRVLTR/
echo $2 | sudo -S $MOUNTBIN -t drvfs \$DRVLTR: /mnt/\$DRVLTR/ -o rw,noatime,uid=1000,gid=1000,case=off

echo "Mounted windows drive \$DRVLTR:\\ to /mnt/\$DRVLTR"

ls /mnt/\$DRVLTR/

EOS

APPBINARYESC="${PROGDIRESC}/${PROG}/"
APPBINARY="${PROGDIRESC}/${PROG}/mntdrv.sh"
if [ -z "$(ls -A ${APPBINARYESC})" ] || [ ! -f ${APPBINARY} ]; then
(>&2 echo ${APPBINARYESC})
(>&2 ls ${APPBINARYESC})

(>&2 echo " \n \n \n")

(>&2 echo ${PROGDIRESC})
(>&2 ls ${PROGDIRESC})

(>&2 echo " \n \n \n")

(>&2 echo ${APPBINARY})
(>&2 ls ${APPBINARY})

(>&2 echo " \n \n \n")

(>&2 echo "ERROR: The application directory is empty after installation.")
(>&2 echo "ERROR: If you experience problems please re-install the software and create an issue on https://github.com/mjoppich/bioGUI.")
(>&2 echo "ERROR: For creating the issue, please upload the log.txt file of your installation attempt.")

(>&2 echo " \n \n \n")

else

echo "${PROG} has been installed into ${APPBINARYESC}"
echo "Binary location ${APPBINARY}"

fi


if [ $# -eq 5 ]; then

IP=$4
PORT=$5

echo "Sending Template to $IP at $PORT"

NCCMD=""

if [ "$(uname)" == "Darwin" ]; then
NCCMD="nc -c $IP $PORT"
else
NCCMD="nc -q 0 $IP $PORT"
fi


$NCCMD <<EOF

<template description="Mount Drive (WSL)" title="Mount Drive">

<window width="500" height="1000" title="Mount Drive">

<vgroup>


<group title="Mount Options">


<label>Which Window Drive do you want to make accessible (mount)?</label><input id="mntr_drv"></input>
<label>WSL User/sudo Password</label><input id="mntr_pw" type="password"></input>

<action program="assembly" hint="Click Here to mount the drive">Mount</action>
</group>


<group title="General Options">
<label>Run in WSL on Windows?</label><checkbox id="WSLsel" value="true" selectonwindows="true">Run in WSL?</checkbox>
</group>

<streambox linebreaks="TRUE" id="output1">
<stream id="outputstream1">OS1</stream>
<stream id="outputstream2">OS2</stream>
</streambox>


</vgroup>

</window>



<execution>
<const id="bindir">${APPBINARYDIR}/</const>


<add id="args">
<const>${APPBINARYDIR}/mntdrv.sh</const>
<value from="\${mntr_drv}"/>
<value from="\${mntr_pw}"/>
</add>

<execute program="assembly" param="bash \${args}" location="/usr/bin/" exec="env" wsl="WSLsel">
<output type="COUT" color="green" to="outputstream1" />
<output type="CERR" color="red" to="outputstream2" />
</execute>


</execution>
</template>


EOF

fi

0 comments on commit b27a3bf

Please sign in to comment.