Better README and comments
This commit is contained in:
parent
df0a0eabda
commit
b850a6638f
23
README.md
23
README.md
@ -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.
|
||||
|
@ -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
|
||||
|
||||
@ -17,25 +18,27 @@ You will have to modify these fields in the scripts:
|
||||
- `-b`: Search base: `dc=example,dc=com`
|
||||
- `-f`: File: The `.ldif` file with the `ldif` data to add or modify an entry
|
||||
|
||||
Usage examples:
|
||||
Command examples:
|
||||
```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
|
||||
```
|
||||
```bash
|
||||
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
|
||||
```
|
||||
|
||||
## Script usage
|
||||
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.
|
||||
|
||||
[ldapsearch.sh](ldapsearch.sh): Search entry by any attribute
|
||||
## Script usage
|
||||
|
||||
[ldapsearch.sh](ldapsearch.sh): Search entries by any attribute
|
||||
```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
|
||||
```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
|
||||
```bash
|
||||
bash ldapmodify.sh filename.ldif
|
||||
bash ldapmodify.sh filename.ldif # Takes 1 filename as argument
|
||||
```
|
@ -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.
|
@ -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.
|
@ -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
|
Loading…
Reference in New Issue
Block a user