Skip to content

Commit

Permalink
many fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinsiryk committed Jun 16, 2017
1 parent c4f4128 commit ac0b28f
Show file tree
Hide file tree
Showing 13 changed files with 334 additions and 99 deletions.
67 changes: 67 additions & 0 deletions AWS/create_own_ami.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
============================
Create own AMI from instance
============================

Tested on AWS Ubuntu Xenial ``create-own-ami.sh``::


#!/bin/bash

set -e

instance_id=$(ec2metadata --instance-id)
instance_name=$(aws ec2 describe-tags --filters Name=resource-id,Values=$instance_id Name=key,Values=Name --query Tags[].Value --output text)

if [ -z $instance_name ]; then
ami_name="ec2-$instance_id-auto-created"
else
ami_name="$instance_name-auto-created"
fi

ami_description="AMI auto created by script from instance $instance_id"

function delete_snapshots_of_ami() {
array=($(aws ec2 describe-images --filters "Name=image-id,Values=$1" --query Images[0].BlockDeviceMappings[].Ebs.SnapshotId --output text))

for i in "${array[@]}"
do
aws ec2 delete-snapshot --snapshot-id $i
echo 'Deleted snapshot $i'
done

}


function delete_ami() {
ami_id=$1

snapshots=($(aws ec2 describe-images --filters "Name=image-id,Values=$ami_id" --query Images[0].BlockDeviceMappings[].Ebs.SnapshotId --output text))

aws ec2 deregister-image --image-id $ami_id
echo "Deregistered AMI $ami_id"

sleep 5.0

for snap_id in "${snapshots[@]}"
do
aws ec2 delete-snapshot --snapshot-id $snap_id
echo "Deleted snapshot $snap_id"
done
}


ami_last_id=$(aws ec2 describe-images --filters "Name=name,Values=$ami_name" --query Images[0].ImageId --output text)

if [ "$ami_last_id" = "None" ]; then
echo "Not exist previous AMI. Nothing to delete."
else
echo "Start deleting previous AMI $ami_name with id $ami_last_id"
delete_ami $ami_last_id

echo "Previous AMI and associated snapshots were deleted."
fi

echo "Start creating AMI $ami_name from $instance_id"
ami_new_id=$(aws ec2 create-image --instance-id $instance_id --name "$ami_name" --description "$ami_description" --output text)

echo "Created new AMI $ami_new_id"
11 changes: 6 additions & 5 deletions JBOSS_EAP/jboss_eap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ JBOSS EAP
#
# RedHat Enterprise Linux server 7.2

::

sudo yum update
sudo yum install java-1.8.0-openjdk
sudo yum update
sudo yum install java-1.8.0-openjdk

java -jar jboss-eap-7.0.0-installer.jar -console
java -jar jboss-eap-7.0.0-installer.jar -console

# auto install
# java -jar jboss-eap-7.0.0-installer.jar auto.xml
# auto install
# java -jar jboss-eap-7.0.0-installer.jar auto.xml

sudo yum install nano

Expand Down
29 changes: 29 additions & 0 deletions MacOS/mac_os.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@
Mac OS instructions
===================

Turn on performance mode for macOS Server (OS X El Capitan 10.11 and later). Provides extended system limits (maxproc, etc.)::

# check
nvram boot-args

# turn on (reboot after turn on)
sudo nvram boot-args="serverperfmode=1 $(nvram boot-args 2>/dev/null | cut -f 2-)"


# turn off (reboot after turn off)
sudo nvram boot-args="$(nvram boot-args 2>/dev/null | sed -e $'s/boot-args\t//;s/serverperfmode=1//')"


Delete a local account::

dscl localhost delete /Local/Default/Users/<user>
rm -rf /Users/<user>


Show listen ports::

sudo lsof -PiTCP -sTCP:LISTEN


Manipulating OS X login items from command line

