Skip to content

Commit 1f6ab17

Browse files
committed
Adding update.sh
1 parent dd760fa commit 1f6ab17

File tree

7 files changed

+56
-18
lines changed

7 files changed

+56
-18
lines changed

about.html

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<!DOCTYPE html>
32
<html lang="en">
43
<head>

faq.html

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<!DOCTYPE html>
32
<html lang="en">
43
<head>

index.html

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<!DOCTYPE html>
32
<html lang="en">
43
<head>

install.html

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<!DOCTYPE html>
32
<html lang="en">
43
<head>

screenshots.html

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<!DOCTYPE html>
32
<html lang="en">
43
<head>

tools/install.sh

+11-13
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ INSTALL_DIR='/srv/lwp'
1818

1919
if [[ -d "$INSTALL_DIR" ]];then
2020
echo "You already have LXC Web Panel installed. You'll need to remove $INSTALL_DIR if you want to install"
21-
exit
21+
exit 1
2222
fi
2323

2424
echo 'Installing requirement...'
@@ -53,13 +53,12 @@ hash git &> /dev/null || {
5353

5454
git clone https://github.com/lxc-webpanel/LXC-Web-Panel.git "$INSTALL_DIR"
5555

56-
echo -e '\nInstallation complete !\n\n'
56+
echo -e '\nInstallation complete!\n\n'
57+
5758

58-
read -p 'Would you want to add LXC Web Panel to init.d for auto start ? [Y/n] ' CONFIRM
59+
echo 'Adding /etc/init.d/lwp...'
5960

60-
if [[ "$CONFIRM" =~ ^([yY][eE][sS]|[yY]|'')$ ]]; then
61-
echo 'Adding /etc/init.d/lwp...'
62-
cat > '/etc/init.d/lwp' <<EOF
61+
cat > '/etc/init.d/lwp' <<EOF
6362
#!/bin/bash
6463
# Copyright (c) 2013 LXC Web Panel
6564
# All rights reserved.
@@ -115,16 +114,15 @@ case "\$1" in
115114
;;
116115
*)
117116
echo 'Usage: /etc/init.d/lwp {start|stop|restart}'
118-
echo 'Do not use service for this please !'
119117
exit 0
120118
;;
121119
esac
122120
123121
exit 0
124122
EOF
125-
chmod +x '/etc/init.d/lwp'
126-
update-rc.d lwp defaults &> /dev/null
127-
echo 'Done'
128-
/etc/init.d/lwp start
129-
echo 'Connect you on http://your-ip-address:5000/'
130-
fi
123+
124+
chmod +x '/etc/init.d/lwp'
125+
update-rc.d lwp defaults &> /dev/null
126+
echo 'Done'
127+
/etc/init.d/lwp start
128+
echo 'Connect you on http://your-ip-address:5000/'

tools/update.sh

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/bash
2+
echo ' _ __ _______ __ __ _ _____ _ '
3+
echo '| | \ \ / / ____| \ \ / / | | | __ \ | |'
4+
echo '| | \ V / | \ \ /\ / /__| |__ | |__) |_ _ _ __ ___| |'
5+
echo "| | > <| | \ \/ \/ / _ \ '_ \ | ___/ _\` | '_ \ / _ \ |"
6+
echo '| |____ / . \ |____ \ /\ / __/ |_) | | | | (_| | | | | __/ |'
7+
echo '|______/_/ \_\_____| \/ \/ \___|_.__/ |_| \__,_|_| |_|\___|_|'
8+
echo -e '\n\nAutomatic updater\n'
9+
10+
if [[ "$UID" -ne "0" ]];then
11+
echo 'You must be root to update LXC Web Panel !'
12+
exit
13+
fi
14+
15+
### BEGIN PROGRAM
16+
17+
INSTALL_DIR='/srv/lwp'
18+
19+
if [[ -d "$INSTALL_DIR" && $(< $INSTALL_DIR/version) == '0.1' ]]; then
20+
21+
/etc/init.d/lwp stop
22+
23+
tmp=$(mktmp)
24+
25+
echo 'Backuping database...'
26+
[[ -f "$INSTALL_DIR/lwp.db" ]] && cp "$INSTALL_DIR/lwp.db" "$tmp" || echo "Can't backup the database!"
27+
28+
echo 'Removing old version...'
29+
rm -rf "$INSTALL_DIR/*" "$INSTALL_DIR/.*"
30+
31+
echo 'Installing LXC Web Panel v0.2...'
32+
git clone https://github.com/lxc-webpanel/LXC-Web-Panel.git "$INSTALL_DIR"
33+
34+
echo 'Restore database...'
35+
cp "$tmp/lwp.db" "$INSTALL_DIR/lwp.db"
36+
rm -R "$tmp"
37+
38+
/etc/init.d/lwp start
39+
40+
echo -e '\nUpdate complete!\n\n'
41+
42+
else
43+
echo 'Unable to find previous installation...'
44+
exit 1
45+
fi

0 commit comments

Comments
 (0)