diff --git a/Makefile b/Makefile index b8b9093..c6a43ef 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -# Autogenerated at 25.08.2022 22:32 using ./gen-makefile +# Autogenerated at 26.08.2022 08:21 using ./gen-makefile .DEFAULT_GOAL := help #=============================================== @@ -159,6 +159,29 @@ zint: zsh: @./install/zsh +#=============================================== +# Scripts listed in ./upgrade +#=============================================== + +# Upgrade omz +^omz: + @./upgrade/omz + +#=============================================== +# Scripts listed in ./uninstall +#=============================================== + +# Uninstall docker +/docker: + @./uninstall/docker + +# Uninstall omz +/omz: + @./uninstall/omz + +#=============================================== +# Service goals +#=============================================== self: @./gen-makefile @@ -166,20 +189,9 @@ self: help: Makefile @echo "Ubuntu software installator" @echo - @echo "Usage:" - @echo "\tmake help\t - Show this help" - @echo "\tmake self\t - Regenerate Makefile (alias of ./gen-makefile)" - @echo "\tmake GOAL\t - Install software" - @echo "\tmake ^GOAL\t - Upgrade software" - @echo "\tmake @GOAL\t - Uninstall software" - @echo - @echo "You can combine GOALs, e.g. 'make @docker docker' will reinstall docker." - @echo - @echo "Available GOALs:" + @echo "Usage:\n make help|- show this help\n make self|- regenerate Makefile (alias of ./gen-makefile)\n make GOAL|- install software\n make ^GOAL|- upgrade software\n make /GOAL|- uninstall software" | column -ts '|' + @echo "\nYou can combine GOALs, here are some examples:" + @echo "\tmake @docker docker" + @echo "\tmake php @docker ^omz" + @echo "\nAvailable GOALs:" @sed -n '/^#/{N;s/# *\(.*\)\n\([^# .].*:\)/\t\2\1/p}' $< | column -ts ':' -+%: - @$(MAKE) $* -^%: - @./upgrade/$* -@%: - @./uninstall/$* diff --git a/README.md b/README.md index 6277786..01fa750 100644 --- a/README.md +++ b/README.md @@ -43,16 +43,20 @@ wget -qO - https://git.axenov.dev/anthony/my-env/raw/branch/master/install/apt | ./install/apt ``` -## How to add a new software script? +## How to add my script? -1. Create new `./install/*` script. +1. Create a new shell script in `./install`, `./upgrade` or `./uninstall` directory. At the beggining of a file you must write these two lines: ```shell #!/bin/bash ##makedesc: Your description for Makefile ``` -2. Test your script -3. Run `./gen-makefile` to generate new `./Makefile` +2. Make this script executable, e.g.: + ```shell + sudo chmod a+x ./install/myscript + ``` +3. Test your script +4. Run `make self` to generate new `./Makefile` ## How to create packs? diff --git a/gen-makefile b/gen-makefile index 24aa98c..163f333 100755 --- a/gen-makefile +++ b/gen-makefile @@ -1,5 +1,7 @@ #!/bin/bash mv Makefile Makefile.bak +CHR_UPGRADE='^' +CHR_UNINSTALL='/' cat << EOF >> Makefile # Autogenerated at $(date +'%d.%m.%Y %H:%M') using ${BASH_SOURCE[0]} @@ -31,7 +33,40 @@ for file in ./install/*; do echo -e "# ${desc}\n${name}:\n\t@${file}\n" >> Makefile done; -cat << "EOF" >> Makefile +cat << EOF >> Makefile +#=============================================== +# Scripts listed in ./upgrade +#=============================================== + +EOF + +for file in ./upgrade/*; do + name=${file##*/} + name=${name%.sh} + desc=$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${file}) + [ -z "$desc" ] && desc='' + echo -e "# ${desc}\n${CHR_UPGRADE}${name}:\n\t@${file}\n" >> Makefile +done; + +cat << EOF >> Makefile +#=============================================== +# Scripts listed in ./uninstall +#=============================================== + +EOF + +for file in ./uninstall/*; do + name=${file##*/} + name=${name%.sh} + desc=$(grep -m 1 -oP "(?<=^##makedesc:\s).*$" ${file}) + [ -z "$desc" ] && desc='' + echo -e "# ${desc}\n${CHR_UNINSTALL}${name}:\n\t@${file}\n" >> Makefile +done; + +cat << EOF >> Makefile +#=============================================== +# Service goals +#=============================================== self: @./gen-makefile @@ -39,26 +74,19 @@ self: help: Makefile @echo "Ubuntu software installator" @echo - @echo "Usage:" - @echo "\tmake help\t - Show this help" - @echo "\tmake self\t - Regenerate Makefile (alias of ./gen-makefile)" - @echo "\tmake GOAL\t - Install software" - @echo "\tmake ^GOAL\t - Upgrade software" - @echo "\tmake @GOAL\t - Uninstall software" - @echo - @echo "You can combine GOALs, e.g. 'make @docker docker' will reinstall docker." - @echo - @echo "Available GOALs:" + @echo "Usage:\n \ + make help|- show this help\n \ + make self|- regenerate Makefile (alias of ./gen-makefile)\n \ + make GOAL|- install software\n \ + make ${CHR_UPGRADE}GOAL|- upgrade software\n \ + make ${CHR_UNINSTALL}GOAL|- uninstall software" | column -ts '|' + @echo "\nYou can combine GOALs, here are some examples:" + @echo "\tmake @docker docker" + @echo "\tmake php @docker ^omz" + @echo "\nAvailable GOALs:" @sed -n '/^#/{N;s/# *\(.*\)\n\([^# .].*:\)/\t\2\1/p}' $< | column -ts ':' -+%: - @$(MAKE) $* -^%: - @./upgrade/$* -@%: - @./uninstall/$* EOF echo "New ./Makefile has been generated!" echo "Old one has been saved as ./Makefile.bak" -echo -make +echo "Now run 'make' to get help" diff --git a/uninstall/omz b/uninstall/omz index b0205a5..c6e9c11 100755 --- a/uninstall/omz +++ b/uninstall/omz @@ -1,5 +1,5 @@ #!/bin/bash -##makedesc: Uninstalling omz +##makedesc: Uninstall omz echo echo "===============================================" diff --git a/upgrade/omz b/upgrade/omz index e92e312..beb339a 100755 --- a/upgrade/omz +++ b/upgrade/omz @@ -1,5 +1,5 @@ #!/bin/bash -##makedesc: Upgrading omz +##makedesc: Upgrade omz echo echo "==============================================="