-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·58 lines (50 loc) · 2.03 KB
/
setup.sh
File metadata and controls
executable file
·58 lines (50 loc) · 2.03 KB
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
#!/bin/bash
# Set up path variables here
# Simple paths without whitespaces expected
# Example:
# - YA_DISK_ROOT = $HOME/Public
# - YA_DISK_RELATIVE = 'yaDisk', computed path: $HOME/Public/yaDisk
# - INBOX_RELATIVE = 'Media', computed path: $HOME/Public/yaDisk/Media
#
YA_DISK_ROOT=$HOME/Public
YA_DISK_RELATIVE='yaDisk'
INBOX_RELATIVE='Media'
LOG_PATH='$YA_DISK_ROOT/yaMedia.log'
cd "$(dirname $0)"
echo "working directory changed to $PWD"
# Set global static YA_DISK_ROOT var
echo "Root access required to set global static YA_DISK_ROOT var"
isRootSetString=$( grep ^YA_DISK_ROOT= /etc/environment | tail -1 )
if [ -z "$isRootSetString" ]; then
echo "YA_DISK_ROOT=$YA_DISK_ROOT" | sudo tee -a /etc/environment
else
echo ""
tac /etc/environment | awk -v dest="YA_DISK_ROOT=\"$YA_DISK_ROOT\"" "!x{x=sub(/^YA_DISK_ROOT=.*/,dest)}1" | tac | sudo tee /etc/environment
echo ""
fi
echo "Set local script-scoped vars"
output=$( awk -v line="yaDisk=\$YA_DISK_ROOT/$YA_DISK_RELATIVE" "!x{x=sub(/^yaDisk=.*/,line)}1" ./ydmenu.sh | awk -v line="streamDir=\$yaDisk/$INBOX_RELATIVE" "!x{x=sub(/^streamDir=.*/,line)}1" | awk -v line="logFilePath=$LOG_PATH" "!x{x=sub(/^logFilePath=.*/,line)}1" )
echo "$output" > ./ydmenu.sh
output=$( awk -v line="tee -a $LOG_PATH" "{gsub(/tee -a.*/,line)}1" ./ydpublish.desktop )
echo "$output" > ./ydpublish.desktop
echo "Create symlinks accordingly"
serviceMenuList=("$HOME/.local/share/kservices5/ServiceMenus" "$HOME/.local/share/kio/servicemenus")
for serviceMenu in "${serviceMenuList[@]}"; do
if [ ! -L $serviceMenu/ydpublish.desktop ]; then
desktopBak=$serviceMenu/ydpublish.desktop.bak
if [ -f $desktopBak ]; then
echo "Backup already exist: $desktopBak"
else
echo "Create backup for default desktop file $desktopBak"
mv $serviceMenu/ydpublish.desktop $desktopBak
fi
ln -s "$PWD/ydpublish.desktop" $serviceMenu
fi
if [ ! -L $HOME/bin/ydmenu.sh ]; then
ln -s "$PWD/ydmenu.sh" $HOME/bin
fi
done
echo "Make scripts executable"
chmod +x ./ydpublish.desktop
chmod +x ./ydmenu.sh
echo "Done"