2022年6月30日星期四

Tomcat X-server

1. x-server2.7  :odcaw2_servlet 

    ref: javax.servlet*;


2. tomcat 9: servlet-api.jar: javax.servlet*

3. tomcat 10: servlet-api.jar: jakarta.servlet*


Correct Env:  Tomcat9 +  X-server2.7 

Comfirm url: http://localhost:8080/oxs/odcaw2_servlet



2022年6月21日星期二

Oracle Tablename/Columns comments

1.  get all table comments

SELECT TABLE_NAME
,COMMENTS
FROM USER_TAB_COMMENTS

2.  get sql for tables comments

SELECT 'COMMENT ON TABLE ' || TABLE_NAME || ' IS ''' || COMMENTS  ||  ''';' AS SQL
FROM USER_TAB_COMMENTS

3. get sql for columns comments 
SELECT T.TABLE_NAME,
C.COLUMN_NAME
,C.COMMENTS
, 'COMMENT ON COLUMN ' || T.TABLE_NAME || '.' || C.COLUMN_NAME || ' IS ''' || C.COMMENTS || ''';' AS SQL
FROM USER_TAB_COMMENTS T, USER_COL_COMMENTS C
where T.TABLE_NAME = C.TABLE_NAME

2022年6月17日星期五

2022年6月13日星期一

linux stat file


$  stat /etc/passwd
  File: ‘/etc/passwd’
  Size: 1596            Blocks: 8          IO Block: 4096   regular file
Device: ca01h/51713d    Inode: 19293210    Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2022-06-03 09:21:07.905548960 +0900
Modify: 2022-06-03 09:21:07.909549008 +0900
Change: 2022-06-03 09:21:07.909549008 +0900
 Birth: -
$  stat -c "%Y" /etc/passwd   # time of last modification, seconds since Epoch
1654215667
stat --help
Usage: stat [OPTION]... FILE...
Display file or file system status.

Mandatory arguments to long options are mandatory for short options too.
  -L, --dereference     follow links
  -f, --file-system     display file system status instead of file status
  -c  --format=FORMAT   use the specified FORMAT instead of the default;
                          output a newline after each use of FORMAT
      --printf=FORMAT   like --format, but interpret backslash escapes,
                          and do not output a mandatory trailing newline;
                          if you want a newline, include \n in FORMAT
  -t, --terse           print the information in terse form
      --help     display this help and exit
      --version  output version information and exit

The valid format sequences for files (without --file-system):

  %a   access rights in octal
  %A   access rights in human readable form
  %b   number of blocks allocated (see %B)
  %B   the size in bytes of each block reported by %b
  %C   SELinux security context string
  %d   device number in decimal
  %D   device number in hex
  %f   raw mode in hex
  %F   file type
  %g   group ID of owner
  %G   group name of owner
  %h   number of hard links
  %i   inode number
  %m   mount point
  %n   file name
  %N   quoted file name with dereference if symbolic link
  %o   optimal I/O transfer size hint
  %s   total size, in bytes
  %t   major device type in hex, for character/block device special files
  %T   minor device type in hex, for character/block device special files
  %u   user ID of owner
  %U   user name of owner
  %w   time of file birth, human-readable; - if unknown
  %W   time of file birth, seconds since Epoch; 0 if unknown
  %x   time of last access, human-readable
  %X   time of last access, seconds since Epoch
  %y   time of last modification, human-readable
  %Y   time of last modification, seconds since Epoch
  %z   time of last change, human-readable
  %Z   time of last change, seconds since Epoch

Valid format sequences for file systems:

  %a   free blocks available to non-superuser
  %b   total data blocks in file system
  %c   total file nodes in file system
  %d   free file nodes in file system
  %f   free blocks in file system
  %i   file system ID in hex
  %l   maximum length of filenames
  %n   file name
  %s   block size (for faster transfers)
  %S   fundamental block size (for block counts)
  %t   file system type in hex
  %T   file system type in human readable form

NOTE: your shell may have its own version of stat, which usually supersedes
the version described here.  Please refer to your shell's documentation
for details about the options it supports.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'stat invocation'

linux date format

$ date
Mon Jun 13 03:31:39 UTC 2022
# 現在の日時をUTCで表示
$ date -u
Mon Jun 13 03:35:28 UTC 2022
# format: ymd-hms
$ date "+%Y%m%d-%H%M%S"
20220613-033446
#formart: ymd
$date "+%Y%m%d"
# 10日後の日付を表示
date "+%Y/%m/%d" -d "10 days"   # days,week,month, year 
#root より、時刻の調整
date -s "2022/06/13 12:34:00"
$ date --help
Usage: date [OPTION]... [+FORMAT]
  or:  date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.

Mandatory arguments to long options are mandatory for short options too.
  -d, --date=STRING         display time described by STRING, not 'now'
  -f, --file=DATEFILE       like --date once for each line of DATEFILE
  -I[TIMESPEC], --iso-8601[=TIMESPEC]  output date/time in ISO 8601 format.
                            TIMESPEC='date' for date only (the default),
                            'hours', 'minutes', 'seconds', or 'ns' for date
                            and time to the indicated precision.
  -r, --reference=FILE      display the last modification time of FILE
  -R, --rfc-2822            output date and time in RFC 2822 format.
                            Example: Mon, 07 Aug 2006 12:34:56 -0600
      --rfc-3339=TIMESPEC   output date and time in RFC 3339 format.
                            TIMESPEC='date', 'seconds', or 'ns' for
                            date and time to the indicated precision.
                            Date and time components are separated by
                            a single space: 2006-08-07 12:34:56-06:00
  -s, --set=STRING          set time described by STRING
  -u, --utc, --universal    print or set Coordinated Universal Time (UTC)
      --help     display this help and exit
      --version  output version information and exit

FORMAT controls the output.  Interpreted sequences are:

  %%   a literal %
  %a   locale's abbreviated weekday name (e.g., Sun)
  %A   locale's full weekday name (e.g., Sunday)
  %b   locale's abbreviated month name (e.g., Jan)
  %B   locale's full month name (e.g., January)
  %c   locale's date and time (e.g., Thu Mar  3 23:05:25 2005)
  %C   century; like %Y, except omit last two digits (e.g., 20)
  %d   day of month (e.g., 01)
  %D   date; same as %m/%d/%y
  %e   day of month, space padded; same as %_d
  %F   full date; same as %Y-%m-%d
  %g   last two digits of year of ISO week number (see %G)
  %G   year of ISO week number (see %V); normally useful only with %V
  %h   same as %b
  %H   hour (00..23)
  %I   hour (01..12)
  %j   day of year (001..366)
  %k   hour, space padded ( 0..23); same as %_H
  %l   hour, space padded ( 1..12); same as %_I
  %m   month (01..12)
  %M   minute (00..59)
  %n   a newline
  %N   nanoseconds (000000000..999999999)
  %p   locale's equivalent of either AM or PM; blank if not known
  %P   like %p, but lower case
  %r   locale's 12-hour clock time (e.g., 11:11:04 PM)
  %R   24-hour hour and minute; same as %H:%M
  %s   seconds since 1970-01-01 00:00:00 UTC
  %S   second (00..60)
  %t   a tab
  %T   time; same as %H:%M:%S
  %u   day of week (1..7); 1 is Monday
  %U   week number of year, with Sunday as first day of week (00..53)
  %V   ISO week number, with Monday as first day of week (01..53)
  %w   day of week (0..6); 0 is Sunday
  %W   week number of year, with Monday as first day of week (00..53)
  %x   locale's date representation (e.g., 12/31/99)
  %X   locale's time representation (e.g., 23:13:48)
  %y   last two digits of year (00..99)
  %Y   year
  %z   +hhmm numeric time zone (e.g., -0400)
  %:z  +hh:mm numeric time zone (e.g., -04:00)
  %::z  +hh:mm:ss numeric time zone (e.g., -04:00:00)
  %:::z  numeric time zone with : to necessary precision (e.g., -04, +05:30)
  %Z   alphabetic time zone abbreviation (e.g., EDT)

By default, date pads numeric fields with zeroes.
The following optional flags may follow '%':

  -  (hyphen) do not pad the field
  _  (underscore) pad with spaces
  0  (zero) pad with zeros
  ^  use upper case if possible
  #  use opposite case if possible

After any flags comes an optional field width, as a decimal number;
then an optional modifier, which is either
E to use the locale's alternate representations if available, or
O to use the locale's alternate numeric symbols if available.

Examples:
Convert seconds since the epoch (1970-01-01 UTC) to a date
  $ date --date='@2147483647'

Show the time on the west coast of the US (use tzselect(1) to find TZ)
  $ TZ='America/Los_Angeles' date

Show the local time for 9AM next Friday on the west coast of the US
  $ date --date='TZ="America/Los_Angeles" 09:00 next Fri'

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
For complete documentation, run: info coreutils 'date invocation'

2022年6月7日星期二

gitlab webhook shell

事前準備

1. webhook docker run.sh 

```
docker run -u root --rm -d -p 9000:9000 \

-v /home/$(whoami)/data/webhook:/etc/webhook \
--name=webhook \
almir/webhook -verbose -hooks=/etc/webhook/hooks.json -hotreload -logfile=/etc/webhook/run.tlog

```

2. hooks.json for gitlab merge request state=merged

#=================

[
  {
    "id": "redeploy",
    "execute-command": "/etc/webhook/redeploy.sh",
    "command-working-directory": "/etc/webhook",
    "response-message": "Executing deploy script...\n",
    "pass-arguments-to-command":
    [
      {
        "source": "payload",
        "name": "project.namespace"
      },
      {
        "source": "payload",
        "name": "project.name"
      },
      {
        "source": "payload",
        "name": "event_type"
      },
      {
        "source": "payload",
        "name": "object_attributes.state"
      },
    ],
    "trigger-rule":
    {
      "and":
      [
      {
      "match":
      {
        "type": "value",
        "value": "{you-webhook-token}",
        "parameter":
        {
          "source": "header",
          "name": "X-Gitlab-Token"
        }
      }   
      },
      {
      "match":
      {
        "type": "regex",
        "regex": "merge_request",
        "parameter":
        {
          "source": "payload",
          "name": "event_type"
        }
      }   
      },
      {
      "match":
      {
        "type": "regex",
        "regex": "merged",
        "parameter":
        {
          "source": "payload",
          "name": "object_attributes.state"
        }
      }
      }
      ]
    }
  }
]

#=================


3. redeploy.sh

#!/bin/sh    #required. format error if no this.
#$1=project.namespace (groupname)
#$2=project.name

echo "$1_$2" > /etc/webhook/$1_$2.log

#l read and write log by anyone 
chmod 666 *.log

4. test webhook 

curl http://localhost:9000/hooks/{id}

6. set webhook url to gitlab 

gitlab/group/project/setting

set webhook url and do test. 

7. cicd.sh

logfile="/etc/webhook/groupname/projectname.log"
#check filetimestamp.
lastModifytime=$(date )


while true
do 

  if [ -e $logfile ]; then
    nowtime=$(stat -c $logfile | grep 'Modify: ' | cut -d' ' -f2,3,4)

    if [ $nowtime -gt $lastModifytime ]; then 

        lastModifytime=$nowtime

        #remove first 
        #rm $logfile
        #do git pull and resync
        cd $git_project_folder  
        git pull 
        resync $from_git_path $to_webserver_path

     fi  
  else

    #sleep 5s
    sleep 5  

  fi   

done 

repo path

 repo path=

https://servername/modulename/versionid/modulename-versionid.zip

2022年6月3日星期五

docker webhook

 1.   hooks.yaml 

- id: redeploy-webhook

  execute-command: "/etc/webhook/redeploy.sh"

  command-working-directory: "/etc/webhook"

  

2.  redeploy.sh
#!/bin/bash
date > /tmp/result_test_shell.log
echo $0 > /tmp/result_test_shell.log

3. docker run.sh

docker run -d -p 9000:9000 \
-v /home/ec2-user/data/webhook:/etc/webhook  \
-v /home/ec2-user/data/develop/imartstorage:/var/imartstorage \
-v /home/ec2-user/data/develop/imartstorage:/var/imartstorage \
-v /home/ec2-user/develop: /var/develop \ 
-v /home/ec2-user/develop: /var/develop \ 
-v /home/ec2-user/resindata: /var/resindata\  
 --name=webhook   almir/webhook -verbose -hooks=/etc/webhook/hooks.yaml -hotreload

2.