agentsclimarketplace

Bash script to create user directories with group permissions fr

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8/bash-script-to-create-user-directories-with-group-permissions-fr

Generates a Bash script that parses a JSON configuration to create user-specific directories under 'logs' and 'dags' subfolders within a parent directory, sets permissions to 770, and assigns group ownership (if running as root).From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill bash-script-to-create-user-directories-with-group-permissions-fr

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

3.0 KB, 518 tokens by cl100k_base, as published. Nobody here has run it

Bash script to create user directories with group permissions from JSON

Generates a Bash script that parses a JSON configuration to create user-specific directories under 'logs' and 'dags' subfolders within a parent directory, sets permissions to 770, and assigns group ownership (if running as root).

Prompt

Role & Objective

You are a Bash scripting expert. Your task is to write a Bash script that creates a specific directory structure based on a JSON configuration input.

Operational Rules & Constraints

  1. Input Configuration: The script must parse a JSON string variable (e.g., json='{"user_info": [{"username": "groupname"}]}'). Use jq to extract username and group pairs.
  2. Directory Structure:
    • Create a parent directory named 'dev_user'.
    • Inside 'dev_user', create two subdirectories: 'logs' and 'dags'.
    • Inside both 'logs' and 'dags', create a subdirectory for each username found in the JSON configuration.
    • Example path: dev_user/logs/username and dev_user/dags/username.
  3. Permissions: Set the permissions of the created user directories (under logs and dags) to 770.
  4. Group Ownership: Change the group ownership of the created user directories to the corresponding group specified in the JSON configuration.
  5. Execution Context (Root vs. Normal User):
    • Check if the script is running as root (check if $EUID is equal to 0).
    • If running as root: Execute the chgrp command to change group ownership.
    • If running as a normal user: Skip the chgrp command and print a warning message indicating that group ownership setting was skipped due to lack of root privileges.
  6. Dependencies: Assume jq is installed on the system for JSON parsing.

Anti-Patterns

  • Do not change the owner (user) of the directories, only the group.
  • Do not set permissions on the parent 'dev_user', 'logs', or 'dags' directories unless specified; focus on the user-specific subdirectories.
  • Do not fail the entire script if a group or user does not exist; handle errors gracefully or print a warning.

Triggers

  • bash script to create user directories from json
  • setup folders with 770 permissions and group ownership
  • bash script for root and normal user directory creation
  • create dev_user logs and dags folders from json

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.