- https://hamstergene.github.io/post/editing-osx-login-items-cmdline/
Expand Down Expand Up @@ -224,6 +248,11 @@ Install some app::
System limits
-------------

.. note::

To increase system limits turn on performance mode


::

launchctl limit
Expand Down
10 changes: 10 additions & 0 deletions MacOS/mac_programming.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ https://en.wikibooks.org/wiki/AppleScript_Programming/System_Events

Loop (repeat) - http://alvinalexander.com/apple/applescript-for-loop-while-loop-examples

Get all UI elements::

set t1 to get every UI element
log "---\nGet every UI element\n---"
repeat with i in t1
log i
log "\n"
end repeat
log "---\nEnd\n---"


Show all processes of application::

Expand Down
2 changes: 2 additions & 0 deletions awk.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ awk - команда контекстного поиска и преобразо

cat /proc/*/stat | awk '{print $1 " " $2}'

awk -F '<separator>' '{print $2}'

http://linuxgeeks.ru/awk.htm
https://ru.wikipedia.org/wiki/AWK
https://linuxconfig.org/learning-linux-commands-awk
Expand Down
13 changes: 13 additions & 0 deletions bash.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@ BASH

http://talk.jpnc.info/bash_lfnw_2017.pdf

BASH if grep ixists statement::

if grep --quiet 'text' /path/to/file; then
echo exists
else
echo not found
fi


Get path to script which run::

SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"


Bash get last line from a variable::

Expand Down
5 changes: 5 additions & 0 deletions git.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Git

https://git-scm.com/book/ru/v2

Avoid **Are you sure you want to continue connecting (yes/no)** on connect via ssh keys::

# bitbucket
ssh-keyscan -t rsa bitbucket.org >> ~/.ssh/known_hosts


Delete credentials from GIT repository [rus] - https://the-bosha.ru/2016/07/01/udaliaem-sluchaino-zakomichennye-privatnye-dannye-iz-git-repozitoriia/

Expand Down
9 changes: 5 additions & 4 deletions install-bbb-auto.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
Install BBB auto
================

::
BigBlueButton 0.81 on Debian 7 Wheezy
-------------------------------------

#BigBlueButton 0.81 in Debian 7 Wheezy
##
::

aptitude install sudo
echo "deb http://ubuntu.bigbluebutton.org/lucid_dev_081/ bigbluebutton-lucid main" | sudo tee /etc/apt/sources.list.d/bigbluebutton.list
#
Expand Down Expand Up @@ -104,7 +105,7 @@ Install BBB auto
#
#
sudo aptitude -f install build-essential libssl-dev libcurl4-openssl-dev libreadline-dev libxslt-dev libxml2-dev libreadline5 libyaml-0-2
#----------����� � ��� �����------------
#
wget https://bigbluebutton.googlecode.com/files/ruby1.9.2_1.9.2-p290-1_amd64.deb
sudo dpkg -i ruby1.9.2_1.9.2-p290-1_amd64.deb
sudo aptitude -f install
Expand Down
17 changes: 16 additions & 1 deletion linux_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,20 @@
Linux commands
==============

Sleep for 1 second between each xargs command::

ps aux | awk '{print $1}' | xargs -I % sh -c '{ echo %; sleep 1; }'


Empty pagecache, dentries and inodes::

# run as root
free -h && sync && echo 3 > /proc/sys/vm/drop_caches && free -h

# pagecache
free -h && echo && sync && echo > /proc/sys/vm/drop_caches && free -h

# (not recomended) pagecache, dentries and inodes
free -h && echo && sync && echo 3 > /proc/sys/vm/drop_caches && free -h


Flush swap::
Expand Down Expand Up @@ -256,6 +266,11 @@ Remove the line which contains string::
sed -i.bak '/pattern to match/d' <file>


Replace whole line started by::

sed "s/start_of_line.*/new_line_content/g"


Find
----

Expand Down

0 comments on commit ac0b28f

Please sign in to comment.