Better README and comments

This commit is contained in:
Candifloss 2024-10-28 10:53:24 +05:30
parent df0a0eabda
commit b850a6638f
5 changed files with 43 additions and 15 deletions

View File

@ -1,3 +1,22 @@
# misc-scripts # Miscellaneous scripts
Misc scripts I use/used for various tasks Various scripts I use/used for common tasks
## Shell scripts
Most of these shell scripts are made for posix shells, and tested only on `bash` and `zsh`, unless specified. Test on other shells and modify at your own risk.
Note that these two are equivalent:
```bash
bash scriptname.sh # Use your shell in place of bash
```
```bash
./scriptname.sh # Requires +x permission for execution
```
Since `bash` and `zsh` are mostly identical in synatx, almost all scripts written for either of these work for both of them, and rarely differ in functionality, like the `()` expansions.
Quick bash reference: [bash cheatsheet](https://devhints.io/bash)
Zsh reference: [zsh cheatsheet](https://devhints.io/zsh)
## Other scripts
Other scripts, like the python scripts, are not limited to specific shells, but may require minor changes if they execute shell commands.

View File

@ -1,6 +1,7 @@
# Basic LDAP operations # Basic LDAP operations
These scripts act as shortcuts for frequently used `openldap` commands or operations. These scripts act as shortcuts for frequently used `openldap` commands or operations. Specifying the `dn`, password, host address, etc. in a script eliminates the need to type them every time you have to do something.
Keep the scripts and credentials away from unauthorized personnel. Use at your own risk.
## Common openldap commands and options ## Common openldap commands and options
@ -17,7 +18,7 @@ You will have to modify these fields in the scripts:
- `-b`: Search base: `dc=example,dc=com` - `-b`: Search base: `dc=example,dc=com`
- `-f`: File: The `.ldif` file with the `ldif` data to add or modify an entry - `-f`: File: The `.ldif` file with the `ldif` data to add or modify an entry
Usage examples: Command examples:
```bash ```bash
ldapsearch -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://ldap.example.com/ -b dc=example,dc=com uid=tomsawyer ldapsearch -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://ldap.example.com/ -b dc=example,dc=com uid=tomsawyer
``` ```
@ -25,17 +26,19 @@ ldapsearch -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://ldap.exam
ldapadd -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://192.12.34.123/ -f testuser.ldif ldapadd -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://192.12.34.123/ -f testuser.ldif
``` ```
Refer the openldap man pages or documentations for more information including full lists of options and argumenst for each command, syntax for `ldif` files, ldap filters, `oid` and attributes, etc.
## Script usage ## Script usage
[ldapsearch.sh](ldapsearch.sh): Search entry by any attribute [ldapsearch.sh](ldapsearch.sh): Search entries by any attribute
```bash ```bash
bash ldapsearch.sh uid=tomsawyer bash ldapsearch.sh uid=tomsawyer # Takes any number of arguments
``` ```
[ldapadd.sh](ldapadd.sh): Add entries from ldif file [ldapadd.sh](ldapadd.sh): Add entries from ldif file
```bash ```bash
bash ldapadd.sh filename.ldif bash ldapadd.sh filename.ldif # Takes 1 filename as argument
``` ```
[ldapmodify.sh](ldapmodify.sh): Modify entries with info from ldif file [ldapmodify.sh](ldapmodify.sh): Modify entries with info from ldif file
```bash ```bash
bash ldapmodify.sh filename.ldif bash ldapmodify.sh filename.ldif # Takes 1 filename as argument
``` ```

View File

@ -1 +1,3 @@
ldapadd -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://192.12.34.123/ -f $1 ldapadd -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://192.12.34.123/ -f $1
# This script takes one argument - the /path/filenam.ldif of an ldif file.
# Refer the documentations for ldif syntax.

View File

@ -1 +1,3 @@
ldapmodify -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://192.12.34.123/ -f $1 ldapmodify -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -H ldap://192.12.34.123/ -f $1
# This script takes one argument - the /path/filenam.ldif of an ldif file.
# Refer the documentations for ldif syntax.

View File

@ -1 +1,3 @@
ldapsearch -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -b dc=example,dc=com $* ldapsearch -D cn=ldapadmin,dc=example,dc=com -w Y0ur4dm!nPwd -b dc=example,dc=com $*
# Takes any number of arguments: atrib=value or '(filter)'
# If no arguments specified, it perform `ldapsearch` without arguments and prints all the matching results