tinycm rev 67
Add tinycm utility to help update and do new install (now that scn is powered by tinxcm)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Thu Apr 24 01:05:43 2014 +0200 (2014-04-24) |
parents | e899fcee1cd5 |
children | c9ab61b3774a |
files | tinycm |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/tinycm Thu Apr 24 01:05:43 2014 +0200 1.3 @@ -0,0 +1,114 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# TinyCM Command line tool. Dont use libtaz since TinyCM can run on any 1.7 +# Linux/BSD distribution providing a web server with CGI SHell support 1.8 +# such as LightTPD. 1.9 +# 1.10 +# Copyright (C) 2014 SliTaz GNU/Linux - BSD License 1.11 +# 1.12 + 1.13 +list="tinycm.list" 1.14 +path="${2%/}" 1.15 +hgurl="http://hg.slitaz.org/tinycm" 1.16 +dlurl="$hgurl/archive/tip.tar.bz2" 1.17 + 1.18 +# 1.19 +# Functions 1.20 +# 1.21 + 1.22 +boldify() { 1.23 + echo -e "\\033[1m$@\\033[0m" 1.24 +} 1.25 + 1.26 +error() { 1.27 + echo -e "\\033[1;31m$@\\033[0;39m" 1.28 +} 1.29 + 1.30 +usage() { 1.31 + cat << EOT 1.32 + 1.33 +$(boldify "Usage:") $(basename $0) [command] [path|list] 1.34 + 1.35 +$(boldify "Commands:") 1.36 + inst Install TinyCM and set permissions 1.37 + up Update one a list of TinyCM installation 1.38 + 1.39 +EOT 1.40 +} 1.41 + 1.42 +check_source() { 1.43 + if [ ! -f "Makefile" ] || [ ! -f "index.cgi" ]; then 1.44 + error "No source found" && exit 1 1.45 + fi 1.46 +} 1.47 + 1.48 +check_path() { 1.49 + if [ ! "$path" ]; then 1.50 + error "Missing path argument" && exit 1 1.51 + fi 1.52 +} 1.53 + 1.54 +check_tiny() { 1.55 + if [ ! -f "$path/index.cgi" ] || [ ! -d "$path/lib" ]; then 1.56 + error "Missing TinyCM in: $path" 1.57 + continue 1.58 + fi 1.59 +} 1.60 + 1.61 +# 1.62 +# Commands 1.63 +# 1.64 + 1.65 +case "$1" in 1.66 + inst) 1.67 + check_source 1.68 + check_path 1.69 + echo "" 1.70 + boldify "Installing TinyCM..." 1.71 + echo "Path:"; echo "$path" 1.72 + mkdir -p $path 1.73 + for file in index.cgi style.css images lib plugins 1.74 + do 1.75 + cp -a $file $path 1.76 + done 1.77 + if [ $(id) == 0 ]; then 1.78 + echo root 1.79 + else 1.80 + echo user 1.81 + fi 1.82 + echo "" ;; 1.83 + up) 1.84 + check_source 1.85 + if [ ! "$path" ] && [ ! -f "$list" ]; then 1.86 + error "Missing path argument or paths list: $list" 1.87 + exit 1 1.88 + fi 1.89 + echo "" 1.90 + boldify $(echo "Updating TinyCM install's...") 1.91 + 1.92 + # Priority to cmdline path argument 1.93 + if [ "$path" ]; then 1.94 + paths="$path" 1.95 + else 1.96 + paths="$(cat ${list})" 1.97 + fi 1.98 + 1.99 + for path in ${paths} 1.100 + do 1.101 + check_tiny 1.102 + echo "Updating: $path" 1.103 + cp -a index.cgi $path 1.104 + cp -a lib/functions.js $path/lib 1.105 + cp -a lib/jseditor.html $path/lib 1.106 + for plug in $(ls plugins) 1.107 + do 1.108 + if [ -d "$path/plugins/$plug" ]; then 1.109 + cp -a plugins/$plug $path/plugins 1.110 + fi 1.111 + done 1.112 + done && echo "" ;; 1.113 + *) 1.114 + usage ;; 1.115 +esac 1.116 + 1.117 +exit 0