Skip to content

Commit

Permalink
pass target host on cmdline
Browse files Browse the repository at this point in the history
  • Loading branch information
andylytical committed Feb 15, 2024
1 parent 2b59dbe commit 718db33
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 30 deletions.
25 changes: 4 additions & 21 deletions cleanup/jira_setup_ldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,35 +217,18 @@ def web_delete_by_id( id, path, addl_form_data={} ):
return r


def set_banner():
banner = get_config().get( 'server', 'banner' )
path = '/secure/admin/EditAnnouncementBanner.jspa'
data = {
'announcement': banner,
'bannerVisibility': 'private',
'Set Banner': 'Set Banner',
'atl_token': get_atl_token(),
}
r = post_sudo_path( path, data )
logging.info( 'Banner set!' )


def set_general_config():
data = { k:v for k,v in get_config().items( 'general config' ) }
# cfg = get_config()
# data = { k:cfg['general config'][k] for k in ( 'baseURL', 'title', 'useGzip' ) }
def setup_ldap():
data = { k:v for k,v in get_config().items( 'LDAP' ) }
# pprint.pprint( data )
data.update( { 'atl_token': get_atl_token(), 'Update': 'Update' } )
path = '/secure/admin/EditApplicationProperties.jspa'
path = '/plugins/servlet/embedded-crowd/configure/ldap/'
r = post_sudo_path( path, data )


def run():
# starttime = time.time()

set_banner()

set_general_config()
setup_ldap()

# elapsed = time.time() - starttime
# logging.info( f'Finished in {elapsed} seconds!' )
Expand Down
18 changes: 10 additions & 8 deletions cleanup/jiractl
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@

### VARIABLES

declare -A APPDIR
APPDIR['jira-test']=/usr/services/jira-standalone
APPDIR['jira-dev-m1']=/srv/jira/app


### FUNCTIONS
Expand All @@ -26,13 +23,15 @@ case "$1" in
esac

# get host
case "$2" in
jira-test|jira-dev-m1)
host="$2"
appdir="${APPDIR[$host]}"
host="$2"
[[ -z "$host" ]] && die 'Missing host'
case "$host" in
jira-test)
appdir=/usr/services/jira-standalone
;;
*)
die 'Missing or unknown host'
appdir=/srv/jira/app
;;
esac

# Decide command to run
Expand All @@ -50,6 +49,9 @@ case "$action" in
logsf)
cmd="tail -f ${appdir}/logs/catalina.out"
;;
off|power|shutdown)
cmd='shutdown -h now'
;;
esac

set -x
Expand Down
15 changes: 14 additions & 1 deletion cleanup/send_migration_file.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### VARIABLES
SRC_HOST=jira-test
SRC_PATH=/usr/services/jirahome/export/projectconfigurator
TGT_HOST=jira-dev-m1
# TGT_HOST=jira-dev-m1
TGT_PATH=/srv/jira/home/import/projectconfigurator


Expand All @@ -22,6 +22,12 @@ ask_yes_no() {
}


die() {
echo "ERROR: $*" 1>&2
exit 99
}


clean_tgt() {
echo "Clean up old files on $TGT_HOST:"
ssh $TGT_HOST "sudo find $TGT_PATH -type f -print -delete"
Expand Down Expand Up @@ -63,7 +69,14 @@ ls_src() {
echo
}


get_host() {
TGT_HOST="$1"
[[ -z "$TGT_HOST" ]] && die "Missing target hostname"
}

### MAIN
get_host "$1"

ls_tgt
ask_yes_no "Clean target ($TGT_HOST)? " && clean_tgt
Expand Down

0 comments on commit 718db33

Please sign in to comment.