|
863 | 863 | subh "all $1" |
864 | 864 | echo "$2" |
865 | 865 |
|
866 | | - subh "filtered $1" |
867 | | - echo "$2" | grep -v "$3" |
| 866 | + if [[ -n "$3" ]]; then |
| 867 | + echo |
| 868 | + subh "filtered $1" |
| 869 | + echo "$2" | grep -v "$3" |
| 870 | + fi |
868 | 871 |
|
869 | | - echo |
870 | 872 | get_key |
871 | 873 | } |
872 | 874 |
|
|
877 | 879 |
|
878 | 880 | stty -echo -icanon min 1 time 0 |
879 | 881 | trap $(stty sane) EXIT |
880 | | -#hostname="$(hostname)" |
| 882 | +if [[ -z $1 ]]; then |
| 883 | + hostname="$(hostname)" |
| 884 | +else |
| 885 | + hostname="$1" |
| 886 | +fi |
881 | 887 | services="${hostname}Services" |
882 | 888 | pkgs="${hostname}Pkgs" |
| 889 | +if [[ "$hostname" == 'bigbang' || "$hostname" == 'chernobyl' ]]; then |
| 890 | + os='redhat' |
| 891 | +elif [[ "$hostname" == 'dinoasteroid' || "$hostname" == 'enlightenment' || "$hostname" == 'vikingraids' ]]; then |
| 892 | + os='debian' |
| 893 | +else |
| 894 | + os='INVALID' |
| 895 | +fi |
883 | 896 | finished=false |
884 | 897 |
|
885 | 898 | while [[ $finished == false ]]; do |
886 | | - select_option 'services' 'users' 'packages' 'clone' 'exit' |
| 899 | + select_option 'services' 'users' 'packages' 'integrity' 'clone' 'test' 'exit' |
887 | 900 | clear |
888 | 901 | case "$selection" in |
889 | 902 | 'services') |
890 | | - if [[ "$hostname" == 'bigbang' || "$hostname" == 'chernobyl' || "$hostname" == 'dinoasteroid' || "$hostname" == 'enlightenment' || "$hostname" == 'vikingraids' ]]; then |
891 | | - display 'services' "$(systemctl list-units --type=service --state=running --no-pager --quiet | cut -d " " -f 3)" "${!services}" |
892 | | - else |
893 | | - error |
894 | | - fi |
| 903 | + display 'services' "$(systemctl list-units --type=service --state=running --no-pager --quiet | cut -d " " -f 3)" "${!services}" |
895 | 904 | ;; |
896 | 905 | 'users') |
897 | | - display 'users' "$(sudo passwd -S -a | awk '$2!="L" {print $1}')" "$users" |
| 906 | + display 'users' "$(sudo cat /etc/shadow | grep -v '!' | cut -d ':' -f 1)" "$users" |
898 | 907 | ;; |
899 | 908 | 'packages') |
900 | | - if [[ "$hostname" == 'bigbang' || "$hostname" == 'chernobyl' ]]; then |
| 909 | + if [[ "$os" == 'redhat' ]]; then |
901 | 910 | display 'packages' "$(dnf repoquery --userinstalled | cut -d ':' -f 1 | sed 's/..$//')" "${!pkgs}" |
902 | | - elif [[ "$hostname" == 'dinoasteroid' || "$hostname" == 'enlightenment' || "$hostname" == 'vikingraids' ]]; then |
| 911 | + elif [[ "$os" == 'debian' ]]; then |
903 | 912 | display 'packages' "$(apt-mark showmanual)" "${!pkgs}" |
904 | 913 | else |
905 | 914 | error |
906 | 915 | fi |
907 | 916 | ;; |
| 917 | + 'integrity') |
| 918 | + if [[ "$os" == 'redhat' ]]; then |
| 919 | + rpm -Va |
| 920 | + elif [[ "$os" == 'debian' ]]; then |
| 921 | + debsums |
| 922 | + |
| 923 | + if [[ "$?" != 0 ]]; then |
| 924 | + echo 'debsums not found! Please install it before continuing' |
| 925 | + fi |
| 926 | + fi |
| 927 | + get_key |
| 928 | + ;; |
908 | 929 | 'clone') |
909 | 930 | header 'cloning..' |
910 | 931 | git clone https://github.com/pix-code/pix-code.github.io |
911 | | - echo -e '\ndone!\n' |
| 932 | + echo -e '\ndone!' |
912 | 933 | get_key |
913 | 934 | ;; |
| 935 | + 'test') |
| 936 | + header 'diagnostic info' |
| 937 | + echo "detected os: $os" |
| 938 | + echo "detected hostname: $hostname" |
| 939 | + echo |
| 940 | + echo 'press m for more' |
| 941 | + if [[ "$(get_key)" == 'm' ]]; then |
| 942 | + subh 'user filter' |
| 943 | + echo "$users" |
| 944 | + echo |
| 945 | + subh 'service filter' |
| 946 | + echo "${!services}" |
| 947 | + echo |
| 948 | + subh 'pkg filter' |
| 949 | + echo "${!pkgs}" |
| 950 | + get_key |
| 951 | + fi |
| 952 | + ;; |
914 | 953 | 'exit') |
915 | 954 | header 'HACK THE PLANET' |
916 | 955 | finished=true |
|
0 commit comments