mirror of
https://github.com/harness/drone.git
synced 2025-05-20 19:09:59 +08:00
feat: [CDE-175]: Changing all shell commands from bash to sh. (#2244)
* feat: [CDE-175]: Changing all shell commands from bash to sh.
This commit is contained in:
parent
ba934bb4e2
commit
bb7433ef9a
@ -30,7 +30,7 @@ type Devcontainer struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (d *Devcontainer) ExecuteCommand(ctx context.Context, command string, detach bool) ([]byte, error) {
|
func (d *Devcontainer) ExecuteCommand(ctx context.Context, command string, detach bool) ([]byte, error) {
|
||||||
cmd := []string{"/bin/bash", "-c", command}
|
cmd := []string{"/bin/sh", "-c", command}
|
||||||
|
|
||||||
execConfig := dockerTypes.ExecConfig{
|
execConfig := dockerTypes.ExecConfig{
|
||||||
User: "root",
|
User: "root",
|
||||||
|
@ -553,8 +553,8 @@ func (e *EmbeddedDockerOrchestrator) createContainer(
|
|||||||
|
|
||||||
_, err := dockerClient.ContainerCreate(ctx, &container.Config{
|
_, err := dockerClient.ContainerCreate(ctx, &container.Config{
|
||||||
Image: imageName,
|
Image: imageName,
|
||||||
Entrypoint: []string{"/bin/bash"},
|
Entrypoint: []string{"/bin/sh"},
|
||||||
Cmd: []string{"-c", "trap \"exit 0\" 15;\n sleep infinity & wait $!"},
|
Cmd: []string{"-c", "trap 'exit 0' 15; sleep infinity & wait $!"},
|
||||||
ExposedPorts: exposedPorts,
|
ExposedPorts: exposedPorts,
|
||||||
}, &container.HostConfig{
|
}, &container.HostConfig{
|
||||||
PortBindings: portBindings,
|
PortBindings: portBindings,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
repo_url={{ .RepoURL }}
|
repo_url={{ .RepoURL }}
|
||||||
devcontainer_present={{ .DevcontainerPresent }}
|
devcontainer_present={{ .DevcontainerPresent }}
|
||||||
@ -9,13 +9,13 @@ branch={{ .Branch }}
|
|||||||
repo_name=$(basename -s .git "$repo_url")
|
repo_name=$(basename -s .git "$repo_url")
|
||||||
|
|
||||||
# Check if Git is installed
|
# Check if Git is installed
|
||||||
if ! command -v git &>/dev/null; then
|
if ! command -v git >/dev/null 2>&1; then
|
||||||
echo "Git is not installed. Installing Git..."
|
echo "Git is not installed. Installing Git..."
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y git
|
apt-get install -y git
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v git &>/dev/null; then
|
if ! command -v git >/dev/null 2>&1; then
|
||||||
echo "Git is not installed. Exiting..."
|
echo "Git is not installed. Exiting..."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
echo "Installing VSCode Web"
|
echo "Installing VSCode Web"
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
echo "Running SSH Server"
|
echo "Running SSH Server"
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
echo "Running VSCode Web"
|
echo "Running VSCode Web"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# Install SSH if it's not already installed
|
# Install SSH if it's not already installed
|
||||||
if ! command -v sshd &> /dev/null; then
|
if ! command -v sshd >/dev/null 2>&1; then
|
||||||
echo "OpenSSH server is not installed. Installing..."
|
echo "OpenSSH server is not installed. Installing..."
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get install -y openssh-server
|
apt-get install -y openssh-server
|
||||||
@ -14,7 +14,7 @@ password={{ .Password }}
|
|||||||
workingDir={{ .WorkingDirectory }}
|
workingDir={{ .WorkingDirectory }}
|
||||||
|
|
||||||
# Check if the user already exists
|
# Check if the user already exists
|
||||||
if id "$username" &> /dev/null; then
|
if id "$username" >/dev/null 2>&1; then
|
||||||
echo "User $username already exists."
|
echo "User $username already exists."
|
||||||
else
|
else
|
||||||
# Create a new user
|
# Create a new user
|
||||||
|
Loading…
Reference in New Issue
Block a user