macOS Big SurでCUnitのmake

CUnitを利用したくてmakeしたのでメモ。

CUnitをダウンロードする。 sourceforge.net

$ bunzip2 CUnit-2.1-2-src.tar.bz2
$ tar -xvf CUnit-2.1-2-src.tar
$ CUnit-2.1-2
$ ./configure --prefix=/usr/local
$ make
$ sudo make install

test.c

#include "CUnit/Basic.h"

int maxi(int i1, int i2) {
    return (i1 > i2) ? i1 : i2;
}

int init_suite_success(void) {
    return 0;
}

int clean_suite_success(void) {
    return 0;
}

void test_maxi(void) {
    CU_ASSERT(maxi(0,2) == 2);
    CU_ASSERT(maxi(0,-2) == 0);
    CU_ASSERT(maxi(2,2) == 2);
}

int main() {
    CU_pSuite pSuite = NULL;

    if (CUE_SUCCESS != CU_initialize_registry()) {
        return CU_get_error();
    }

    pSuite = CU_add_suite("suite success", init_suite_success, clean_suite_success);
    if (pSuite == NULL) {
        CU_cleanup_registry();
        return CU_get_error();
    }

    if (CU_add_test(pSuite, "test maxi", test_maxi) == NULL) {
      CU_cleanup_registry();
      return CU_get_error();
   }

    CU_basic_set_mode(CU_BRM_VERBOSE);
    CU_basic_run_tests();
    CU_basic_show_failures(CU_get_failure_list());
    CU_cleanup_registry();

    return CU_get_error();
}
$ gcc -o test test.c -lcunit
$ ./test


     CUnit - A unit testing framework for C - Version 2.1-2
     http://cunit.sourceforge.net/


Suite: suite success
  Test: test maxi ...passed

Run Summary:    Type  Total    Ran Passed Failed Inactive
              suites      1      1    n/a      0        0
               tests      1      1      1      0        0
             asserts      3      3      3      0      n/a

Elapsed time =    0.000 seconds

CentOS7.6でMetabaseをサービスとして起動

サービス用のファイル作成

#vi /etc/systemd/system/metabase.service

[Unit]
Description=Metabase.

[install]
WantedBy=multi-user.target

[Service]
Restart=always
User=root
Type=simple
WorkingDirectory=/opt/
ExecStop=/bin/kill -SIGTERM $MAINPID
ExecStart=/usr/bin/java -jar /opt/metabase.jar
SyslogIdentifier=metabase

起動

#systemctl start metabase

自動起動設定

#systemctl enable metabase

RundeckでのSSH設定

# cp id_rsa /var/lib/rundeck/.ssh
  • 対象プロジェクトのresourcesファイルに以下を追加
ssh-authentication="privateKey"
ssh-keypath="/var/lib/rundeck/.ssh/id_rsa"
sh-key-passphrase-storage-path="keys/ssh_key_passphrase"

※Key Typeには「Password」を選択

# chmod 600 /var/lib/rundeck/var/storage/content/keys/ssh_key_passphrase

SSH Private Key Passphrase with a Job Option
http:// http://rundeck.org/docs/plugins-user-guide/ssh-plugins.html#ssh-private-key-passphrase-with-a-job-option

CentOS7.2にRundeckをインストール

1. Javaをインストール

# yum install -y java-1.8.0 

2. Rundeckパッケージインストール

# rpm -Uvh http://repo.rundeck.org/latest.rpm

3. Rundeckインストール

# yum install -y rundeck

4. Rundeck起動

# systemctl start rundeckd

5. Rundeck自動起動

# systemctl enable rundeckd

6. URL設定

# vi /etc/rundeck/rundeck-config.properties
  :%s/localhost/対象サーバのIPアドレスもしくはホスト名/gc
# vi /etc/rundeck/framework.properties
  :%s/localhost/対象サーバのIPアドレスもしくはホスト名/gc

7. Rundeck用にサービスとポート開放

# firewall-cmd --add-port=4440/tcp --permanent
# firewall-cmd --add-service=http --permanent
# firewall-cmd --reload

8. adminパスワードをハッシュ化

# java -cp /var/lib/rundeck/bootstrap/jetty-all-9.0.7.v20131107.jar org.eclipse.jetty.util.security.Password admin パスワード

9. アドミンのパスワードをハッシュ値に変更

# vi /etc/rundeck/realm.properties

10. Rundeck再起動

# systemctl restart rundeckd

Twitter APIからいいねを取得しVue.jsとBootstrapでカード表示

HTML

<div id="app" class="card-columns">
      
      <div class="card" v-for="favorite in favorites">
          <template v-if="favorite.extended_entities != ''">
              <template v-for="entity in favorite.extended_entities">
                  <template v-for="media in entity">
                      <img class="card-img-top img-fluid" v-bind:src="media.media_url_https" alt="">
                  </template>
              </template>
          </template>

          <div class="card-block">
              <p class="card-text">{{ favorite.text }}</p>
          </div>
        
      </div>
      
    </div>

JavaScript

var app = new Vue({
            el: '#app',
            data: {
                favorites: []
            },
		    mounted() {
		        axios.get("https://xxx")
			    .then(response => {
			        this.favorites = response.data
			    })
		    }
        })