Skip to content

Instantly share code, notes, and snippets.

View gomasy's full-sized avatar

Gomasy gomasy

View GitHub Profile
@gomasy
gomasy / tailscaled
Last active May 4, 2024 00:20
Test implementation of /etc/init.d/tailscaled
#!/bin/bash
#
# tailscaled Start up the Tailscale server daemon
#
# description: A mesh VPN that makes it easy to connect your devices, wherever they are.
#
# processname: tailscaled
### BEGIN INIT INFO
# Provides: tailscaled
diff --git a/configure.ac b/configure.ac
index 82e8bb7..a431e05 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4870,6 +4870,30 @@ AC_SUBST([GSSLIBS])
AC_SUBST([K5LIBS])
AC_SUBST([CHANNELLIBS])
+# Check whether user wants systemd support
+SYSTEMD_MSG="no"
package main
import (
"bufio"
"fmt"
"log"
"net"
"strconv"
"golang.org/x/text/transform"
.status__wrapper .status {
padding: 8px 10px 8px 8px;
}
.status__wrapper .status__content {
line-height: 20px;
margin-left: 56px;
margin-top: -34px;
}
@gomasy
gomasy / nut-governor.c
Last active March 24, 2022 00:54
CPU governor changer for Network UPS Tools
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
const char basepath[] = "/sys/devices/system/cpu/cpu%d/cpufreq/%s";
void update_governor(int cpu, char *gov) {
FILE *fp;
char path[64];
@gomasy
gomasy / ssh-alert.rb
Last active March 7, 2018 13:03
ゴリ押し
require "net/https"
require "ipaddr"
require "json"
require "uri"
slack_url = URI.parse("") # slack webhook url
user = ENV["USER"]
remote_ip = IPAddr.new(ENV["SSH_CONNECTION"].split(" ")[0])
local_ip = IPAddr.new(ENV["SSH_CONNECTION"].split(" ")[2])
@gomasy
gomasy / mail2slack.rb
Last active March 6, 2020 01:21
ありがとう Slack
require "digest/md5"
require "net/https"
require "json"
require "mail"
require "time"
require "uri"
def parse_envelope(data)
if data.multipart?
data.parts.map do |pt|
#!/bin/sh
declare -A prev
declare -A next
renewal=0
domain=("gomasy.jp" "gomasy.net")
for d in ${domain[@]}; do
prev+=([$d]=`date -r /etc/letsencrypt/live/$d/cert.pem "+%s"`)
@gomasy
gomasy / mail.rb
Last active July 13, 2017 00:09
なんか
require "net/smtp"
require "securerandom"
require "base64"
FOOTER = "\n\n-----\nThis mail was issued by Ruby #{RUBY_VERSION} on Arch Linux (x86_64)."
def send_mail(server, from, to, subject, body)
Net::SMTP.start(server[:host], server[:port], `uname -n`.chomp, server[:user], server[:pass], :cram_md5) do |smtp|
smtp.send_message(
"Message-Id: <#{SecureRandom.uuid}@#{server[:host]}>\n" + \
@gomasy
gomasy / 00-route.sh
Last active August 19, 2018 13:58
xl2tpd により L2TP コネクションが確立した際に自動的に経路を追加するスクリプト
#!/bin/sh
# This script is run by pppd after the link is established.
# It executes all the scripts available in /etc/ppp/ip-up.d directory,
# with the following parameters:
# $1 = interface name (e.g. ppp0)
# $2 = tty device
# $3 = speed
# $4 = local IP address
# $5 = remote IP address