I don't know why, but the rendering of my code mucks up the spacing and indentation, despite being correct in the original file. I'm having issues getting the following script to run (specifically the nested script at the end of the docker command near the end of the script; I think I'm not passing the `lsb_release` variable correctly as an argument to the called `create_rpc_rs.sh` script, but I don't know how to correctly do so):
#!/bin/sh
# This script regenerates the `src/rpc_proto.rs` file from `rpc.proto`.
lsb_release=$(lsb_release -si);
echo"$lsb_release"
echo"Checking if docker is installed."
if docker --version | grep -q "Docker version";then
echo"Confirmed that docker is installed."
else
echo"Docker is not installed; attempting to install now."
if [[ "$lsb_release"=*Linux* ]];then
case"$lsb_release"in*Ubuntu*)
apt-get update;
apt-get install -y docker;;
*Manjaro*) sudo pacman -S --needed docker;;
*)
echo"installation for Docker is not configured for \
your OS, please install manually and make a pull \
request to install in this script for your OS">&2;
exit 1;;
esac;
fi
fi
echo"Checking that docker is running."
if systemctl status docker | grep -q 'Active: inactive (dead)';then
echo"docker is not running; starting docker now."
systemctl start docker
else
echo"Confirmed that docker is running."
fi
docker run --rm -v "$(pwd)":/usr/code:z -w /usr/code rust \
/bin/bash -c "sh create_rpc_rs.sh $lsb_release"
mv -f rpc.rs ./src/rpc_proto.rs
This is create_rpc_rs.sh:
#!/bin/sh
echo"Installing protobuf if not already installed."
if [[ $1=*Linux* ]] ;then
case$1in*Ubuntu*)
apt-get update;
apt-get install -y protobuf-compiler;;
*Manjaro*) sudo pacman -S --needed protobuf;;
*)
echo"installation for protobuf is not configured for \
your OS, please install manually and make a pull request;"
# exit 1;;
esac;
fi
echo"installing protobuf";
cargo install --version 1 protobuf;
echo"Producing rpc.rs via protoc and rpc.proto"
protoc --rust_out . rpc.proto
This is the output when running `./regen_proto_structs.sh`, as you can see, `lsb_release` is not found, and I don't know how to correctly pass it Ii.e. the output of lsb_release -si on the computer that docker is runnning on, to the docker container.:
$ ./regen_structs_proto1.sh
Checking if docker is installed.
Confirmed that docker is installed.
Checking that docker is running.
Confirmed that docker is running.
Installing protobuf if not already installed.
create_rpc_rs.sh: 4: create_rpc_rs.sh: [[: not found
installing protobuf
Updating registry `https://github.com/rust-lang/crates.io-index`
Unfortunately I posted this at a bad time as I need to stop working for the day.