-
Notifications
You must be signed in to change notification settings - Fork 105
/
Copy pathinstall-tinyfilemanager.sh
executable file
·103 lines (80 loc) · 3.81 KB
/
install-tinyfilemanager.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
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
#!/usr/bin/env bash
# Author: Stefan Saam, [email protected]
#######################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#######################################################################
# uses SCRIPT_MODE from parent script (if existing)
echo "Installing tinyfilemanager..."
# Don't start as root
if [[ $EUID -eq 0 ]]; then
echo "Run the script as a regular user"
exit 1
fi
# change into actual user-dir
cd
# define DIRs
INSTALLER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ ! "${INSTALLER_DIR}" =~ "little-backup-box" ]]; then
# in case it is called by regular install command (curl ...)
INSTALLER_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/little-backup-box"
fi
WEB_ROOT_TINYFILEMANAGER="/var/www/tinyfilemanager"
sudo mkdir -p "${WEB_ROOT_TINYFILEMANAGER}"
if [ "${SCRIPT_MODE}" = "update" ]; then
sudo rm -R ${WEB_ROOT_TINYFILEMANAGER}/*
fi
# Update source and perform the full system upgrade
sudo apt-get update
sudo DEBIAN_FRONTEND=noninteractive \
apt-get \
-o "Dpkg::Options::=--force-confold" \
-o "Dpkg::Options::=--force-confdef" \
full-upgrade -y -q --allow-downgrades --allow-remove-essential --allow-change-held-packages
# Install the required packages
sudo DEBIAN_FRONTEND=noninteractive \
apt-get \
-o "Dpkg::Options::=--force-confold" \
-o "Dpkg::Options::=--force-confdef" \
install -y -q --allow-downgrades --allow-remove-essential --allow-change-held-packages \
zip php-zip php-mbstring
# Remove obsolete packages
sudo apt-get autoremove -y
# get files
sudo rm ./tinyfilemanager -R
git clone https://github.com/prasathmani/tinyfilemanager.git
# backup config-file
if [ -f "${WEB_ROOT_TINYFILEMANAGER}/config.php" ]; then
sudo cp "${WEB_ROOT_TINYFILEMANAGER}/config.php" "./tinyfilemanager/"
fi
# move files in place
sudo cp -R ./tinyfilemanager/*.php "${WEB_ROOT_TINYFILEMANAGER}"
sudo cp -R ./tinyfilemanager/*.json "${WEB_ROOT_TINYFILEMANAGER}"
sudo mv "${WEB_ROOT_TINYFILEMANAGER}/tinyfilemanager.php" "${WEB_ROOT_TINYFILEMANAGER}/index.php"
# setup
if [ -f "./tinyfilemanager/config.php" ]; then
sudo cp "./tinyfilemanager/config.php" "${WEB_ROOT_TINYFILEMANAGER}/"
else
echo "<?php" | sudo tee "${WEB_ROOT_TINYFILEMANAGER}/config.php"
echo "//Default Configuration" | sudo tee -a "${WEB_ROOT_TINYFILEMANAGER}/config.php"
echo "\$CONFIG = '{\"lang\":\"en\",\"error_reporting\":false,\"show_hidden\":false,\"hide_Cols\":true,\"theme\":\"light\"}';" | sudo tee -a "${WEB_ROOT_TINYFILEMANAGER}/config.php"
echo " \$use_auth = false;" | sudo tee -a "${WEB_ROOT_TINYFILEMANAGER}/config.php"
echo " \$root_path = \"/var/www/tinyfilemanager/media\";" | sudo tee -a "${WEB_ROOT_TINYFILEMANAGER}/config.php"
echo " \$root_url = \"files/media\";" | sudo tee -a "${WEB_ROOT_TINYFILEMANAGER}/config.php"
echo " \$max_upload_size_bytes = 1048576000;" | sudo tee -a "${WEB_ROOT_TINYFILEMANAGER}/config.php"
echo "?>" | sudo tee -a "${WEB_ROOT_TINYFILEMANAGER}/config.php"
fi
sudo ln -s "/media" "${WEB_ROOT_TINYFILEMANAGER}/media"
# change owner and make scripts executable
sudo chown www-data:www-data "${WEB_ROOT_TINYFILEMANAGER}" -R
sudo chmod +x ${WEB_ROOT_TINYFILEMANAGER}/*.php
#Finish
echo "tinyfilemanager will be available after reboot."