##// END OF EJS Templates
rccontrol: added reconfigure commands to alter .ini files
super-admin -
Show More
@@ -62,9 +62,9 b' services:'
62 command:
62 command:
63 - "--config.file=/etc/prometheus/prometheus.yml"
63 - "--config.file=/etc/prometheus/prometheus.yml"
64 - "--storage.tsdb.path=/prometheus"
64 - "--storage.tsdb.path=/prometheus"
65 - "--storage.tsdb.retention.time=24h"
65 - "--web.console.libraries=/etc/prometheus/console_libraries"
66 - "--web.console.libraries=/etc/prometheus/console_libraries"
66 - "--web.console.templates=/etc/prometheus/consoles"
67 - "--web.console.templates=/etc/prometheus/consoles"
67 - "--storage.tsdb.retention.time=24h"
68 - "--web.enable-lifecycle"
68 - "--web.enable-lifecycle"
69 # ports:
69 # ports:
70 # - "9090:9090"
70 # - "9090:9090"
@@ -137,5 +137,4 b' services:'
137 - rhodecode_network
137 - rhodecode_network
138 volumes:
138 volumes:
139 - /var/log:/var/log
139 - /var/log:/var/log
140 - logvolume:/var/log_volume
141 - ./config/promtail:/etc/promtail
140 - ./config/promtail:/etc/promtail
@@ -2,7 +2,7 b''
2 while true
2 while true
3 do
3 do
4 echo $(date)
4 echo $(date)
5 ./rccontrol stack-upgrade rhodecode --restart-unhealthy && \
5 NO_COLOR=1 ./rccontrol stack-upgrade rhodecode --restart-unhealthy && \
6 echo "Next execution in 300s..." && \
6 echo "Next execution in 300s..." && \
7 sleep 300
7 sleep 300
8 done No newline at end of file
8 done
@@ -87,6 +87,30 b' rccontrol_usage() {'
87 echo
87 echo
88
88
89 # :environment_variable.usage
89 # :environment_variable.usage
90 echo " RC_STACK_ROUTER_VER"
91 printf "\n"
92 printf " Default: v1\n"
93 echo
94
95 # :environment_variable.usage
96 echo " RC_STACK_SERVICES_VER"
97 printf "\n"
98 printf " Default: v1\n"
99 echo
100
101 # :environment_variable.usage
102 echo " RC_STACK_RHODECODE_VER"
103 printf "\n"
104 printf " Default: v1\n"
105 echo
106
107 # :environment_variable.usage
108 echo " RC_STACK_METRICS_VER"
109 printf "\n"
110 printf " Default: v1\n"
111 echo
112
113 # :environment_variable.usage
90 echo " RCC_CONFIG"
114 echo " RCC_CONFIG"
91 printf " default config file for rccontrol\n"
115 printf " default config file for rccontrol\n"
92 printf " Default: .rccontrol.ini\n"
116 printf " Default: .rccontrol.ini\n"
@@ -895,11 +919,13 b' rccontrol_cli_usage() {'
895 echo
919 echo
896 # :command.usage_commands
920 # :command.usage_commands
897 printf "Commands:\n"
921 printf "Commands:\n"
898 echo " redis CLI for Redis"
922 echo " redis CLI for Redis"
899 echo " db CLI with Database connection"
923 echo " db CLI with Database connection"
900 echo " db-upgrade CLI to run db upgrade"
924 echo " db-upgrade CLI to run db upgrade"
901 echo " storage CLI for repository storage. Exposes a basic image with mounted data and repositories volumes"
925 echo " storage CLI for repository storage. Exposes a basic image with mounted data and repositories volumes"
902 echo " attach attach to running instance of RhodeCode main web app"
926 echo " attach attach to running instance of RhodeCode main web app"
927 echo " configure-vcs reconfigure the vcsserver.ini"
928 echo " configure-rhodecode reconfigure the rhodecode.ini"
903 echo
929 echo
904
930
905 # :command.long_usage
931 # :command.long_usage
@@ -1060,6 +1086,76 b' rccontrol_cli_attach_usage() {'
1060 }
1086 }
1061
1087
1062 # :command.usage
1088 # :command.usage
1089 rccontrol_cli_configure_vcs_usage() {
1090 if [[ -n $long_usage ]]; then
1091 printf "rccontrol cli configure-vcs - reconfigure the vcsserver.ini\n"
1092 echo
1093
1094 else
1095 printf "rccontrol cli configure-vcs - reconfigure the vcsserver.ini\n"
1096 echo
1097
1098 fi
1099
1100 printf "Usage:\n"
1101 printf " rccontrol cli configure-vcs [OPTIONS]\n"
1102 printf " rccontrol cli configure-vcs --help | -h\n"
1103 echo
1104
1105 # :command.long_usage
1106 if [[ -n $long_usage ]]; then
1107 printf "Options:\n"
1108
1109 # :command.usage_fixed_flags
1110 echo " --help, -h"
1111 printf " Show this help\n"
1112 echo
1113
1114 # :command.usage_flags
1115 # :flag.usage
1116 echo " --ini-path INI_PATH"
1117 printf " Path to vcsserver.ini\n"
1118 echo
1119
1120 fi
1121 }
1122
1123 # :command.usage
1124 rccontrol_cli_configure_rhodecode_usage() {
1125 if [[ -n $long_usage ]]; then
1126 printf "rccontrol cli configure-rhodecode - reconfigure the rhodecode.ini\n"
1127 echo
1128
1129 else
1130 printf "rccontrol cli configure-rhodecode - reconfigure the rhodecode.ini\n"
1131 echo
1132
1133 fi
1134
1135 printf "Usage:\n"
1136 printf " rccontrol cli configure-rhodecode [OPTIONS]\n"
1137 printf " rccontrol cli configure-rhodecode --help | -h\n"
1138 echo
1139
1140 # :command.long_usage
1141 if [[ -n $long_usage ]]; then
1142 printf "Options:\n"
1143
1144 # :command.usage_fixed_flags
1145 echo " --help, -h"
1146 printf " Show this help\n"
1147 echo
1148
1149 # :command.usage_flags
1150 # :flag.usage
1151 echo " --ini-path INI_PATH"
1152 printf " Path to rhodecode.ini\n"
1153 echo
1154
1155 fi
1156 }
1157
1158 # :command.usage
1063 rccontrol_backup_db_usage() {
1159 rccontrol_backup_db_usage() {
1064 if [[ -n $long_usage ]]; then
1160 if [[ -n $long_usage ]]; then
1065 printf "rccontrol backup-db - Backup Database\n"
1161 printf "rccontrol backup-db - Backup Database\n"
@@ -1476,6 +1572,84 b' get_docker_definitions() {'
1476
1572
1477 }
1573 }
1478
1574
1575 # src/lib/reconfigure_ini.sh
1576 config_vcsserver_ini() {
1577 # workers adjustment
1578 sed_replace '^#?workers = .*' 'workers = 1'
1579 sed_replace '^#?memory_max_usage = .*' 'memory_max_usage = 2147483648'
1580 sed_replace '^#?core\.binary_dir = .*' 'core.binary_dir = \/home\/rhodecode\/\.rccontrol\/vcsserver-1\/profile\/bin'
1581
1582 sed_replace '^#?rc_cache\.repo_object\.expiration_time = .*' 'rc_cache.repo_object.expiration_time = 2592000'
1583 sed_replace '^#?rc_cache\.repo_object\.backend = dogpile\.cache\.rc\.redis_msgpack' 'rc_cache.repo_object.backend = dogpile.cache.rc.redis_msgpack'
1584
1585 sed_replace '^#?rc_cache\.repo_object\.arguments\.socket_timeout = .*' 'rc_cache.repo_object.arguments.socket_timeout = 30'
1586 sed_replace '^#?rc_cache\.repo_object\.arguments\.db = .*' 'rc_cache.repo_object.arguments.db = 5'
1587 sed_replace '^#?rc_cache\.repo_object\.arguments\.port = .*' 'rc_cache.repo_object.arguments.port = 6379'
1588 sed_replace '^#?rc_cache\.repo_object\.arguments\.host = .*' 'rc_cache.repo_object.arguments.host = redis'
1589 sed_replace '^#?rc_cache\.repo_object\.arguments\.redis_expiration_time = .*' 'rc_cache.repo_object.arguments.redis_expiration_time = 3592000'
1590
1591 sed_replace '^#?cache_dir = .*' 'cache_dir = \/var\/opt\/rhodecode_data'
1592 sed_replace '^#?formatter = .*' 'formatter = json'
1593 }
1594
1595 config_rhodecode_ini(){
1596 # workers adjustment
1597 sed_replace '^#?workers = .*' 'workers = 1'
1598 sed_replace '^#?memory_max_usage = .*' 'memory_max_usage = 2147483648'
1599
1600 # email
1601 sed_replace '^#?email_prefix = .*' 'email_prefix = [RhodeCode]'
1602 sed_replace '^#?app_email_from = .*' "app_email_from = rhodecode-noreply@$RC_HOSTNAME"
1603 sed_replace '^#?smtp_server = .*' 'smtp_server = localhost'
1604
1605 # set license_token
1606 sed_replace '^#?license_token =.*' "license_token = $RC_LICENSE_TOKEN"
1607
1608 # enable celery
1609 sed_replace '^#?use_celery = .*', 'use_celery = true'
1610
1611 # cleanup rabbitmq example entry
1612 sed_replace '^#celery\.broker_url = amqp.*' ''
1613 sed_replace '^#?celery\.broker_url = .*' 'celery\.broker_url = redis:\/\/localhost:6379\/8'
1614
1615 # switch beaker sessions to Redis based
1616 sed_replace '^#?beaker.session.type = file.*' '#beaker.session.type = file'
1617 sed_replace '^#?beaker.session.data_dir = .*' '#beaker.session.data_dir = \/tmp\/data\/sessions'
1618
1619 # enable redis db2
1620 sed_replace '^#?beaker\.session\.type = ext:redis' 'beaker.session.type = ext:redis'
1621 sed_replace '^#?beaker\.session\.url = redis:\/\/127.0.0.1:6379\/2' 'beaker.session.url = redis:\/\/redis:6379\/2'
1622
1623 # sed_replace '^#?beaker.session.type = ext:database.*' 'beaker.session.type = ext:database'
1624 # sed_replace '^#?beaker.session.sa.url = postgresql.*' 'beaker.session.sa.url = postgresql://{{rhodecode_db_username}}:{{rhodecode_db_password}}@localhost/{{rhodecode_db_name}}'
1625
1626 # enable SVN
1627 sed_replace '^#?svn.proxy.generate_config = .*' 'svn.proxy.generate_config = true'
1628
1629 # enable SSH
1630 sed_replace '^#?ssh.generate_authorized_keyfile = .*' 'ssh.generate_authorized_keyfile = true'
1631
1632 # # the wrapper_cmd
1633 # sed_replace '^#?ssh.wrapper_cmd = .*' 'ssh.wrapper_cmd = /home/{{vm_account_name}}/dev-code/rhodecode-enterprise-ee/profile/bin/rc-ssh-wrapper'
1634 #
1635
1636 # '^#?api_access_controllers_whitelist = .*', 'api_access_controllers_whitelist = RepoFilesView:repo_archivefile, RepoFilesView:repo_file_raw'
1637 #
1638 #
1639 # # set search to elasticsearch
1640 # # enabled modules for Whoosh we remove, we have duplicates there..
1641 # '^search.module = .*', ''
1642 # '^search.location = .*', ''
1643 #
1644 # '^#?search.module = .*', 'search.module = rc_elasticsearch'
1645 # '^#?search.location = .*', 'search.location = http://localhost:9200'
1646 # '^#?search.es_version = .*', 'search.es_version = 6'
1647
1648 # # enable Chat
1649 # '^#?chat.enabled = .*', 'chat.enabled = true'
1650
1651 }
1652
1479 # src/lib/send_completions.sh
1653 # src/lib/send_completions.sh
1480 send_completions() {
1654 send_completions() {
1481 echo $'# rccontrol completion -*- shell-script -*-'
1655 echo $'# rccontrol completion -*- shell-script -*-'
@@ -1615,6 +1789,13 b' send_completions() {'
1615 echo $'# ex: filetype=sh'
1789 echo $'# ex: filetype=sh'
1616 }
1790 }
1617
1791
1792 # src/lib/utils.sh
1793 random_str() {
1794 len=$1
1795 random_generate=$(echo $RANDOM | md5sum | head -c $len)
1796 echo $random_generate
1797 }
1798
1618 # src/lib/validate_stack_exists.sh
1799 # src/lib/validate_stack_exists.sh
1619
1800
1620 validate_stack_exists() {
1801 validate_stack_exists() {
@@ -1662,6 +1843,8 b' rccontrol_self_update_command() {'
1662
1843
1663 ENV_VER=$REPLY
1844 ENV_VER=$REPLY
1664
1845
1846 echo "HERE"
1847 exit
1665 version_old=$($FINAL_TARGET --version)
1848 version_old=$($FINAL_TARGET --version)
1666
1849
1667 echo "$(green self-update: downloading new rccontrol script from $FETCH_FROM)"
1850 echo "$(green self-update: downloading new rccontrol script from $FETCH_FROM)"
@@ -1769,12 +1952,6 b' rccontrol_init_command() {'
1769 fi
1952 fi
1770 }
1953 }
1771
1954
1772 random_str() {
1773 len=$1
1774 random_generate=$(echo $RANDOM | md5sum | head -c $len)
1775 echo $random_generate
1776 }
1777
1778 bootstrap_config() {
1955 bootstrap_config() {
1779 shared_key=$(random_str 32)
1956 shared_key=$(random_str 32)
1780 db_key=$(random_str 32)
1957 db_key=$(random_str 32)
@@ -2327,7 +2504,8 b' rccontrol_stack_upgrade_rhodecode_command() {'
2327 echo "$(yellow Found unhealthy containers $unhealthy)"
2504 echo "$(yellow Found unhealthy containers $unhealthy)"
2328 for container in $unhealthy
2505 for container in $unhealthy
2329 do
2506 do
2330 echo "restart $container"
2507 docker stats --no-stream $container
2508 echo "unhealthy_log: restart $container"
2331 docker restart --time=10 $container
2509 docker restart --time=10 $container
2332 done
2510 done
2333
2511
@@ -2569,6 +2747,64 b' rccontrol_cli_attach_command() {'
2569 }
2747 }
2570
2748
2571 # :command.function
2749 # :command.function
2750 rccontrol_cli_configure_vcs_command() {
2751 # src/cli_configure_vcs_command.sh
2752 ini_path=${args[--ini-path]}
2753 DEBUG=${args[--debug]}
2754
2755 sed_replace() {
2756
2757 if [[ $DEBUG ]]; then
2758 echo "pat1: $1"
2759 echo "pat1: $2"
2760 echo
2761 echo "sed --in-place=.replaced -E \"s/$1/$2/\" $ini_path"
2762 fi
2763
2764 sed --in-place=.replaced -E "s/$1/$2/" $ini_path
2765 }
2766
2767 config_vcsserver_ini
2768
2769 echo
2770 echo "reconfigure of $ini_path completed"
2771
2772 }
2773
2774 # :command.function
2775 rccontrol_cli_configure_rhodecode_command() {
2776 # src/cli_configure_rhodecode_command.sh
2777 ini_path=${args[--ini-path]}
2778 DEBUG=${args[--debug]}
2779
2780 sed_replace() {
2781
2782 if [[ $DEBUG ]]; then
2783 echo "pat1: $1"
2784 echo "pat1: $2"
2785 echo
2786 echo "sed --in-place=.replaced -E \"s/$1/$2/\" $ini_path"
2787 fi
2788
2789 sed --in-place=.replaced -E "s/$1/$2/" $ini_path
2790 }
2791
2792 # read generated secrets etc from our .env file
2793 .env --file $RUNTIME_ENV
2794
2795 .env get RC_LICENSE_TOKEN
2796 RC_LICENSE_TOKEN=$REPLY
2797
2798 .env get RC_HOSTNAME
2799 RC_HOSTNAME=$REPLY
2800
2801 config_rhodecode_ini
2802
2803 echo
2804 echo "reconfigure of $ini_path completed"
2805 }
2806
2807 # :command.function
2572 rccontrol_backup_db_command() {
2808 rccontrol_backup_db_command() {
2573 # src/backup_db_command.sh
2809 # src/backup_db_command.sh
2574 check_bootstrap
2810 check_bootstrap
@@ -2671,6 +2907,10 b' parse_requirements() {'
2671 # :command.environment_variables_filter
2907 # :command.environment_variables_filter
2672 # :command.environment_variables_default
2908 # :command.environment_variables_default
2673 export RC_CLI_VERSION_NAME="${RC_CLI_VERSION_NAME:-4.28.0.REL.2022.12.22}"
2909 export RC_CLI_VERSION_NAME="${RC_CLI_VERSION_NAME:-4.28.0.REL.2022.12.22}"
2910 export RC_STACK_ROUTER_VER="${RC_STACK_ROUTER_VER:-v1}"
2911 export RC_STACK_SERVICES_VER="${RC_STACK_SERVICES_VER:-v1}"
2912 export RC_STACK_RHODECODE_VER="${RC_STACK_RHODECODE_VER:-v1}"
2913 export RC_STACK_METRICS_VER="${RC_STACK_METRICS_VER:-v1}"
2674 export RCC_CONFIG="${RCC_CONFIG:-.rccontrol.ini}"
2914 export RCC_CONFIG="${RCC_CONFIG:-.rccontrol.ini}"
2675 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
2915 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
2676 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
2916 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
@@ -4135,6 +4375,20 b' rccontrol_cli_parse_requirements() {'
4135 shift $#
4375 shift $#
4136 ;;
4376 ;;
4137
4377
4378 configure-vcs)
4379 action="configure-vcs"
4380 shift
4381 rccontrol_cli_configure_vcs_parse_requirements "$@"
4382 shift $#
4383 ;;
4384
4385 configure-rhodecode)
4386 action="configure-rhodecode"
4387 shift
4388 rccontrol_cli_configure_rhodecode_parse_requirements "$@"
4389 shift $#
4390 ;;
4391
4138 # :command.command_fallback
4392 # :command.command_fallback
4139 "")
4393 "")
4140 rccontrol_cli_usage >&2
4394 rccontrol_cli_usage >&2
@@ -4392,6 +4646,122 b' rccontrol_cli_attach_parse_requirements() {'
4392 }
4646 }
4393
4647
4394 # :command.parse_requirements
4648 # :command.parse_requirements
4649 rccontrol_cli_configure_vcs_parse_requirements() {
4650 # :command.fixed_flags_filter
4651 while [[ $# -gt 0 ]]; do
4652 case "${1:-}" in
4653 --help | -h)
4654 long_usage=yes
4655 rccontrol_cli_configure_vcs_usage
4656 exit
4657 ;;
4658
4659 *)
4660 break
4661 ;;
4662
4663 esac
4664 done
4665
4666 # :command.command_filter
4667 action="cli configure-vcs"
4668
4669 # :command.parse_requirements_while
4670 while [[ $# -gt 0 ]]; do
4671 key="$1"
4672 case "$key" in
4673 # :flag.case
4674 --ini-path)
4675
4676 # :flag.case_arg
4677 if [[ -n ${2+x} ]]; then
4678
4679 args[--ini-path]="$2"
4680 shift
4681 shift
4682 else
4683 printf "%s\n" "--ini-path requires an argument: --ini-path INI_PATH" >&2
4684 exit 1
4685 fi
4686 ;;
4687
4688 -?*)
4689 printf "invalid option: %s\n" "$key" >&2
4690 exit 1
4691 ;;
4692
4693 *)
4694 # :command.parse_requirements_case
4695 # :command.parse_requirements_case_simple
4696 printf "invalid argument: %s\n" "$key" >&2
4697 exit 1
4698
4699 ;;
4700
4701 esac
4702 done
4703
4704 }
4705
4706 # :command.parse_requirements
4707 rccontrol_cli_configure_rhodecode_parse_requirements() {
4708 # :command.fixed_flags_filter
4709 while [[ $# -gt 0 ]]; do
4710 case "${1:-}" in
4711 --help | -h)
4712 long_usage=yes
4713 rccontrol_cli_configure_rhodecode_usage
4714 exit
4715 ;;
4716
4717 *)
4718 break
4719 ;;
4720
4721 esac
4722 done
4723
4724 # :command.command_filter
4725 action="cli configure-rhodecode"
4726
4727 # :command.parse_requirements_while
4728 while [[ $# -gt 0 ]]; do
4729 key="$1"
4730 case "$key" in
4731 # :flag.case
4732 --ini-path)
4733
4734 # :flag.case_arg
4735 if [[ -n ${2+x} ]]; then
4736
4737 args[--ini-path]="$2"
4738 shift
4739 shift
4740 else
4741 printf "%s\n" "--ini-path requires an argument: --ini-path INI_PATH" >&2
4742 exit 1
4743 fi
4744 ;;
4745
4746 -?*)
4747 printf "invalid option: %s\n" "$key" >&2
4748 exit 1
4749 ;;
4750
4751 *)
4752 # :command.parse_requirements_case
4753 # :command.parse_requirements_case_simple
4754 printf "invalid argument: %s\n" "$key" >&2
4755 exit 1
4756
4757 ;;
4758
4759 esac
4760 done
4761
4762 }
4763
4764 # :command.parse_requirements
4395 rccontrol_backup_db_parse_requirements() {
4765 rccontrol_backup_db_parse_requirements() {
4396 # :command.fixed_flags_filter
4766 # :command.fixed_flags_filter
4397 while [[ $# -gt 0 ]]; do
4767 while [[ $# -gt 0 ]]; do
@@ -4548,6 +4918,10 b' initialize() {'
4548
4918
4549 # :command.environment_variables_default
4919 # :command.environment_variables_default
4550 export RC_CLI_VERSION_NAME="${RC_CLI_VERSION_NAME:-4.28.0.REL.2022.12.22}"
4920 export RC_CLI_VERSION_NAME="${RC_CLI_VERSION_NAME:-4.28.0.REL.2022.12.22}"
4921 export RC_STACK_ROUTER_VER="${RC_STACK_ROUTER_VER:-v1}"
4922 export RC_STACK_SERVICES_VER="${RC_STACK_SERVICES_VER:-v1}"
4923 export RC_STACK_RHODECODE_VER="${RC_STACK_RHODECODE_VER:-v1}"
4924 export RC_STACK_METRICS_VER="${RC_STACK_METRICS_VER:-v1}"
4551 export RCC_CONFIG="${RCC_CONFIG:-.rccontrol.ini}"
4925 export RCC_CONFIG="${RCC_CONFIG:-.rccontrol.ini}"
4552 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
4926 export RC_STACK_ROUTER_EXT="${RC_STACK_ROUTER_EXT:-.custom/docker-compose-router.override.yaml}"
4553 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
4927 export RC_STACK_METRICS_EXT="${RC_STACK_METRICS_EXT:-.custom/docker-compose-metrics.override.yaml}"
@@ -4905,6 +5279,24 b' run() {'
4905 fi
5279 fi
4906 ;;
5280 ;;
4907
5281
5282 "cli configure-vcs")
5283 if [[ ${args[--help]:-} ]]; then
5284 long_usage=yes
5285 rccontrol_cli_configure_vcs_usage
5286 else
5287 rccontrol_cli_configure_vcs_command
5288 fi
5289 ;;
5290
5291 "cli configure-rhodecode")
5292 if [[ ${args[--help]:-} ]]; then
5293 long_usage=yes
5294 rccontrol_cli_configure_rhodecode_usage
5295 else
5296 rccontrol_cli_configure_rhodecode_command
5297 fi
5298 ;;
5299
4908 "backup-db")
5300 "backup-db")
4909 if [[ ${args[--help]:-} ]]; then
5301 if [[ ${args[--help]:-} ]]; then
4910 long_usage=yes
5302 long_usage=yes
General Comments 0
You need to be logged in to leave comments. Login now