Compare commits

...

3 Commits

Author SHA1 Message Date
4677b84a29
Initial docker sandbox 2022-07-04 23:25:31 +08:00
7008ec36b7
Apache fix 2022-07-04 23:24:43 +08:00
f2d41885af
Composer cleanup 2022-07-04 23:24:27 +08:00
6 changed files with 78 additions and 44 deletions

4
.dockerignore Normal file
View File

@ -0,0 +1,4 @@
.git
.gitignore
.dockerignore
README.md

27
Dockerfile Normal file
View File

@ -0,0 +1,27 @@
FROM ubuntu:22.04
RUN apt update && \
apt -y install \
apt-transport-https \
apt-utils \
bsdmainutils \
curl \
dialog \
grep \
make \
man \
sudo \
wget
RUN adduser ivan \
--quiet \
--home=/home/ivan \
--ingroup=sudo \
--disabled-password \
--disabled-login
COPY ./ /home/ivan/my-env
RUN echo "ivan ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
USER ivan
WORKDIR /home/ivan/my-env

View File

@ -1,4 +1,4 @@
# Autogenerated at 04.07.2022 22:16 using ./gen-makefile.sh
# Autogenerated at 04.07.2022 23:25 using ./gen-makefile.sh
##lamp: Apache + php + mariadb
lamp: apache php mariadb
@ -110,6 +110,6 @@ help: Makefile
@echo "Available goals:"
@sed -n 's/^##//p' $< | column -t -s ':' | sed -e "s/^/\t/"
##<goal>_: Same as 'cat ./install/<goal>.sh'
##<goal>_: Same as 'cat ./install/<goal>'
%_:
@cat ./install/$*

View File

@ -30,6 +30,9 @@ make help
./gen-makefile.sh
```
> I do not recomend to run `make` without arguments.
> Use `make help` to look around.
### Selective straightforward installation
```shell
@ -72,3 +75,18 @@ mypackY: goalA goalB
where:
* `mypack*` is the pack name
* `goal*` are script names in `./install`
## Testing in docker
```shell
# switch to repo dir
cd my-env
# build and run container
docker build -t myenv . && docker run -it myenv
# oneliner
docker run -it $(docker build -q .)
```
Now you can play around with scripts.

View File

@ -8,5 +8,5 @@ echo "==============================================="
echo
sudo apt install -y --autoremove apache2 && \
service apache2 restart && \
sudo systemctl restart apache2 && \
apache2 -v

View File

@ -11,46 +11,31 @@ installed() {
command -v "$1" >/dev/null 2>&1
}
if installed "php"; then
if installed "composer"; then
echo "WARNING: You already have composer installed - removing to install actual version"
sudo apt remove -y --autoremove composer
sudo rm -f /bin/composer
sudo rm -f /usr/bin/composer
sudo rm -f /usr/local/bin/composer
sudo rm -rf /usr/src/composer
fi
sudo mkdir -m 0777 -p /usr/src/composer
cd /usr/src/composer
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
sudo cp /usr/src/composer/composer.phar /usr/local/bin/composer
cd - >/dev/null
sudo rm -rf /usr/src/composer/
installed "composer" && composer --version
else
echo "WARNING: You need to have php installed"
!installed "php" && echo "WARNING: You need to have php installed"
if installed "composer"; then
echo "WARNING: Removing current composer to install its actual version"
sudo apt remove -y --autoremove composer
sudo rm -f /bin/composer
sudo rm -f /usr/bin/composer
sudo rm -f /usr/local/bin/composer
sudo rm -rf /usr/src/composer
fi
# title "Installing composer.phar in home dir..."
# cd ~
# EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
# php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
# ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
# if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
# then
# >&2 echo 'ERROR: Invalid installer signature'
# rm composer-setup.php
# exit 1
# fi
# php composer-setup.php --quiet
# RESULT=$?
# rm composer-setup.php
sudo mkdir -m 0777 -p /usr/src/composer
cd /usr/src/composer
# https://getcomposer.org/doc/faqs/how-to-install-composer-programmatically.md
EXPECTED_CHECKSUM="$(php -r 'copy("https://composer.github.io/installer.sig", "php://stdout");')"
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_CHECKSUM="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then
>&2 echo 'ERROR: Invalid installer checksum'
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
sudo cp /usr/src/composer/composer.phar /usr/local/bin/composer
cd - >/dev/null
sudo rm -rf /usr/src/composer/
installed "composer" && composer --version