-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathslack-day
executable file
·79 lines (73 loc) · 2.66 KB
/
slack-day
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
BACKUP_FILE="$DIR/backup/ssb-interop.js"
if [ "$(uname -r | sed -n 's/.*\( *Microsoft *\).*/\1/p')" == "Microsoft" ] # Windows OS
then
OS="windows"
INTEROP_FOLDER_ROOT="$(cmd.exe /c 'echo|set /p=%LOCALAPPDATA%' | sed -n 's/\\/\//pg' | sed -n 's/C:/\/mnt\/c/p')"
LATEST_APP_DIR="$(ls -t ${INTEROP_FOLDER_ROOT} | grep 'app-[0-9]' | head -n1)"
INTEROP_FOLDER="${INTEROP_FOLDER_ROOT}/slack/${LATEST_APP_DIR}/resources/app.asar.unpacked/src/static"
EXE_FILE="${INTEROP_FOLDER_ROOT}/slack/slack.exe"
if [ ! -d "$INTEROP_FOLDER" ]
then
IS_VERSION_4=true
INTEROP_FOLDER="${INTEROP_FOLDER_ROOT}/slack/${LATEST_APP_DIR}/resources/app.asar.unpacked/dist"
ASAR_FILE="${INTEROP_FOLDER_ROOT}/slack/${LATEST_APP_DIR}/resources/app.asar"
BACKUP_FILE="$BACKUP_FOLDER/ssb-interop.bundle.js"
ASAR="$DIR/bin/asar"
fi
elif [ "$(uname)" == "Linux" ] # Linux OS
then
INTEROP_FOLDER="/usr/lib/slack/resources/app.asar.unpacked/src/static"
elif [ "$(uname)" == "Darwin" ] # Mac OS
then
INTEROP_FOLDER="/Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static"
if [ ! -d "$INTEROP_FOLDER" ]
then
IS_VERSION_4=true
INTEROP_FOLDER="$DIR/files/app.asar.unpacked/dist"
ASAR_FILE="/Applications/Slack.app/Contents/Resources/app.asar"
BACKUP_FILE="$BACKUP_FOLDER/ssb-interop.bundle.js"
ASAR="$DIR/bin/asar"
fi
fi
if [ $IS_VERSION_4 ]
then
if [ ! -f $ASAR ]
then
echo "asar exec not found"
exit 1
fi
if [ ! -f "$INTEROP_FILE" ]
then
$ASAR extract $ASAR_FILE ./files/app.asar.unpacked
fi
fi
if [ -f "$BACKUP_FILE" ]
then
cp "$BACKUP_FILE" "$INTEROP_FOLDER"
# restart slack
if [ "$OS" == "windows" ] # Windows OS
then
cmd.exe /c 'taskkill /F /IM slack.exe' &> /dev/null
$EXE_FILE </dev/null &>/dev/null & # start slack process in detached mode
elif [ "$(uname)" == "Linux" ] # Linux OS
then
if [ $(ps aux | grep -i slack | wc -l) -gt 1 ]
then
killall "slack" # kill all slack processes
fi
slack </dev/null &>/dev/null & # start slack process in detached mode
elif [ "$(uname)" == "Darwin" ] # Mac OS
then
if [ $IS_VERSION_4 ]
then
sudo $ASAR pack ./files/app.asar.unpacked $ASAR_FILE
fi
if [ $(ps aux | grep -i Slack | wc -l) -gt 1 ]
then
killall "Slack" # kill all slack processes
fi
/Applications/Slack.app/Contents/MacOS/Slack </dev/null &>/dev/null & # start slack process in detached mode
fi
fi