-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit
executable file
·138 lines (122 loc) · 2.61 KB
/
init
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/bin/sh
CURDIR=$(cd $(dirname $0) && pwd)
smbconf_def="$CURDIR/conf/smb.def"
CONFIDR="$CURDIR/conf"
PACKAGEID="com.modouwifi.samba"
# to tp
TO_TP_TITLE="魔豆文件共享"
TO_TP_CONF_DIR="/data/conf/launcher/conf.d"
TO_TP_CONF_FILE="$TO_TP_CONF_DIR/samba_share.conf"
TO_TP_ICON="$CURDIR/res/icon.png"
TO_TP_PRESSED_ICON="$CURDIR/res/picon.png"
PIDFILE="$CURDIR/custom.pid"
SMBSTATUSFILE="$CURDIR/conf/smb.status"
usage()
{
echo "ERROR: action missing"
echo "syntax: $0 <start|stop|restart|status|config|install|uninstall>"
echo "example: $0 start"
}
install()
{
# to tp
if [ ! -d $TO_TP_CONF_DIR ]; then
mkdir -p $TO_TP_CONF_DIR
fi
echo "{" > "$TO_TP_CONF_FILE"
echo "\"name\" : \"$TO_TP_TITLE\"," >> "$TO_TP_CONF_FILE"
echo "\"icon\" : \"$TO_TP_ICON\"," >> "$TO_TP_CONF_FILE"
echo "\"iconPressed\" : \"$TO_TP_PRESSED_ICON\"," >> "$TO_TP_CONF_FILE"
echo "\"exec\" : \"$CURDIR/sbin/smb-action.sh tpstart\"," >> "$TO_TP_CONF_FILE"
echo "\"msgNum\" : 4" >> "$TO_TP_CONF_FILE"
echo "}" >> "$TO_TP_CONF_FILE"
return 0;
}
uninstall()
{
rm /lib/libbigballofmud.so.0
rm $TO_TP_CONF_FILE
echo "uninstall";
return 0;
}
stop()
{
$CURDIR/sbin/smb-server.sh stop
/system/sbin/appInfo.sh set_status $PACKAGEID NOTRUNNING
echo 0 > $SMBSTATUSFILE
return 0;
}
start()
{
$CURDIR/sbin/smb-server.sh start
/system/sbin/appInfo.sh set_status $PACKAGEID ISRUNNING
echo 1 > $SMBSTATUSFILE
return 0;
}
status()
{
echo "Hello, modou";
return 0;
}
set_config()
{
$CURDIR/sbin/smb-server.sh syncConfig
$CURDIR/sbin/smb-server.sh stop
$CURDIR/sbin/smb-server.sh start
$CURDIR/sbin/smb-server.sh flush
/system/sbin/appInfo.sh set_status $PACKAGEID ISRUNNING
return 0;
}
# main
if [ $# -lt 1 ]; then
usage init
exit 1
fi
case "$1" in
"stop")
stop;
if [ "0" != "$?" ]; then
exit 1;
fi
exit 0;
;;
"start")
start;
if [ "0" != "$?" ]; then
exit 1;
fi
exit 0;
;;
"status")
status;
if [ "0" != "$?" ]; then
exit 1;
fi
exit 0;
;;
"set_config")
set_config;
if [ "0" != "$?" ]; then
exit 1;
fi
exit 0;
;;
"install")
install;
if [ "0" != "$?" ]; then
exit 1;
fi
exit 0;
;;
"uninstall")
uninstall;
if [ "0" != "$?" ]; then
exit 1;
fi
exit 0;
;;
*)
usage init;
exit 1;
;;
esac