forked from lynxthecat/cake-autorate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cake-autorate-setup.sh
64 lines (51 loc) · 2.15 KB
/
cake-autorate-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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#! /bin/sh
# Basic installation script for cake-autorate.sh
# See https://github.com/lynxthecat/sqm-autorate for details
# https://www.shellcheck.net/ is your friend
SRC_DIR="https://raw.githubusercontent.com/lynxthecat/CAKE-autorate/main/"
# SRC_DIR="https://raw.githubusercontent.com/richb-hanover/cake-autorate/setup-script/"
DOC_URL="https://github.com/lynxthecat/CAKE-autorate#installation-on-openwrt"
# Retrieve required packages
opkg update
opkg install bash iputils-ping
# Set up CAKE-autorate files
# cd to the /root directory
cd /root/ || exit
# create the cake-autorate directory if it's not present
[[ -d cake-autorate ]] || mkdir cake-autorate
printf "Installing cake-autorate in /root/cake-autorate...\n"
# cd into it
cd cake-autorate/ || exit
# rm the main script and fetch a fresh copy
[[ -f cake-autorate.sh ]] && rm cake-autorate.sh
wget -q "$SRC_DIR"cake-autorate.sh
# Check if the configuration script exists, and ask whether to keep it
editmsg=$(printf "\nNow edit the cake-autorate-config.sh file as described in:\n $DOC_URL")
if [ -f cake-autorate-config.sh ]; then
printf "Previous configuration present - keep it? [Y/n] "
read keepIt
if [ "$keepIt" == "N" ] || [ "$keepIt" == "n" ]; then
rm ./cake-autorate-config.sh
wget -q "$SRC_DIR"cake-autorate-config.sh
else
editmsg="Using prior configuration"
fi
else
wget -q "$SRC_DIR"cake-autorate-config.sh
fi
# make both .sh files executable
chmod +x *.sh
# Tell how to handle the config file - use old, or edit the new one
printf "$editmsg \n"
# Also copy over the service file but DO NOT ACTIVATE IT
# cd into the directory and remove the previous file
cd /etc/init.d || exit
[[ -f cake-autorate ]] && rm cake-autorate
wget -q "$SRC_DIR"cake-autorate
chmod +x cake-autorate
printf "\n`grep cake_autorate_version /root/cake-autorate/cake-autorate-config.sh` successfully installed, but not yet running\n\n"
printf "Start the software manually with:\n"
printf " cd /root/cake-autorate; bash ./cake-autorate.sh\n"
printf "Run as a service with:\n"
printf " service cake-autorate enable; service cake-autorate start\n\n"
printf "And don't forget to disable output logging if running as a service!\n"