Skip to content

Commit

Permalink
Merge pull request #148 from azubieta/appimage_wrapper
Browse files Browse the repository at this point in the history
Appimage wrapper
  • Loading branch information
raoulh authored Nov 11, 2017
2 parents 8acef5b + 314a819 commit fbe5284
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 15 deletions.
3 changes: 1 addition & 2 deletions data/moolticute.desktop
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Moolticute
Comment=Start Moolticute daemon and App
Exec=/usr/bin/moolticute
Icon=moolticute
Terminal=false
Categories=Utility
Categories=Utility;
112 changes: 112 additions & 0 deletions data/moolticute.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
#!/bin/bash
##
# Wrapper for the moolticute AppImage
##

me="Moolticute.AppImage"
UDEV_RULES_FILE_PATH="/etc/udev/rules.d/50-mooltipass.rules"
UDEV_RULE='SUBSYSTEMS=="usb", ATTRS{idVendor}=="16d0", ATTRS{idProduct}=="09a0", SYMLINK+="mooltipass" TAG+="uaccess", TAG+="udev-acl"'

help_msg="Moolticute for linux
Usage:
$me <arg>
Arguments:
-d --daemon Runs daemon only mode.
-i --install Install moolticute UDev rules
-c --check Check moolticute UDev rules
-u --uninstall Uninstall moolticute UDev rules
-h --help This help
Example:
Run Moolticute normaly
./$me
Run only the moolticuted daemon
./$me --daemon
";

SUDO_MSG="Allow Mooltipass Udev rules to be applied in your system?"

DAEMON_ONLY=0
INSTALL=0
UNINSTALL=0
CHECK=0

case "$1" in
-d|--daemon)
DAEMON_ONLY=1
;;
-i|--install)
INSTALL=1
;;
-c|--check)
CHECK=1
;;
-u|--uninstall)
UNINSTALL=1
;;
-h|-\?|--help)
printf "$help_msg"
exit
;;
-?*)
printf 'WARN: Unknown option (ignored): %s\n' "$1" >&2
exit 1
;;

esac

# Check if UDEV rules are set on normal run
if (( $# == 0 )) &&\
[ ! -s $UDEV_RULES_FILE_PATH ];
then

SUDO_BIN=$( which kdesudo || which gksudo || which sudo)

INSTALL_COMMAND="echo \"$UDEV_RULE\" | tee $UDEV_RULES_FILE_PATH && udevadm control --reload-rules"

SUDO_ARGS=
FILENAME=$(basename "$SUDO_BIN")
case "$FILENAME" in
'sudo')
echo "$SUDO_MSG"
$SUDO_BIN sh -c "$INSTALL_COMMAND"
;;
'gksudo')
$SUDO_BIN -m "$SUDO_MSG" "sh -c '$INSTALL_COMMAND'"
;;
'kdesudo')
$SUDO_BIN -i moolticute --comment "$SUDO_MSG" -c "$INSTALL_COMMAND"
;;
esac
fi

if (( $DAEMON_ONLY == 1 )) ;
then
echo "Running daemon only"
moolticuted
elif (( $INSTALL == 0 )) && (( $UNINSTALL == 0 )) && (( $CHECK == 0 ));
then
moolticute
elif (( $INSTALL == 1 ));
then
echo "Installing moolticute UDEV rules"
echo $UDEV_RULE | sudo tee $UDEV_RULES_FILE_PATH
sudo udevadm control --reload-rules
elif (( $CHECK == 1 ));
then
if [ -s $UDEV_RULES_FILE_PATH ];
then
echo "Moolticute Udev rules are NOT installed."
exit 1;
else
echo "Moolticute Udev rules are installed."
exit 0;
fi
elif (( $UNINSTALL == 1 ));
then
echo "Uninstalling moolticuted UDEV rules"
sudo rm $UDEV_RULES_FILE_PATH
sudo udevadm control --reload-rules
fi
18 changes: 5 additions & 13 deletions scripts/ci/linux/appimage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,12 @@ source $SCRIPTDIR/../funcs.sh
########################################################################
cp ./debian/moolticute/usr/* $TARGET_DIR -r

########################################################################
# Generate .desketop file and icon
########################################################################

echo "[Desktop Entry]
Version=1.0
Type=Application
Name=Moolticute
Comment=Moolticute allows your browser extensions to talk with the Mooltipass.
TryExec=moolticute
Exec=moolticute %F
Icon=moolticute" > $BASE_PATH/$APP/$APP.AppDir/moolticute.desktop

cp ./data/moolticute.desktop $BASE_PATH/$APP/$APP.AppDir
cp ./img/AppIcon.svg $BASE_PATH/$APP/$APP.AppDir/moolticute.svg
cp ./data/moolticute.sh $BASE_PATH/$APP/$APP.AppDir/usr/bin/

# Use the wrapper instead of the
sed -i 's/Exec=\/usr\/bin\/moolticute/Exec=moolticute.sh/g' /$BASE_PATH/$APP/$APP.AppDir/moolticute.desktop

########################################################################
# Copy desktop and icon file to AppDir for AppRun to pick them up
Expand Down

0 comments on commit fbe5284

Please sign in to comment.