tinycm view tinycm @ rev 69

small CSS change
author Christophe Lincoln <pankso@slitaz.org>
date Thu Apr 24 02:26:38 2014 +0200 (2014-04-24)
parents
children 4d4e3de7b254
line source
1 #!/bin/sh
2 #
3 # TinyCM Command line tool. Dont use libtaz since TinyCM can run on any
4 # Linux/BSD distribution providing a web server with CGI SHell support
5 # such as LightTPD.
6 #
7 # Copyright (C) 2014 SliTaz GNU/Linux - BSD License
8 #
10 list="tinycm.list"
11 path="${2%/}"
12 hgurl="http://hg.slitaz.org/tinycm"
13 dlurl="$hgurl/archive/tip.tar.bz2"
15 #
16 # Functions
17 #
19 boldify() {
20 echo -e "\\033[1m$@\\033[0m"
21 }
23 error() {
24 echo -e "\\033[1;31m$@\\033[0;39m"
25 }
27 usage() {
28 cat << EOT
30 $(boldify "Usage:") $(basename $0) [command] [path|list]
32 $(boldify "Commands:")
33 inst Install TinyCM and set permissions
34 up Update one a list of TinyCM installation
36 EOT
37 }
39 check_source() {
40 if [ ! -f "Makefile" ] || [ ! -f "index.cgi" ]; then
41 error "No source found" && exit 1
42 fi
43 }
45 check_path() {
46 if [ ! "$path" ]; then
47 error "Missing path argument" && exit 1
48 fi
49 }
51 check_tiny() {
52 if [ ! -f "$path/index.cgi" ] || [ ! -d "$path/lib" ]; then
53 error "Missing TinyCM in: $path"
54 continue
55 fi
56 }
58 #
59 # Commands
60 #
62 case "$1" in
63 inst)
64 check_source
65 check_path
66 echo ""
67 boldify "Installing TinyCM..."
68 echo "Path:"; echo "$path"
69 mkdir -p $path
70 for file in index.cgi style.css images lib plugins
71 do
72 cp -a $file $path
73 done
74 if [ $(id) == 0 ]; then
75 echo root
76 else
77 echo user
78 fi
79 echo "" ;;
80 up)
81 check_source
82 if [ ! "$path" ] && [ ! -f "$list" ]; then
83 error "Missing path argument or paths list: $list"
84 exit 1
85 fi
86 echo ""
87 boldify $(echo "Updating TinyCM install's...")
89 # Priority to cmdline path argument
90 if [ "$path" ]; then
91 paths="$path"
92 else
93 paths="$(cat ${list})"
94 fi
96 for path in ${paths}
97 do
98 check_tiny
99 echo "Updating: $path"
100 cp -a index.cgi $path
101 cp -a lib/functions.js $path/lib
102 cp -a lib/jseditor.html $path/lib
103 for plug in $(ls plugins)
104 do
105 if [ -d "$path/plugins/$plug" ]; then
106 cp -a plugins/$plug $path/plugins
107 fi
108 done
109 done && echo "" ;;
110 *)
111 usage ;;
112 esac
114 exit 0