One Paragraph of project description goes here
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.
#!/bin/bash | |
#--------------------------------------------------------- | |
# Usage: sudo ./collect_data.sh <network-interface-name> | |
#--------------------------------------------------------- | |
# Define some variables | |
LOGFILE=/tmp/tcp_conf.log | |
DateStr=$(date +"%Y-%m-%d %H:%M:%S") |
# ssh key generator data source expects the below 3 inputs, and produces 3 outputs for use: | |
# "${data.external.ssh_key_generator.result.public_key}" (contents) | |
# "${data.external.ssh_key_generator.result.private_key}" (contents) | |
# "${data.external.ssh_key_generator.result.private_key_file}" (path) | |
data "external" "ssh_key_generator" { | |
program = ["bash", "${path.root}/../ssh_key_generator.sh"] | |
query = { | |
customer_name = "${var.customer_name}" | |
customer_group = "${var.customer_group}" |
while [ ! -f /tmp/wait-script.sh ] | |
do | |
sleep .2 | |
done | |
chmod 755 /tmp/wait-script.sh; /tmp/wait-script.sh |
pg_dump is a nifty utility designed to output a series of SQL statements that describes the schema and data of your database. You can control what goes into your backup by using additional flags.
Backup: pg_dump -h localhost -p 5432 -U postgres -d mydb > backup.sql
Restore: psql -h localhost -p 5432 -U postgres -d mydb < backup.sql
-h is for host.
-p is for port.
-U is for username.
-d is for database.
#read a file from the command line without using the cat command | |
```sh | |
$ while IFS= read -r line; do echo $line; done < file.txt | |
``` | |
#bash script and read any file line by line | |
```sh | |
#!/bin/bash | |
n=1 | |
while IFS= read -r line; do |
Create the file /root/rbash.sh (this can be any name or path, but should be chown root:root and chmod 700):
#!/bin/bash
commands=("man" "pwd" "ls" "whoami")
timestamp(){ date +'%Y-%m-%s %H:%M:%S'; }
log(){ echo -e "$(timestamp)\t$1\t$(whoami)\t$2" > /var/log/rbash.log; }
trycmd()
{
echo $- # shows the attributes enabled on the shell
[[ $- == *i* ]] && echo 'Interactive' || echo 'not-interactive' # detect if you are in an interactive or non-interactive shell with
echo $0 # display if the login_shell or not login_shell is used
shopt login_shell # the same meaning as above command
echo $SHELL # display which shell is used