A
A
Alexander Osadchy2020-03-14 02:13:18
Docker
Alexander Osadchy, 2020-03-14 02:13:18

How to overwrite a file under Windows?

Hello!

Please help me resolve the following issue:

We changed the OS at work (I had Linux - installed Windows ... need photoshop, etc.), and here's the problem:

We have a website on WP (+ git - versionpress) - when we work, we launch it in docker..everything is set up for Linux..and now you need to rewrite the site initialization file on the LAN for Windows (the terminal is different)

Here is the file itself to initialize the site on the LAN:

#!/usr/bin/env bash
set -x
set -e
docker-compose down
docker system prune -f && docker volume prune -f
docker-compose up --build -d
docker cp ~/.ssh/id_rsa wordpressweb:/var/www/.ssh/
docker cp ~/.ssh/known_hosts wordpressweb:/var/www/.ssh/
docker exec wordpressweb chown -R www-data:www-data /var/www/.ssh/
docker exec wordpressweb chown www-data:www-data /var/www/html/wp-content/
docker exec wordpressweb chown www-data:www-data /var/www/html/wp-content/plugins/
docker exec wordpressweb chown www-data:www-data /var/www/html/wp-content/themes/
docker exec wordpressweb chmod -R a+rw /var/www/html/wp-content/plugins/wp-site-slick-slider-and-image-carousel
docker exec wordpressweb chmod -R a+rw /var/www/html/wp-content/plugins/email-subscribers
docker exec wordpressweb chmod -R a+rw /var/www/html/wp-content/themes/site-tech
docker exec wordpressweb chmod -R a+rw /var/www/html/wp-content/themes/stub-site-tech
docker exec -u www-data wordpressweb git init
docker exec -u www-data wordpressweb git remote add origin [email protected]:site/site-versionpress-wordpress.git
docker exec -u www-data wordpressweb git fetch
docker exec -u www-data wordpressweb git reset --hard origin/master
docker exec -u www-data wordpressweb git clean -f -d --exclude="wp-content/plugins/wp-site-slick-slider-and-image-carousel/ wp-content/plugins/email-subscribers/ wp-content/themes/stub-site-tech/ wp-content/themes/site-tech/"
docker exec wordpressweb chmod -R a+rw /var/www/html/wp-content/plugins/wp-site-slick-slider-and-image-carousel
docker exec wordpressweb chmod -R a+rw /var/www/html/wp-content/plugins/email-subscribers
docker exec wordpressweb chmod -R a+rw /var/www/html/wp-content/themes/site-tech
docker exec wordpressweb chmod -R a+rw /var/www/html/wp-content/themes/stub-site-tech
docker exec -u www-data wordpressweb  git config --replace-all user.name "$(git config --global user.name)"
docker exec -u www-data wordpressweb  git config --replace-all user.email "$(git config --global user.email)"
docker exec wordpressweb apt-get update
docker exec wordpressweb apt-get install -y mariadb-client nano
docker exec wordpressweb mkdir /var/www/.local/
docker exec wordpressweb chown www-data:www-data /var/www/.local/
docker exec -u www-data wordpressweb wp core install --url="http://192.168.1.37:8000" --title=site --admin_user=admin --admin_password=admin [email protected]
docker exec -u www-data wordpressweb wp plugin install https://github.com/versionpress/versionpress/releases/download/4.0-beta2/versionpress-4.0-beta2.zip --activate
docker exec -u www-data wordpressweb wp vp restore-site --siteurl="http://192.168.1.37:8000" --yes
docker exec -u www-data wordpressweb wp user list
docker exec wordpressweb chmod -R a+rw /var/www/html/wp-content/plugins/wp-site-slick-slider-and-image-carousel
docker exec wordpressweb chmod -R a+rw /var/www/html/wp-content/plugins/email-subscribers
docker exec wordpressweb chmod -R a+rw /var/www/html/wp-content/themes/site-tech
docker exec wordpressweb chmod -R a+rw /var/www/html/wp-content/themes/stub-site-tech
#docker exec -u www-data wordpressweb wp user create admin [email protected] --user_pass=admin --role=administrator


In the file, requests are written for ubuntu .. does not work on Windows (

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2020-03-14
@DELUX

in general, in your code there are only two purely Linux bash commands
set -x which is essentially a debug mode - displays the commands that bash executes
set -e stop script if the command cannot be executed,
replaced with their analogues or simply thrown out - it's up to you.
The rest should work under Windows, if you install docker desktop for windows
, you will need to fix it:
- rewrite the paths in docker cp commands to windows ones
- you may need to add shared disks to docker desktop so that the folders from which you copy files to the container are available to the container (or maybe and don’t, I practically didn’t work with docker cp)
Alternative:
install git with git-bash
and run the file without changes in this shell.
or turn on the preview mode in Windows and install WSL2, enable the use of WSL in the docker settings and work through the Windows subsystem for Linux
and use the file in the same way without changes

V
Vadim Priluzkiy, 2020-03-14
@Oxyd

Maybe WSL will save you. Then perversions with rewriting will not be needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question