welcome ipfs
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
PATH=/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin
|
||||
0 0 * * * root /etc/init.d/myos ansible-pull
|
||||
@reboot root make ansible-pull > /var/log/ansible-pull.log
|
||||
0 0 * * * root make ansible-pull > /var/log/ansible-pull.log
|
||||
|
||||
@@ -16,44 +16,27 @@ NAME="$(basename "$0")"
|
||||
type make >/dev/null 2>&1 && [ -d "${MYOS}" ] && cd "${MYOS}" || exit 1
|
||||
|
||||
case "$1" in
|
||||
force-stop)
|
||||
HOOK="stop stack-node-stop"
|
||||
shift
|
||||
;;
|
||||
force-reload)
|
||||
HOOK="recreate stack-node-recreate"
|
||||
shift
|
||||
;;
|
||||
force-restart)
|
||||
HOOK="restart stack-node-restart"
|
||||
shift
|
||||
;;
|
||||
force-shutdown)
|
||||
HOOK="down stack-node-down"
|
||||
shift
|
||||
TARGET='force-recreate'
|
||||
;;
|
||||
reload)
|
||||
HOOK="recreate"
|
||||
shift
|
||||
;;
|
||||
shutdown)
|
||||
HOOK="down"
|
||||
shift
|
||||
TARGET="recreate"
|
||||
;;
|
||||
start)
|
||||
echo "Starting $NAME..."
|
||||
HOOK="up"
|
||||
shift
|
||||
TARGET="up"
|
||||
;;
|
||||
status)
|
||||
HOOK="ps"
|
||||
shift
|
||||
TARGET="ps"
|
||||
;;
|
||||
stop)
|
||||
echo "Stopping $NAME..."
|
||||
TARGET="$1"
|
||||
;;
|
||||
*)
|
||||
TARGET="$1"
|
||||
;;
|
||||
esac
|
||||
shift ||:
|
||||
|
||||
IFS=$'\n'; exec env $(cat /etc/default/myos ~/.myos 2>/dev/null) make ${HOOK:-} "${@}"
|
||||
IFS=$'\n'; exec env $(cat /etc/default/myos 2>/dev/null) make ${TARGET:-} ${TARGET_FORCE:-} $@
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# file rc.sh: Call user defined functions
|
||||
## author: Yann "aya" Autissier
|
||||
## license: GPL
|
||||
## version: 20210714
|
||||
## version: 20220630
|
||||
|
||||
case $- in
|
||||
# if this is an interactive shell
|
||||
@@ -24,7 +24,7 @@ case $- in
|
||||
fi
|
||||
done
|
||||
# load user stuff from RC_* env vars
|
||||
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}"; for line in $(printenv 2>/dev/null |awk '$0 ~ /^RC_[1-9A-Z_]*=/'); do
|
||||
IFS="$(printf '%b_' '\n')"; IFS="${IFS%_}"; for line in $(printenv 2>/dev/null |awk '$0 ~ /^RC_[0-9A-Z_]*=/' |sort); do
|
||||
func_name=$(printf '%s\n' "${line%%=*}" |awk '{print tolower(substr($0,4))}')
|
||||
eval func_args=\$"${line%%=*}"
|
||||
[ "${func_args}" = "false" ] && continue
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# file rc_functions.sh: Define shell functions
|
||||
## author: Yann "aya" Autissier
|
||||
## license: GPL
|
||||
## version: 20220620
|
||||
## version: 20220630
|
||||
|
||||
# function force: Run a command sine die
|
||||
force() {
|
||||
@@ -40,9 +40,8 @@ force8() {
|
||||
|
||||
# function load_average; Print the current load average
|
||||
load_average() {
|
||||
awk '{printf "%.1f\n" $1}' /proc/loadavg 2>/dev/null\
|
||||
|| uptime 2>/dev/null |awk '{printf "%.1f\n", $(NF-2)}'
|
||||
}
|
||||
uptime 2>/dev/null |awk '{printf "%.1f\n", $(NF-2)}'
|
||||
}
|
||||
|
||||
# function process_count: Print number of "processes"/"running processes"/"D-state"
|
||||
process_count() {
|
||||
|
||||
@@ -3,7 +3,7 @@ Description=Call myos ansible-pull
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/etc/init.d/myos ansible-pull
|
||||
ExecStart=make ansible-pull
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
# file: handlers/main.yml
|
||||
|
||||
- name: update boot config
|
||||
- name: update boot - syslinux
|
||||
environment:
|
||||
PATH: "{{ ansible_env.PATH }}:/usr/sbin:/sbin"
|
||||
with_together:
|
||||
@@ -10,3 +10,12 @@
|
||||
command: "update-extlinux"
|
||||
when: item.1.changed and item.0.dest == "/etc/update-extlinux.conf"
|
||||
|
||||
- name: update boot - grub
|
||||
environment:
|
||||
PATH: "{{ ansible_env.PATH }}:/usr/sbin:/sbin"
|
||||
with_together:
|
||||
- '{{ boot_config }}'
|
||||
- '{{ boot_config_handler_notify.results }}'
|
||||
command: "update-grub"
|
||||
when: item.1.changed and item.0.dest == "/etc/default/grub"
|
||||
|
||||
|
||||
@@ -4,10 +4,34 @@
|
||||
- name: boot - define config
|
||||
set_fact:
|
||||
boot_config:
|
||||
# set clocksource at boot
|
||||
# set docker optimizations - armbian
|
||||
- dest: /boot/armbianEnv.txt
|
||||
line: 'docker_optimizations=on'
|
||||
regex: ''
|
||||
# set clocksource - grub
|
||||
- dest: /etc/default/grub
|
||||
line: 'GRUB_CMDLINE_LINUX="\1 clocksource=tsc tsc=reliable"'
|
||||
regex: '^GRUB_CMDLINE_LINUX="((?!.*clocksource=tsc tsc=reliable).*)"$'
|
||||
# set resources limits - grub
|
||||
- dest: /etc/default/grub
|
||||
line: 'GRUB_CMDLINE_LINUX="\1 cgroup_enable=memory swapaccount=1"'
|
||||
regex: '^GRUB_CMDLINE_LINUX="((?!.*cgroup_enable=memory swapaccount=1).*)"$'
|
||||
# set clocksource - syslinux
|
||||
- dest: /etc/update-extlinux.conf
|
||||
line: 'default_kernel_opts="\1 clocksource=tsc tsc=reliable"'
|
||||
regex: '^default_kernel_opts="((?!.*clocksource=tsc tsc=reliable).*)"$'
|
||||
# set resources limits - syslinux
|
||||
- dest: /etc/update-extlinux.conf
|
||||
line: 'default_kernel_opts="\1 cgroup_enable=memory swapaccount=1"'
|
||||
regex: '^default_kernel_opts="((?!.*cgroup_enable=memory swapaccount=1).*)"$'
|
||||
# set clocksource - uboot
|
||||
- dest: /boot/cmdline.txt
|
||||
line: '\1 clocksource=tsc tsc=reliable'
|
||||
regex: '^((?!.*clocksource=tsc tsc=reliable).*)$'
|
||||
# set resources limits - uboot
|
||||
- dest: /boot/cmdline.txt
|
||||
line: '\1 cgroup_enable=memory swapaccount=1'
|
||||
regex: '^((?!.*cgroup_enable=memory swapaccount=1).*)$'
|
||||
|
||||
- name: boot - stat config file
|
||||
with_items: '{{boot_config|default([])}}'
|
||||
@@ -28,6 +52,7 @@
|
||||
regex: '{{item.0.regex}}'
|
||||
become: yes
|
||||
notify:
|
||||
- update boot config
|
||||
- update boot - syslinux
|
||||
- update boot - grub
|
||||
register: boot_config_handler_notify
|
||||
|
||||
|
||||
@@ -9,13 +9,6 @@
|
||||
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0644
|
||||
become: yes
|
||||
|
||||
- name: files - copy myos cron file
|
||||
when: hosts_update
|
||||
with_items:
|
||||
- /etc/cron.d/myos
|
||||
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0644
|
||||
become: yes
|
||||
|
||||
- name: files - copy binary files
|
||||
with_items:
|
||||
- /etc/init.d/myos
|
||||
@@ -26,8 +19,6 @@
|
||||
- name: files - copy files - systemd
|
||||
when: ansible_service_mgr|lower == "systemd"
|
||||
with_items:
|
||||
- /etc/systemd/system/ansible.service
|
||||
- /etc/systemd/system/ansible.timer
|
||||
- /etc/systemd/system/myos.service
|
||||
- /etc/systemd/system/zram.service
|
||||
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0644
|
||||
|
||||
@@ -34,6 +34,10 @@
|
||||
- import_tasks: ssh.yml
|
||||
tags:
|
||||
- ssh
|
||||
- import_tasks: update.yml
|
||||
tags:
|
||||
- update
|
||||
when: hosts_update|default(false)
|
||||
- import_tasks: user.yml
|
||||
tags:
|
||||
- user
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
---
|
||||
# file: tasks/update.yml
|
||||
|
||||
- name: update - copy files
|
||||
with_items:
|
||||
- /etc/cron.d/myos
|
||||
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0644
|
||||
become: yes
|
||||
|
||||
- name: update - copy files - systemd
|
||||
when: ansible_service_mgr|lower == "systemd"
|
||||
with_items:
|
||||
- /etc/systemd/system/ansible.service
|
||||
- /etc/systemd/system/ansible.timer
|
||||
copy: src=../files/{{item}} dest={{item}} owner=root group=root mode=0644
|
||||
become: yes
|
||||
|
||||
- name: update - create /root/.myos
|
||||
become: true
|
||||
template:
|
||||
src: myos.j2
|
||||
dest: ~/.myos
|
||||
force: no
|
||||
mode: 0400
|
||||
|
||||
- name: update - create /root/Makefile
|
||||
become: true
|
||||
template:
|
||||
src: Makefile.j2
|
||||
dest: ~/Makefile
|
||||
force: yes
|
||||
|
||||
@@ -11,13 +11,6 @@
|
||||
copy: src="{{ item }}" dest=~/.ssh/ mode=0400
|
||||
ignore_errors: true
|
||||
|
||||
- name: user - create ~/.myos
|
||||
template:
|
||||
src: myos.j2
|
||||
dest: ~/.myos
|
||||
force: no
|
||||
mode: 0400
|
||||
|
||||
- name: user - create ~/.rc.d
|
||||
file: path=~/.rc.d/ state={{hosts_user_rc_enable|default(false)|ternary('directory', 'absent')}} mode="0700"
|
||||
|
||||
@@ -97,9 +90,3 @@
|
||||
- :filetype plugin indent on
|
||||
lineinfile: dest=~/.vimrc create=yes line='{{item}}'
|
||||
|
||||
- name: user - update ~/Makefile
|
||||
template:
|
||||
src: Makefile.j2
|
||||
dest: ~/Makefile
|
||||
force: yes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user