-
Notifications
You must be signed in to change notification settings - Fork 18
/
termux_setup.sh
executable file
·50 lines (38 loc) · 1.48 KB
/
termux_setup.sh
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
#!/bin/sh
# Install the dependencies on Termux, which could be difficult, especially hunspell.
# Update packages
pkg update
pkg upgrade -y
# First, make sure pip is installed.
pkg install -y python-pip
# Install hunspell (the original C++ package).
pkg install -y hunspell
# Fix the file paths of headers and libraries.
ln -s $PREFIX/include/hunspell/* $PREFIX/include/
ln -s $PREFIX/lib/libhunspell-*.so $PREFIX/lib/libhunspell.so
# Now install the python package with pip
pip install hunspell
# Install lxml's dependencies
# pkg install -y libxml2 libxslt
# Install libyaml
pkg install -y libyaml
# Install other dependencies
pip install -r server/requirements.txt
# Install opencc
# pkg install -y libopencc
# pip install opencc
# Set up exteral storage
# termux-setup-storage
# This is non-blocking, so we have to let the user do it manually.
# Configure default source directory
mkdir -p /sdcard/Documents/Dictionaries
mkdir -p ~/.silverdict
echo -e "history_size: 100\nnum_suggestions: 10\nsources:\n- /sdcard/Documents/Dictionaries" > ~/.silverdict/misc.yaml
# Create Termux:Widget shortcuts
mkdir -p ~/.shortcuts
PROJECT_DIR=$(pwd)
echo -e "#!/bin/sh\ntermux-wake-lock\npython $PROJECT_DIR/server/server.py 0.0.0.0 &> ~/.silverdict/server.log &" > ~/.shortcuts/SilverDict-Start.sh
echo -e "#!/bin/sh\nkillall -SIGTERM python\ntermux-wake-unlock\nexit" > ~/.shortcuts/SilverDict-Stop.sh
chmod +x ~/.shortcuts/*
# Release the lock upon logout
echo "#!/bin/sh\ntermux-wake-unlock" >> ~/.bash_logout