Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run bash scripts (#!/bin/bash) #24470

Open
16 of 20 tasks
noahtalerman opened this issue Dec 6, 2024 · 1 comment
Open
16 of 20 tasks

Run bash scripts (#!/bin/bash) #24470

noahtalerman opened this issue Dec 6, 2024 · 1 comment
Assignees
Labels
customer-cisneros customer-leiden customer-olympus #g-orchestration Orchestration product group :release Ready to write code. Scheduled in a release. See "Making changes" in handbook. story A user story defining an entire feature

Comments

@noahtalerman
Copy link
Member

noahtalerman commented Dec 6, 2024

Goal

User story
As an IT admin,
I want to run scripts with #!/bin/bash on macOS/Linux
so that I don't have to rewrite my existing bash scripts to prevent them from failing.

Key result

Deliver prioritized customer request

Original requests

Context

Changes

Product

  • UI changes: Figma
  • CLI (fleetctl) usage changes: No changes
  • YAML changes: No changes
  • REST API changes: No changes
  • Fleet's agent (fleetd) changes: No changes
  • Activity changes: No changes
  • Permissions changes: No changes
  • Changes to paid features or tiers: No changes
  • Transparency changes: No changes
  • First draft of test plan added
  • Other reference documentation changes: Update scripts guide
  • Once shipped, requester has been notified
  • Once shipped, dogfooding issue has been filed

Engineering

ℹ️  Please read this issue carefully and understand it. Pay special attention to UI wireframes, especially "dev notes".

QA

Risk assessment

  • Requires load testing: No need.
  • Risk level: Low
  • Risk description: A potential bug in running the bash scripts or affecting other scripts. Low risk cause this can easily be caught by QA.

Test plan

  1. Upload a script that begins with #!/bin/bash and contains bash-specific features (e.g. uses arrays)
    • Run the script on a macOS host
    • Run the script on a Linux host
  2. Upload the same script, but without #!/bin/bash on the first line.
    • Try running again; should fail because it runs using #!/bin/sh

Testing notes

Confirmation

  1. Engineer (@____): Added comment to user story confirming successful completion of test plan.
  2. QA (@____): Added comment to user story confirming successful completion of test plan.
@noahtalerman noahtalerman added story A user story defining an entire feature :product Product Design department (shows up on 🦢 Drafting board) #g-endpoint-ops Endpoint ops product group Epic DO NOT USE. Auto-created by ZenHub, cannot be disabled. and removed Epic DO NOT USE. Auto-created by ZenHub, cannot be disabled. labels Dec 6, 2024
@noahtalerman noahtalerman removed the :product Product Design department (shows up on 🦢 Drafting board) label Dec 6, 2024
@noahtalerman noahtalerman added #g-orchestration Orchestration product group :product Product Design department (shows up on 🦢 Drafting board) and removed #g-endpoint-ops Endpoint ops product group labels Dec 20, 2024
iansltx added a commit that referenced this issue Jan 15, 2025
@xpkoala xpkoala assigned sharon-fdm and xpkoala and unassigned rachaelshaw Jan 16, 2025
@sharon-fdm sharon-fdm added :release Ready to write code. Scheduled in a release. See "Making changes" in handbook. and removed :product Product Design department (shows up on 🦢 Drafting board) labels Jan 20, 2025
@dantecatalfamo dantecatalfamo added this to the 4.64.0-tentative milestone Jan 22, 2025
@allenhouchins
Copy link
Member

Today I learned that even though you can't upload bash scripts today, you can spawn bash commands from sh scripts. Example:

#!/bin/sh
#
# A script to find the line "#WaylandEnable=False" in /etc/gdm3/custom.conf,
# uncomment it if present, and then restart the GDM service.

FILE="/etc/gdm3/custom.conf"
SEARCH_LINE="#WaylandEnable=false"
UNCOMMENTED_LINE="WaylandEnable=false"

# Check if the file contains a line starting with "#WaylandEnable=False"
if grep -xq '^#WaylandEnable=false$' /etc/gdm3/custom.conf; then
  echo "Found '$SEARCH_LINE'. Uncommenting it..."
  # Use sed to remove the leading '#' on that specific line
  sed -i 's/^#WaylandEnable=false$/WaylandEnable=false/' $FILE
  
  echo "Restarting the GDM service to apply changes..."
  systemctl daemon-reload # Make sure systemctl is aware of changes
  systemctl restart gdm3

  # Restart Fleet Desktop
  nohup bash -c "sleep 10 && systemctl restart orbit" >/dev/null 2>&1 & # <-----------

else
  echo "Either '$SEARCH_LINE' is already uncommented or the line is missing."
fi

I had to do this because sh doesn't support commands like disown and other background process capabilities.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-cisneros customer-leiden customer-olympus #g-orchestration Orchestration product group :release Ready to write code. Scheduled in a release. See "Making changes" in handbook. story A user story defining an entire feature
Development

No branches or pull requests

7 participants