ssfs view ssfs-env @ rev 109

Remove ashism ==
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue Feb 26 12:27:01 2019 +0100 (2019-02-26)
parents 525d7e348205
children
line source
1 #!/bin/sh
2 #
3 # Ssfs vdisk chroot env utility - Help chrooted users use the environment.
4 # No i18n in this script since gettext is not installed in vdisk chroot.
5 #
6 # Copyright (C) SliTaz GNU/Linux - BSD License
7 # Author: Christophe Lincoln <pankso@slitaz.org>
8 #
10 app=$(basename $0)
12 help() {
13 cat << EOT
15 $(echo -e "\033[1mUsage:\033[0m") $app [command] [pattern]
17 $(echo -e "\033[1mCommands:\033[0m")
18 help Display this short help usage.
19 info Display account and system information.
20 list List all files in your Sync folder.
21 search Search for a file or a system command.
23 EOT
24 }
26 separator() {
27 echo "================================================================================"
28 }
30 # User and system summary.
31 info() {
32 size=$(du -sh $HOME | awk {'print $1'})
33 all=$(find $HOME | wc -l)
34 sync=$(find $HOME/Sync | wc -l)
35 cmds=$(find /bin /sbin | wc -l)
36 users=$(ls /home | wc -l)
37 cat << EOT
39 Account info
40 $(separator)
41 Home path : $HOME
42 SSH keys : .ssh/authorized_keys
43 Home usage : $size
44 All files : $all
45 Sync files : $sync
46 $(separator)
48 System info
49 $(separator)
50 Server date : $(date "+%H-%m-%d %H:%M")
51 System commands : $cmds
52 Vdisk users : $users
53 $(separator)
55 EOT
56 }
58 #
59 # Commands
60 #
62 case "$1" in
63 info)
64 info ;;
65 list)
66 echo -e "\nList of files in Sync"
67 separator
68 cd $HOME/Sync && find . | fgrep ./ | sed s'@./@@'
69 separator && echo "" ;;
70 search)
71 [ -z "$2" ] && echo "Usage: $app search file" && exit 0
72 query="$2"
73 echo -e "\n\033[1mSearching for:\033[0m $query\n"
74 echo "Matching files" && separator
75 find $HOME | grep -i $query
76 echo -e "\nMatching commands" && separator
77 find /bin | grep -i $query
78 echo "" ;;
79 *)
80 help ;;
81 esac
82 exit 0